bigint-crypto-utils/node_modules/collect-all
juanelas c29b520108 JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
..
example JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
jsdoc2md JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
lib JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
test JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
.npmignore JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
.travis.yml JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
LICENSE JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
README.md JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
package.json JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00
yarn.lock JS Standard. Some fixes with the test. Better structure 2020-04-06 13:17:22 +02:00

README.md

view on npm npm module downloads Build Status Dependency Status js-standard-style

collect-all

Returns a stream which fires a callback and becomes readable once all input is received.

By default the callback is invoked with a Buffer instance containing all concatenated input. If you set the option { objectMode: true } the callback is invoked with an array containing all objects received.

collectAll([callback], [options]) ⇒ Duplex

Kind: Exported function

Param Type Description
[callback] function Called once with the collected input data (by default a Buffer instance, or array in objectMode.). The value returned by this callback function will be passed downstream.
[options] object Stream options object, passed to the constructor for the stream returned by collect-all. If the callback function supplied returns a non-string/buffer value, set options.objectMode to true.

Example
An example command-line client script - string input received at stdin is stamped with received then written to stdout.

var collectAll = require('collect-all')
process.stdin
  .pipe(collectAll(function (input) {
    input = 'received: ' + input
    return input
  }))
  .pipe(process.stdout)

An object-mode example:

var collectAll = require('collect-all')

function onAllCollected (collected) {
  console.log('Objects collected: ' + collected.length)
}

var stream = collectAll(onAllCollected, { objectMode: true })
stream.write({})
stream.write({})
stream.end({}) // outputs 'Objects collected: 3'

© 2015-17 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.