# fs-minipass

> fs read and write streams based on minipass

Latest version **3.0.3** (published 2023-08-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install fs-minipass
pnpm add fs-minipass
yarn add fs-minipass
bun add fs-minipass
```

## Health

**Score 38/100 (D)** — status: abandoned.

Positive: has types package; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2023-08-14 |
| First published | 2017-09-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/fs-minipass) |
| Module format | CommonJS |
| Node | ^14.17.0 \|\| ^16.13.0 \|\| >=18.0.0 |
| Dependencies | 1 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 20 |
| Author | GitHub Inc. |
| Maintainers | npm-cli-ops, saquibkhan, fritzy, gar, lukekarrys |

## Links

- npm: https://www.npmjs.com/package/fs-minipass
- Repository: https://github.com/npm/fs-minipass
- Homepage: https://github.com/npm/fs-minipass#readme
- Issues: https://github.com/npm/fs-minipass/issues
- npm.io page: https://npm.io/package/fs-minipass

## Dependencies (1)

- [minipass](https://npm.io/package/minipass.md) ^7.0.3

## Recent versions

- 3.0.3 (latest) — 2023-08-14
- 3.0.2 — 2023-04-26
- 3.0.1 — 2023-01-30
- 3.0.0 — 2022-12-13
- 2.1.0 — 2020-01-21
- 2.0.1 — 2020-01-20
- 2.0.0 — 2019-09-30
- 1.2.7 — 2019-09-16
- 1.2.6 — 2019-05-15
- 1.2.5 — 2018-01-04
- 1.2.4 — 2018-01-04
- 1.2.3 — 2017-11-14
- 1.2.2 — 2017-11-14
- 1.2.1 — 2017-09-21
- 1.2.0 — 2017-09-17
- … 4 more at https://npm.io/package/fs-minipass/versions

## README

# fs-minipass

Filesystem streams based on [minipass](http://npm.im/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.

```js
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.

---
_Source: https://npm.io/package/fs-minipass · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
