CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
README.md29 linesDownload Raw Back to minipass-sized
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 
basant307/AI_Governance_Project · CoolFace