npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stackline/fs-write-stream-atomic

v1.0.1

Published

Compatibility-first atomic filesystem Writable streams with maintained lifecycle handling and first-party types

Readme

@stackline/fs-write-stream-atomic

A compatibility-first maintained continuation of [email protected]. It exposes a Node.js Writable stream that writes to an adjacent temporary file and replaces the target only after the temporary stream has closed successfully.

npm install @stackline/fs-write-stream-atomic

Existing dependency keys can migrate with an npm alias:

npm install fs-write-stream-atomic@npm:@stackline/fs-write-stream-atomic

CommonJS

const createWriteStreamAtomic = require('@stackline/fs-write-stream-atomic')

const output = createWriteStreamAtomic('output.txt', { mode: 0o600 })
output.on('error', console.error)
output.on('close', () => console.log('replacement visible'))
output.end('complete value')

The factory remains callable with or without new.

ESM

import createWriteStreamAtomic, { WriteStreamAtomic } from '@stackline/fs-write-stream-atomic'

const output = new WriteStreamAtomic('output.txt')
output.end('complete value')

Options and events

The documented filename is a string. Writable and file-stream options such as encoding, mode, flags, and highWaterMark are supported. An additional chown: { uid, gid } option applies ownership before rename.

open reflects the temporary file descriptor. On success, finish occurs only after the physical file closes and rename succeeds; close follows it. The existing target remains visible until then. Contending writers publish one complete winner.

Append flags preserve upstream behavior: because every operation starts with a new temporary file, flags: 'a' replaces the target with newly streamed content rather than appending to its old content.

Error and cancellation cleanup

Use stream.pipeline() when connecting a source so a source error destroys the destination and removes its temporary file:

const { pipeline } = require('stream')
pipeline(input, createWriteStreamAtomic('output.txt'), callback)

Bare .pipe() does not forward source errors. Call destination.destroy(error) yourself if the source is managed separately. Explicit destroy and ordinary write/chown/rename failures are cleaned up. Abrupt process termination can still leave a temporary file.

Atomicity boundary

The adjacent rename supplies atomic visibility on filesystems that provide it. This package does not fsync the file or parent directory and does not claim power-loss durability. It is not a transaction across multiple files.

See COMPATIBILITY_CONTRACT.md and MIGRATION.md before replacing the historical package.