2.1.2 • Published 2 years ago

pond v2.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

pond CI

commits

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.

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago

0.2.0

7 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

10 years ago