basant307/AI_Governance_Project
048
1# minipass-sized2 3A Minipass stream that raises an error if you get a different number of4bytes than expected.5 6## USAGE7 8Use just like any old [minipass](http://npm.im/minipass) stream, but9provide a `size` option to the constructor.10 11The `size` option must be a positive integer, smaller than12`Number.MAX_SAFE_INTEGER`.13 14```js15const MinipassSized = require('minipass-sized')16// figure out how much data you expect to get17const 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 with21 // { found: <number>, expect: <number>, code: 'EBADSIZE' }22})23response.pipe(stream)24```25 26Caveats: this does not work with `objectMode` streams, and will throw a27`TypeError` from the constructor if the size argument is missing or28invalid.29 