JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 325
  • Score
    100M100P100Q35882F
  • License MIT

Collect a stream into a buffer.

Package Exports

  • pond

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pond) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pond CI

[![][issues-img]][issues-url] [![commits][commits-img]][commits-url]

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.

[issues-img]: https://img.shields.io/github/issues/xingrz/pond.svg?style=flat-square [issues-url]: https://github.com/xingrz/pond/issues [commits-img]: https://img.shields.io/github/last-commit/xingrz/pond?style=flat-square [commits-url]: https://github.com/xingrz/pond/commits/master