source: trip-planner-front/node_modules/minipass-sized/README.md@ eed0bf8

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

initial commit

  • Property mode set to 100644
File size: 859 bytes
Line 
1# minipass-sized
2
3A Minipass stream that raises an error if you get a different number of
4bytes than expected.
5
6## USAGE
7
8Use just like any old [minipass](http://npm.im/minipass) stream, but
9provide a `size` option to the constructor.
10
11The `size` option must be a positive integer, smaller than
12`Number.MAX_SAFE_INTEGER`.
13
14```js
15const MinipassSized = require('minipass-sized')
16// figure out how much data you expect to get
17const expectedSize = +headers['content-length']
18const stream = new MinipassSized({ size: expectedSize })
19stream.on('error', er => {
20 // if it's the wrong size, then this will raise an error with
21 // { found: <number>, expect: <number>, code: 'EBADSIZE' }
22})
23response.pipe(stream)
24```
25
26Caveats: this does not work with `objectMode` streams, and will throw a
27`TypeError` from the constructor if the size argument is missing or
28invalid.
Note: See TracBrowser for help on using the repository browser.