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

fs-write-stream-atomic-modern

v1.0.10

Published

A compatibility-focused modern fork of fs-write-stream-atomic.

Downloads

173

Readme

fs-write-stream-atomic-modern

fs-write-stream-atomic-modern is a compatibility-focused maintained fork of fs-write-stream-atomic.

It provides the same CommonJS Writable-stream API for supported modern Node.js versions, while replacing safe-to-remove legacy dependencies and modernizing the tests, type declarations, and cross-platform CI.

Install

npm install fs-write-stream-atomic-modern

Node.js 22 or newer is required.

Usage

const fs = require('node:fs')
const fsWriteStreamAtomic = require('fs-write-stream-atomic-modern')

const destination = fsWriteStreamAtomic('output.txt')
fs.createReadStream('input.txt').pipe(destination)

destination.on('finish', () => {
  // The temporary file has closed and the rename has completed. At this point
  // output.txt contains all bytes accepted by this stream.
})

The export works both as a function and as a constructor:

const first = fsWriteStreamAtomic('first.txt')
const second = new fsWriteStreamAtomic('second.txt')

fsWriteStreamAtomic(filename[, options])

  • filename accepts the path values supported by fs.WriteStream.
  • options.chown may contain numeric uid and gid values. Ownership is applied to the temporary file before rename.
  • options.encoding defaults to utf8.
  • options.mode defaults to 0o666.
  • options.flags defaults to w.
  • Other Writable and filesystem WriteStream options are forwarded for compatibility.

The returned object is a Writable stream. It supports write(), end(), pipe() as a destination, destroy(), and the normal EventEmitter methods.

Completion events

This package intentionally delays its outer finish event. The sequence on a successful write is:

write temporary file
→ close temporary file
→ optional chown
→ rename temporary file over destination
→ finish
→ asynchronous boundary
→ close

Therefore the destination is ready when finish fires. On an operation error, the stream attempts to remove its temporary file and emits error before close; it does not emit finish.

What “atomic” means here

The package writes beside the destination and then asks the filesystem to replace the destination with rename(). On filesystems where same-filesystem rename replacement is atomic, readers do not observe a partially streamed destination.

This is not a power-loss durability guarantee. The package does not call fsync(), does not provide a cross-filesystem copy fallback, and cannot extend local rename guarantees to every network filesystem.

Migrating without changing imports

After this package is published, npm aliases can let an application retain its old require('fs-write-stream-atomic') calls:

{
  "dependencies": {
    "fs-write-stream-atomic": "npm:fs-write-stream-atomic-modern@^1.0.10"
  }
}

See COMPATIBILITY.md for observable behavior and known differences, and MODERNIZATION.md for the dependency and tooling decisions.

Credits and license

The original implementation is by Isaac Z. Schlueter and contributors. This fork retains the ISC license and original copyright notice.