function readIfThere
readIfThere(file: string): string | null

A file's contents, or null when it cannot be read — a missing path is an answer, not a crash.

Sync for the same reason writeIfPossible is: .cat, .type and .copy each make one read that the answer is waiting on, and readFileSync measured ~0.35ms against ~0.59ms for the promise. The reads that BRACKET an editor session are async — nobody is waiting on those.

import { readIfThere } from './editor.ts';

readIfThere('/definitely/not/here'); // null

Parameters

file: string

Return Type

string | null

Usage

import { readIfThere } from "lib/commands/repl/editor.ts";