function writeIfPossible
writeIfPossible(
file: string,
contents: string
): boolean

True when the file was written. A save that cannot land is a message, not a crashed session.

Sync, unlike the writes around an editor session: .save is one write with a person waiting on its answer, and a single writeFileSync beats the promise it would otherwise allocate. Nothing else is queued behind it to be blocked.

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

writeIfPossible('/definitely/not/here/a.txt', 'x'); // false

Parameters

file: string
contents: string

Return Type

boolean

Usage

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