Reader(pathOrOptions[, stat])
Inspect and stream
Callable with or without new. Returns the specialized reader and exposes path, type, size, props, parent/root context, and lifecycle events.
Node.js filesystem streams · ISC
Walk files and directory trees as stat-bearing stream objects, then pipe them into metadata-aware writers—without abandoning the established fstream@1.0.12 contract.
npm install @stackline/fstream
Keep an existing import unchanged with fstream: npm:@stackline/fstream in your dependencies.
01 / Object-stream model
A Reader discovers the filesystem type, exposes stat metadata, and selects the matching file, directory, link, socket, or proxy reader. A directory emits direct entry objects and recursive child objects. Pipe the root into a Writer to recreate the tree and supported metadata.
02 / Quick start
The destination type can be inferred. Attach error listeners before the stream begins changing the filesystem.
const fstream = require('@stackline/fstream')
const reader = fstream.Reader({
path: 'source',
sort: 'alpha'
})
const writer = fstream.Writer('destination')
reader.on('error', console.error)
writer.on('error', console.error)
reader.pipe(writer)
03 / Public API
Reader(pathOrOptions[, stat])
Callable with or without new. Returns the specialized reader and exposes path, type, size, props, parent/root context, and lifecycle events.
Writer(pathOrOptions[, stat])
Creates files, directories, symbolic links, and hard links; creates missing parents; and applies requested mode, ownership, and timestamps where the host permits.
collect(stream)
Pauses a compatible legacy stream and buffers data and entries until its replacement pipe() is called. Destinationless replay remains supported.
04 / Lifecycle
Typed readers begin with ready === false. Stat metadata is copied before ready; directory entries follow. Successful completion emits end and then close. A successful close is terminal.
With follow: true, descendant links are followed. A link that revisits an ancestor remains observable, emits one ELOOP warning, and ends only that branch.
05 / Migration
"fstream": "npm:@stackline/fstream@1.0.0"
Existing require('fstream') calls stay unchanged. Commit the manifest and lockfile together.
import { Reader, Writer } from
'@stackline/fstream'
Real ESM and first-party TypeScript declarations are additive. The default ESM export is the CommonJS namespace object.
06 / Filesystem boundary
Writers mutate caller-selected paths and clobber incompatible destinations by default. Link following may leave the lexical source tree. Validate source and destination paths, enforce an allowed root, and apply size, depth, entry-count, and timeout limits around untrusted input.
Cycle detection prevents ancestor recursion; it is not a sandbox or archive extraction policy. The package has no browser build and makes no browser filesystem claim.
Read the complete safe-use boundary →07 / Reference files