source: trip-planner-front/node_modules/fs-minipass/README.md@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[6a3a178]1# fs-minipass
2
3Filesystem streams based on [minipass](http://npm.im/minipass).
4
54 classes are exported:
6
7- ReadStream
8- ReadStreamSync
9- WriteStream
10- WriteStreamSync
11
12When using `ReadStreamSync`, all of the data is made available
13immediately upon consuming the stream. Nothing is buffered in memory
14when the stream is constructed. If the stream is piped to a writer,
15then it will synchronously `read()` and emit data into the writer as
16fast as the writer can consume it. (That is, it will respect
17backpressure.) If you call `stream.read()` then it will read the
18entire file and return the contents.
19
20When using `WriteStreamSync`, every write is flushed to the file
21synchronously. If your writes all come in a single tick, then it'll
22write it all out in a single tick. It's as synchronous as you are.
23
24The async versions work much like their node builtin counterparts,
25with the exception of introducing significantly less Stream machinery
26overhead.
27
28## USAGE
29
30It's just streams, you pipe them or read() them or write() to them.
31
32```js
33const fsm = require('fs-minipass')
34const readStream = new fsm.ReadStream('file.txt')
35const writeStream = new fsm.WriteStream('output.txt')
36writeStream.write('some file header or whatever\n')
37readStream.pipe(writeStream)
38```
39
40## ReadStream(path, options)
41
42Path string is required, but somewhat irrelevant if an open file
43descriptor is passed in as an option.
44
45Options:
46
47- `fd` Pass in a numeric file descriptor, if the file is already open.
48- `readSize` The size of reads to do, defaults to 16MB
49- `size` The size of the file, if known. Prevents zero-byte read()
50 call at the end.
51- `autoClose` Set to `false` to prevent the file descriptor from being
52 closed when the file is done being read.
53
54## WriteStream(path, options)
55
56Path string is required, but somewhat irrelevant if an open file
57descriptor is passed in as an option.
58
59Options:
60
61- `fd` Pass in a numeric file descriptor, if the file is already open.
62- `mode` The mode to create the file with. Defaults to `0o666`.
63- `start` The position in the file to start reading. If not
64 specified, then the file will start writing at position zero, and be
65 truncated by default.
66- `autoClose` Set to `false` to prevent the file descriptor from being
67 closed when the stream is ended.
68- `flags` Flags to use when opening the file. Irrelevant if `fd` is
69 passed in, since file won't be opened in that case. Defaults to
70 `'a'` if a `pos` is specified, or `'w'` otherwise.
Note: See TracBrowser for help on using the repository browser.