{"_id":"through2-sink","_rev":"3-4fc6cab94b725f780d125c8a58c215aa","name":"through2-sink","description":"A through2 wrapper that just receives chunks and nothing else.","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"through2-sink","version":"1.0.0","description":"A through2 wrapper that just receives chunks and nothing else.","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"git@github.com:joepie91/through2-sink.git"},"keywords":["streams","through","through2","passthrough","spy"],"author":{"name":"Sven Slootweg"},"license":"MIT","bugs":{"url":"https://github.com/joepie91/through2-sink/issues"},"dependencies":{"through2":"~0.5.1","xtend":"~3.0.0"},"gitHead":"f399b939638d11e61018322ce2c29d5c229bb6a7","homepage":"https://github.com/joepie91/through2-sink","_id":"through2-sink@1.0.0","scripts":{},"_shasum":"5f106bba1d7330dad3cba5c0ab1863923256c399","_from":".","_npmVersion":"2.1.3","_nodeVersion":"0.12.0","_npmUser":{"name":"joepie91","email":"admin@cryto.net"},"maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"dist":{"shasum":"5f106bba1d7330dad3cba5c0ab1863923256c399","tarball":"https://registry.npmjs.org/through2-sink/-/through2-sink-1.0.0.tgz","integrity":"sha512-9HvIHIEXZ5YgstQx3vsu4U/QQ/n7X5RHlXf8MsfSEnEzeUFbX9BHBWmlwdQ1b6CzDlUEDwjFnkSIxpJZ6qP+0Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFvZ+wufaMYcCZfoxR+XeP6k5ucQOvM4AI3SmXdimLwhAiAIIyjGB1T4bZq5JJ4Ho4uSZzVoJdobOL6ajOT2oVhvjA=="}]}}},"readme":"through2-spy\n============\n\n[![NPM](https://nodei.co/npm/through2-sink.png)](https://nodei.co/npm/through2-sink/)\n\nThis is a super thin wrapper around [through2](http://npm.im/through2) for creating simple 'terminus' streams, that do nothing but look at the chunk received.\n\nThis module is heavily based on Bryce B. Baril's [through2-spy](https://www.npmjs.com/package/through2-spy), with the `.push` call removed. Why? So that you can have the same functionality at the *end* of a pipeline, without buffering everything up. It was originally written to help implement progress events in [bhttp](https://www.npmjs.com/package/bhttp). If you were to just use `through2-spy` for this, then [this](https://github.com/joyent/node/issues/14477) would happen.\n\nPass a function to run as each chunk goes through your stream pipeline. Return an Error to abort the pipeline.\n\n```js\n\nvar sink = require(\"through2-sink\")\n\nvar count = 0\nvar countChunks = sink(function (chunk) {\n  count++\n})\n\n// vs. with through2:\nvar countChunks = through2(function (chunk, encoding, callback) {\n  count++\n  return callback()\n})\n\n// Then use your sink:\nsource.pipe(countChunks)\n\n// Additionally accepts `wantStrings` argument to conver buffers into strings\nvar nsaregex = /(open source)|(foss)|(node\\.js)|(mods are asleep)|(post sinks)/i\nvar prizm = sink({wantStrings: true}, function (str) {\n  var buggyWiretap = str.match(nsaregex)\n  if (buggyWiretap) {\n    this.emit(\"OMGTERRIST\", buggyWiretap[0], str)\n  }\n})\n\nprizm.on(\"OMGTERRIST\", sendDrone(/* ... */))\n\ninternet.pipe(prizm) // can't have the terrists getting their packets!\n\n// Return an Error to abort the pipeline\nvar Meter = sink.ctor({maxBytes: 1024, bytes: 0}, function (chunk) {\n  this.options.bytes += chunk.length\n  if (this.options.bytes >= this.options.maxBytes) return new Error(\"Over 1024 byte limit!\")\n})\n\nvar meter = new Meter()\n\n```\n\nAPI\n---\n\n`require(\"through2-sink\")([options], fn)`\n---\n\nCreate a `through2-sink` instance that will call `fn(chunk)` and then silently pass through data downstream.\n\n`require(\"through2-sink\").ctor([options], fn)`\n---\n\nCreate a `through2-sink` Type that can be instantiated via `new Type()` or `Type()` to create reusable sinks.\n\n`require(\"through2-sink\").obj([options], fn)`\n---\n\nCreate a `through2-sink` that defaults to `objectMode = true`.\n\n`require(\"through2-sink\").objCtor([options], fn)`\n---\n\nCreate a `through2-sink` Type that defaults to `objectMode = true`.\n\nOptions\n-------\n\n  * wantStrings: Automatically call chunk.toString() for the super lazy.\n  * all other through2 options\n\nLICENSE\n=======\n\nMIT\n","maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"time":{"modified":"2022-06-27T06:25:00.755Z","created":"2015-04-06T09:13:39.142Z","1.0.0":"2015-04-06T09:13:39.142Z"},"homepage":"https://github.com/joepie91/through2-sink","keywords":["streams","through","through2","passthrough","spy"],"repository":{"type":"git","url":"git@github.com:joepie91/through2-sink.git"},"author":{"name":"Sven Slootweg"},"bugs":{"url":"https://github.com/joepie91/through2-sink/issues"},"license":"MIT","readmeFilename":"README.md"}