{"_id":"barrage","_rev":"273597","name":"barrage","description":"Extensions to streams (as a mixin)","dist-tags":{"latest":"2.0.4"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"time":{"modified":"2021-06-03T17:51:10.000Z","created":"2013-07-02T00:03:33.510Z","2.0.4":"2017-10-17T16:43:12.445Z","2.0.3":"2017-10-17T11:45:27.322Z","2.0.2":"2017-10-17T11:42:34.902Z","2.0.1":"2017-07-28T17:17:40.261Z","2.0.0":"2017-07-28T17:16:28.761Z","1.1.0":"2014-09-11T14:44:48.733Z","1.0.0":"2013-08-25T14:10:48.339Z","0.0.4":"2013-07-07T16:10:42.140Z","0.0.3":"2013-07-06T23:19:02.214Z","0.0.2":"2013-07-06T22:52:30.656Z","0.0.1":"2013-07-02T00:03:33.510Z"},"users":{},"author":{"name":"ForbesLindesay"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/barrage.git"},"versions":{"2.0.4":{"name":"barrage","version":"2.0.4","main":"lib/index.js","types":"lib/index.d.ts","files":["lib/"],"description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"@types/is-promise":"0.0.3","@types/node":"^8.0.17","@types/once":"^1.3.28","is-promise":"^2.1.0","once":"^1.4.0"},"devDependencies":{"@types/mocha":"^2.2.41","mocha":"*","promise":"^6.0.0","typescript":"^2.4.2"},"scripts":{"prepublish":"npm run build","build":"tsc","pretest":"npm run build","test":"mocha -R spec lib/test.js"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"3d17f812b6c77fc2b5201b1b0ebdddf483863310","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"homepage":"https://github.com/ForbesLindesay/barrage#readme","_id":"barrage@2.0.4","_npmVersion":"5.5.1","_nodeVersion":"8.6.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"ea27ee50606ebaaa261fb87563196aa7209bb3a4","size":7293,"noattachment":false,"key":"/barrage/-/barrage-2.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-2.0.4.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barrage-2.0.4.tgz_1508258591523_0.02250538533553481"},"directories":{},"publish_time":1508258592445,"_hasShrinkwrap":false,"_cnpm_publish_time":1508258592445},"2.0.3":{"name":"barrage","version":"2.0.3","main":"lib/index.js","types":"lib/index.d.ts","files":["lib/index.d.ts","lib/index.js"],"description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"@types/is-promise":"0.0.3","@types/node":"^8.0.17","@types/once":"^1.3.28","is-promise":"^2.1.0","once":"^1.4.0"},"devDependencies":{"@types/mocha":"^2.2.41","mocha":"*","promise":"^6.0.0","typescript":"^2.4.2"},"scripts":{"prepublish":"npm run build","build":"tsc","pretest":"npm run build","test":"mocha -R spec lib/test.js"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"8a9f565c576f47448bcb08817b540b3bdb4459fe","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"homepage":"https://github.com/ForbesLindesay/barrage#readme","_id":"barrage@2.0.3","_npmVersion":"5.5.1","_nodeVersion":"8.6.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"98fa39ff933f42a83bc1ebf48b147ddb9921e443","size":5857,"noattachment":false,"key":"/barrage/-/barrage-2.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-2.0.3.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barrage-2.0.3.tgz_1508240726423_0.07584567880257964"},"directories":{},"publish_time":1508240727322,"_hasShrinkwrap":false,"_cnpm_publish_time":1508240727322},"2.0.2":{"name":"barrage","version":"2.0.2","main":"lib/index.js","types":"lib/index.d.ts","files":["lib/index.d.ts","lib/index.js"],"description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"@types/is-promise":"0.0.3","@types/node":"^8.0.17","@types/once":"^1.3.28","is-promise":"^2.1.0","once":"^1.4.0"},"devDependencies":{"@types/mocha":"^2.2.41","mocha":"*","promise":"^6.0.0","typescript":"^2.4.2"},"scripts":{"build":"tsc","pretest":"npm run build","test":"mocha -R spec lib/test.js"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"02e0f97f3ba2519baf9dda96fa8fe156643d86b1","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"homepage":"https://github.com/ForbesLindesay/barrage#readme","_id":"barrage@2.0.2","_npmVersion":"5.5.1","_nodeVersion":"8.6.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"9849d51c5d9918c109653c07a0ddf380fdcbf359","size":5840,"noattachment":false,"key":"/barrage/-/barrage-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-2.0.2.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barrage-2.0.2.tgz_1508240553874_0.16573975002393126"},"directories":{},"publish_time":1508240554902,"_cnpm_publish_time":1508240554902,"_hasShrinkwrap":false},"2.0.1":{"name":"barrage","version":"2.0.1","main":"lib/index.js","types":"lib/index.d.ts","files":["lib/index.d.ts","lib/index.js"],"description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"@types/is-promise":"0.0.3","@types/node":"^8.0.17","@types/once":"^1.3.28","is-promise":"^2.1.0","once":"^1.4.0"},"devDependencies":{"@types/mocha":"^2.2.41","mocha":"*","promise":"^6.0.0","typescript":"^2.4.2"},"scripts":{"build":"tsc","pretest":"npm run build","test":"mocha -R spec lib/test.js"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"255581f3a8fca943d6997bffd1cd1792495ee121","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"homepage":"https://github.com/ForbesLindesay/barrage#readme","_id":"barrage@2.0.1","_shasum":"5555ab6458cca5a79ff91361c211981d8b055c03","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"5555ab6458cca5a79ff91361c211981d8b055c03","size":5843,"noattachment":false,"key":"/barrage/-/barrage-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-2.0.1.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barrage-2.0.1.tgz_1501262259289_0.411821412621066"},"directories":{},"publish_time":1501262260261,"_hasShrinkwrap":false,"_cnpm_publish_time":1501262260261},"2.0.0":{"name":"barrage","version":"2.0.0","main":"lib/index.js","types":"lib/index.d.ts","files":["lib/index.d.ts","lib/index.js"],"description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"@types/is-promise":"0.0.3","@types/node":"^8.0.17","@types/once":"^1.3.28","is-promise":"^2.1.0","once":"^1.4.0"},"devDependencies":{"@types/mocha":"^2.2.41","mocha":"*","promise":"^6.0.0","typescript":"^2.4.2"},"scripts":{"build":"tsc","pretest":"npm run build","test":"mocha -R spec lib/test.js"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"33c5c46dca49bcf4decce5f964aa6e7f88ee94c1","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"homepage":"https://github.com/ForbesLindesay/barrage#readme","_id":"barrage@2.0.0","_shasum":"8c5b4dd73fca3849a77c81e0ca559ed477fec31b","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"8c5b4dd73fca3849a77c81e0ca559ed477fec31b","size":5628,"noattachment":false,"key":"/barrage/-/barrage-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-2.0.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barrage-2.0.0.tgz_1501262187853_0.7784702987410128"},"directories":{},"publish_time":1501262188761,"_hasShrinkwrap":false,"_cnpm_publish_time":1501262188761},"1.1.0":{"name":"barrage","version":"1.1.0","description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"promise":"^6.0.0"},"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"c6543cc24e1bc63dc0a5a3a9f4c7f046f2bfb8ff","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"homepage":"https://github.com/ForbesLindesay/barrage","_id":"barrage@1.1.0","_shasum":"6f5384765c463f7718012f160dccf033fc6fc394","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"6f5384765c463f7718012f160dccf033fc6fc394","size":6230,"noattachment":false,"key":"/barrage/-/barrage-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-1.1.0.tgz"},"directories":{},"publish_time":1410446688733,"_cnpm_publish_time":1410446688733,"_hasShrinkwrap":false},"1.0.0":{"name":"barrage","version":"1.0.0","description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"promise":"~3.2.0"},"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"_id":"barrage@1.0.0","dist":{"shasum":"f3fdf822b07850d3aa95ba46e83db133c9fbcfa4","size":5823,"noattachment":false,"key":"/barrage/-/barrage-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-1.0.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"publish_time":1377439848339,"_cnpm_publish_time":1377439848339,"_hasShrinkwrap":false},"0.0.4":{"name":"barrage","version":"0.0.4","description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"promise":"~3.2.0","readable-stream":"~1.0.2"},"devDependencies":{"mocha":"*"},"optionalDependencies":{"readable-stream":"~1.0.2"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","readmeFilename":"README.md","_id":"barrage@0.0.4","dist":{"shasum":"b6794c170af481cd904b5bc4c1d6ec329358023a","size":4143,"noattachment":false,"key":"/barrage/-/barrage-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-0.0.4.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"publish_time":1373213442140,"_cnpm_publish_time":1373213442140,"_hasShrinkwrap":false},"0.0.3":{"name":"barrage","version":"0.0.3","description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"promise":"~3.2.0","readable-stream":"~1.0.2"},"devDependencies":{"mocha":"*"},"optionalDependencies":{"readable-stream":"~1.0.2"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","readmeFilename":"README.md","_id":"barrage@0.0.3","dist":{"shasum":"c027abb2b9a636cf75a0c13cc169bc597ed4a8ac","size":4140,"noattachment":false,"key":"/barrage/-/barrage-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-0.0.3.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"publish_time":1373152742214,"_cnpm_publish_time":1373152742214,"_hasShrinkwrap":false},"0.0.2":{"name":"barrage","version":"0.0.2","description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"promise":"~3.2.0","readable-stream":"~1.0.2"},"devDependencies":{"mocha":"*"},"optionalDependencies":{"readable-stream":"~1.0.2"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","readmeFilename":"README.md","_id":"barrage@0.0.2","dist":{"shasum":"1f0b4155d0be2ebd353ff677548d5f345453c63d","size":4132,"noattachment":false,"key":"/barrage/-/barrage-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-0.0.2.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"publish_time":1373151150656,"_cnpm_publish_time":1373151150656,"_hasShrinkwrap":false},"0.0.1":{"name":"barrage","version":"0.0.1","description":"Extensions to streams (as a mixin)","keywords":[],"dependencies":{"promise":"~3.1.0","readable-stream":"~1.0.2"},"devDependencies":{"mocha":"*"},"optionalDependencies":{"readable-stream":"~1.0.2"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/barrage.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","readmeFilename":"README.md","_id":"barrage@0.0.1","dist":{"shasum":"8f15b8713c00ec64ddd34b62b65e8e0dc55d7db6","size":4135,"noattachment":false,"key":"/barrage/-/barrage-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/barrage/download/barrage-0.0.1.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"publish_time":1372723413510,"_cnpm_publish_time":1372723413510,"_hasShrinkwrap":false}},"readme":"# barrage\n\nNodeJS Streams with strong types via typescript, and helper methods to make dealing with object streams pleasent.\n\n[![Build Status](https://img.shields.io/travis/ForbesLindesay/barrage/master.svg)](https://travis-ci.org/ForbesLindesay/barrage)\n[![Dependency Status](https://img.shields.io/david/ForbesLindesay/barrage.svg)](https://david-dm.org/ForbesLindesay/barrage)\n[![NPM version](https://img.shields.io/npm/v/barrage.svg)](https://www.npmjs.com/package/barrage)\n\n## Installation\n\n    npm install barrage\n\n## API\n\n```js\nimport {Readable, Writable, Transform} from 'barrage';\n```\n\nThese are native streams, but with a few extensions:\n\n### readable.syphon(stream, [options])\n\nThis is exactly like the built in `source.pipe(destination, [options])` except that it also forwards any errors emitted by `source` to the `destination`.  When your streams represent transformations, that is usually much more useful than the built in `.pipe`.\n\n### readable.buffer([encoding]): Promise\n\nWhen the barrage is a readable stream, this method buffers the results and handles errors, resulting in a node.js style `callback` API.  If there is no `encoding` parameter, the callback is called with an `Array` for the result.  If encoding is `'buffer'` then the callback is called with a single `Buffer` for the result.  If any other string is passed as `encoding`, the `encoding` parameter is passed on to `buffer.toString(encoding)` and the result is therefore a `String`\n\n### writable.wait(): Promise\n\nThis works like `barrage.buffer`, except that it does not buffer the result.  It will wait for an `end` or `finish` event and then call the callback.  If an error event is fired, the callback is called with that error. The callback is only ever called once.\n\nIf the callback parameter is absent, a [Promises/A+](http://promises-aplus.github.io/promises-spec/) promise is returned instead.\n\n### readable.map(transform, options) / new barrage.Map(transform, options)\n\nThis passes each chunk to `transform` and then pushes the result of calling `transform` to the output stream.  You can either call this as a method on an existing barrage stream, or create a `Transform` stream by calling `new barrage.Map`\n\ne.g.\n\n```js\nfunction square() {\n  return new barrage.Map(function (x) {\n    return x * x\n  })\n}\n```\n\nIt supports both being asynchronous, and parallel:\n\n```js\nfunction load() {\n  return new barrage.Map(function (stat, callback) {\n    fs.readFile(stat.fullPath, callback)\n  }, {parallel: 10})\n}\n```\n\nWhen operating in parallel, the ordering of the resulting stream is always preserved.\n\nIt also supports promises\n\n```js\nfunction load() {\n  return new barrage.Map(function (stat) {\n    return Promise.denodeify(fs.readFile)(stat.fullPath)\n  }, {parallel: 10})\n}\n```\n\n### readable.filter(transform, options) / new barrage.Filter(transform, options)\n\nThis is exactly like `barrage.map` / `new barrage.Map` except that `transform` should return `true` or `false` and the chunks will be filtered based on that value.\n\n### readable.flatMap(transform, options) / new barrage.FlatMap(transform, options)\n\nTake a function that maps an object onto an array or stream (or if `for...of` is supported by your version of node, any iterable), then return a stream for those individual items.  e.g.\n\n```js\nvar source = new b.Readable({objectMode: true});\nsource._read = function () {\n  this.push(1)\n  this.push(2)\n  this.push(3)\n  this.push(null)\n};\nsource.flatMap(function (x) {\n  var source = new b.Readable({objectMode: true})\n  source._read = function () {\n    this.push(x * 1) // 1, 2, 3\n    this.push(x * 2) // 2, 4, 6\n    this.push(null)\n  }\n  return source\n}).buffer().done(function (data) {\n    assert.deepEqual(data, [1, 2, 2, 4, 3, 6])\n    done()\n  })\n  ```\n\n### readable.bufferTransform(transform, encoding) / new barrage.BufferTransform(transform, encoding)\n\nTakes a function that transforms a string and returns a `Transform` stream.  e.g.\n\n```js\nfunction coffeify(filename) {\n  return new barrage.BufferTransform(function (src) {\n    return compileCoffee(filename, src)\n  }, 'utf8')\n}\nfunction compileCoffee(filename, src) {\n  //do compilation and return a string\n}\nfs.createReadStream('src.coffee').pipe(coffeify('src.coffee')).pipe(fs.createWriteStream('src.js'))\n```\n\nThis is mostly useful for processing files over stdio and creating browserify transforms.\n\nThe `transform` function may optionally take a callback argument (if it returns `undefined`) or return a promise (instead of a string).\n\n## License\n\n  MIT\n","_attachments":{},"homepage":"https://github.com/ForbesLindesay/barrage#readme","bugs":{"url":"https://github.com/ForbesLindesay/barrage/issues"},"license":"MIT"}