Skip to main content
Home
Works with
This package works with Node.js, Deno
This package works with Node.js
This package works with Deno
JSR Score100%
Downloads1/wk
Publisheda year ago (1.2.0)

File Writer supports multiple asynchronous write operations while preventing racing conditions.

This module exports two functions: appendText and writeText.

The purpose of this functions is to work asynchronously without the need of waiting for the result.

If multiple write requests appear without the previous write job has been finished, the functions cache the data and reschedule the operation.

import { appendText } from "@popov/file-writer";

appendText("log.txt", "foo\n");
appendText("log.txt", "bar\n");

// `log.txt` contains:
// foo
// bar
import { writeText } from "@popov/file-writer";

writeText("log.txt", "foo\n");
writeText("log.txt", "bar\n");

// `log.txt` contains:
// bar

This module works in Deno and NodeJS.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@popov/file-writer

Import symbol

import * as file_writer from "@popov/file-writer";
or

Import directly with a jsr specifier

import * as file_writer from "jsr:@popov/file-writer";

Add Package

pnpm i jsr:@popov/file-writer
or (using pnpm 10.8 or older)
pnpm dlx jsr add @popov/file-writer

Import symbol

import * as file_writer from "@popov/file-writer";

Add Package

yarn add jsr:@popov/file-writer
or (using Yarn 4.8 or older)
yarn dlx jsr add @popov/file-writer

Import symbol

import * as file_writer from "@popov/file-writer";

Add Package

vlt install jsr:@popov/file-writer

Import symbol

import * as file_writer from "@popov/file-writer";

Add Package

npx jsr add @popov/file-writer

Import symbol

import * as file_writer from "@popov/file-writer";