README
pond
Collect a stream into a buffer.
Please aware that, because buffers came out from a stream are buffered into the memory, DO NOT try to collect a stream that is large or with unknowable length!
import { createReadStream } from 'fs';
import { createHash } from 'crypto';
import pond from 'pond';
const digest = await createReadStream('/path/to/some/file')
.pipe(createHash('sha256'))
.pipe(pond())
.spoon();
console.log(digest.toString('hex'));
Requirements
Node >= 10, tested on latest Node and latest LTS Node.
Installation
npm install --save pond
Usage
Promise, await
const buffer = await stream.pipe(pond()).spoon();
const buffer = await pond(stream).spoon();
Stream API (piping):
fs.createReadStream('somefile')
.pipe(pond())
.on('error', (err) => {
// ...
})
.spoon((buffer) => {
// ...
});
Or, old-fashioned callback:
pond(fs.createReadStream('anotherfile'), function (err, buffer) {
// ...
});
Test
npm test
License
This project is released under the terms of MIT License.