All Projects → npm → fs-minipass

npm / fs-minipass

Licence: ISC license
fs read and write streams based on minipass

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to fs-minipass

npm-registry-mock
mock the npm registry
Stars: ✭ 26 (+73.33%)
Mutual labels:  npm-cli
node-cli-boilerplate
🪓 Create node cli with this user friendly boilerplate
Stars: ✭ 17 (+13.33%)
Mutual labels:  npm-cli
npm-profile
Make changes to your npmjs.com profile via cli or library
Stars: ✭ 29 (+93.33%)
Mutual labels:  npm-cli
inflight
Add callbacks to requests in flight to avoid async duplication
Stars: ✭ 63 (+320%)
Mutual labels:  npm-cli
Cli
the package manager for JavaScript
Stars: ✭ 5,277 (+35080%)
Mutual labels:  npm-cli
Node Semver
The semver parser for node (the one npm uses)
Stars: ✭ 3,944 (+26193.33%)
Mutual labels:  npm-cli
run-script
Run a lifecycle script for a package (descendant of npm-lifecycle)
Stars: ✭ 29 (+93.33%)
Mutual labels:  npm-cli
lint
lint the npmcli way
Stars: ✭ 27 (+80%)
Mutual labels:  npm-cli
proggy
Progress bar updates at a distance
Stars: ✭ 12 (-20%)
Mutual labels:  npm-cli
pacote
npm fetcher
Stars: ✭ 179 (+1093.33%)
Mutual labels:  npm-cli
parse-conflict-json
Parse a JSON string that has git merge conflicts, resolving if possible
Stars: ✭ 24 (+60%)
Mutual labels:  npm-cli
libnpmpublish
programmatically publish and unpublish npm packages
Stars: ✭ 44 (+193.33%)
Mutual labels:  npm-cli
config
Configuration management for https://github.com/npm/cli
Stars: ✭ 22 (+46.67%)
Mutual labels:  npm-cli
cacache
npm's content-addressable cache
Stars: ✭ 181 (+1106.67%)
Mutual labels:  npm-cli
cmd-shim
The cmd-shim used in npm
Stars: ✭ 65 (+333.33%)
Mutual labels:  npm-cli
libnpmsearch
programmatic API for the shiny new npm search endpoint
Stars: ✭ 25 (+66.67%)
Mutual labels:  npm-cli
cross-post
Cross Post a blog to multiple websites
Stars: ✭ 66 (+340%)
Mutual labels:  npm-cli
git
a util for spawning git from npm CLI contexts
Stars: ✭ 48 (+220%)
Mutual labels:  npm-cli

fs-minipass

Filesystem streams based on minipass.

4 classes are exported:

  • ReadStream
  • ReadStreamSync
  • WriteStream
  • WriteStreamSync

When using ReadStreamSync, all of the data is made available immediately upon consuming the stream. Nothing is buffered in memory when the stream is constructed. If the stream is piped to a writer, then it will synchronously read() and emit data into the writer as fast as the writer can consume it. (That is, it will respect backpressure.) If you call stream.read() then it will read the entire file and return the contents.

When using WriteStreamSync, every write is flushed to the file synchronously. If your writes all come in a single tick, then it'll write it all out in a single tick. It's as synchronous as you are.

The async versions work much like their node builtin counterparts, with the exception of introducing significantly less Stream machinery overhead.

USAGE

It's just streams, you pipe them or read() them or write() to them.

const fsm = require('fs-minipass')
const readStream = new fsm.ReadStream('file.txt')
const writeStream = new fsm.WriteStream('output.txt')
writeStream.write('some file header or whatever\n')
readStream.pipe(writeStream)

ReadStream(path, options)

Path string is required, but somewhat irrelevant if an open file descriptor is passed in as an option.

Options:

  • fd Pass in a numeric file descriptor, if the file is already open.
  • readSize The size of reads to do, defaults to 16MB
  • size The size of the file, if known. Prevents zero-byte read() call at the end.
  • autoClose Set to false to prevent the file descriptor from being closed when the file is done being read.

WriteStream(path, options)

Path string is required, but somewhat irrelevant if an open file descriptor is passed in as an option.

Options:

  • fd Pass in a numeric file descriptor, if the file is already open.
  • mode The mode to create the file with. Defaults to 0o666.
  • start The position in the file to start reading. If not specified, then the file will start writing at position zero, and be truncated by default.
  • autoClose Set to false to prevent the file descriptor from being closed when the stream is ended.
  • flags Flags to use when opening the file. Irrelevant if fd is passed in, since file won't be opened in that case. Defaults to 'a' if a pos is specified, or 'w' otherwise.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].