113 lines
8.4 KiB
JSON
113 lines
8.4 KiB
JSON
|
{
|
||
|
"_args": [
|
||
|
[
|
||
|
{
|
||
|
"raw": "through2@^2.0.0",
|
||
|
"scope": null,
|
||
|
"escapedName": "through2",
|
||
|
"name": "through2",
|
||
|
"rawSpec": "^2.0.0",
|
||
|
"spec": ">=2.0.0 <3.0.0",
|
||
|
"type": "range"
|
||
|
},
|
||
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/fbjs-scripts"
|
||
|
]
|
||
|
],
|
||
|
"_from": "through2@>=2.0.0 <3.0.0",
|
||
|
"_id": "through2@2.0.3",
|
||
|
"_inCache": true,
|
||
|
"_location": "/through2",
|
||
|
"_nodeVersion": "7.2.0",
|
||
|
"_npmOperationalInternal": {
|
||
|
"host": "packages-18-east.internal.npmjs.com",
|
||
|
"tmp": "tmp/through2-2.0.3.tgz_1480373529377_0.264686161885038"
|
||
|
},
|
||
|
"_npmUser": {
|
||
|
"name": "rvagg",
|
||
|
"email": "rod@vagg.org"
|
||
|
},
|
||
|
"_npmVersion": "3.10.9",
|
||
|
"_phantomChildren": {
|
||
|
"core-util-is": "1.0.2",
|
||
|
"inherits": "2.0.3",
|
||
|
"process-nextick-args": "2.0.0",
|
||
|
"safe-buffer": "5.1.1",
|
||
|
"util-deprecate": "1.0.2"
|
||
|
},
|
||
|
"_requested": {
|
||
|
"raw": "through2@^2.0.0",
|
||
|
"scope": null,
|
||
|
"escapedName": "through2",
|
||
|
"name": "through2",
|
||
|
"rawSpec": "^2.0.0",
|
||
|
"spec": ">=2.0.0 <3.0.0",
|
||
|
"type": "range"
|
||
|
},
|
||
|
"_requiredBy": [
|
||
|
"/fbjs-scripts",
|
||
|
"/gulp-util"
|
||
|
],
|
||
|
"_resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
|
||
|
"_shasum": "0004569b37c7c74ba39c43f3ced78d1ad94140be",
|
||
|
"_shrinkwrap": null,
|
||
|
"_spec": "through2@^2.0.0",
|
||
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/fbjs-scripts",
|
||
|
"author": {
|
||
|
"name": "Rod Vagg",
|
||
|
"email": "r@va.gg",
|
||
|
"url": "https://github.com/rvagg"
|
||
|
},
|
||
|
"bugs": {
|
||
|
"url": "https://github.com/rvagg/through2/issues"
|
||
|
},
|
||
|
"dependencies": {
|
||
|
"readable-stream": "^2.1.5",
|
||
|
"xtend": "~4.0.1"
|
||
|
},
|
||
|
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
|
||
|
"devDependencies": {
|
||
|
"bl": "~1.1.2",
|
||
|
"faucet": "0.0.1",
|
||
|
"stream-spigot": "~3.0.5",
|
||
|
"tape": "~4.6.2"
|
||
|
},
|
||
|
"directories": {},
|
||
|
"dist": {
|
||
|
"shasum": "0004569b37c7c74ba39c43f3ced78d1ad94140be",
|
||
|
"tarball": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz"
|
||
|
},
|
||
|
"gitHead": "4383b10b2cb6a32ae215760715b317513abe609f",
|
||
|
"homepage": "https://github.com/rvagg/through2#readme",
|
||
|
"keywords": [
|
||
|
"stream",
|
||
|
"streams2",
|
||
|
"through",
|
||
|
"transform"
|
||
|
],
|
||
|
"license": "MIT",
|
||
|
"main": "through2.js",
|
||
|
"maintainers": [
|
||
|
{
|
||
|
"name": "rvagg",
|
||
|
"email": "rod@vagg.org"
|
||
|
},
|
||
|
{
|
||
|
"name": "bryce",
|
||
|
"email": "bryce@ravenwall.com"
|
||
|
}
|
||
|
],
|
||
|
"name": "through2",
|
||
|
"optionalDependencies": {},
|
||
|
"readme": "# through2\n\n[![NPM](https://nodei.co/npm/through2.png?downloads&downloadRank)](https://nodei.co/npm/through2/)\n\n**A tiny wrapper around Node streams.Transform (Streams2) to avoid explicit subclassing noise**\n\nInspired by [Dominic Tarr](https://github.com/dominictarr)'s [through](https://github.com/dominictarr/through) in that it's so much easier to make a stream out of a function than it is to set up the prototype chain properly: `through(function (chunk) { ... })`.\n\nNote: As 2.x.x this module starts using **Streams3** instead of Stream2. To continue using a Streams2 version use `npm install through2@0` to fetch the latest version of 0.x.x. More information about Streams2 vs Streams3 and recommendations see the article **[Why I don't use Node's core 'stream' module](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html)**.\n\n```js\nfs.createReadStream('ex.txt')\n .pipe(through2(function (chunk, enc, callback) {\n for (var i = 0; i < chunk.length; i++)\n if (chunk[i] == 97)\n chunk[i] = 122 // swap 'a' for 'z'\n\n this.push(chunk)\n\n callback()\n }))\n .pipe(fs.createWriteStream('out.txt'))\n .on('finish', function () {\n doSomethingSpecial()\n })\n```\n\nOr object streams:\n\n```js\nvar all = []\n\nfs.createReadStream('data.csv')\n .pipe(csv2())\n .pipe(through2.obj(function (chunk, enc, callback) {\n var data = {\n name : chunk[0]\n , address : chunk[3]\n , phone : chunk[10]\n }\n this.push(data)\n\n callback()\n }))\n .on('data', function (data) {\n all.push(data)\n })\n .on('end', function () {\n doSomethingSpecial(all)\n })\n```\n\nNote that `through2.obj(fn)` is a convenience wrapper around `through2({ objectMode: true }, fn)`.\n\n## API\n\n<b><code>through2([ options, ] [ transformFunction ] [, flushFunction ])</code></b>\n\nConsult the **[stream.Transform](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform)** documentation for the exact rules of the `transformFunction` (i.e. `this._transform`) and the optional `flushFunction` (i.e. `this._flush`).\n\n### options\n\nThe options argument is optional and is passed straight through to `stream.Transform`. So you can use `objectMode:true` if you are processing non-binary streams (or just use `through2.obj()`).\n\nThe `options` argument is first, unlike standard convention, because if I'm passing in an anonymous function then I'd prefer for the options argument to not get lost at the end of the call:\n\n```js\nfs.createReadStream('/tmp/important.dat')\n .pipe(through2({ objectMode: true, allowHalfOpen: false },\n function (chunk, enc, cb) {\n cb(null, 'wut?') // note we can use the second argument on the callback\n // to provide data as an alternative to this.push('wut?')\n }\n )\n .pipe(fs.createWriteStream('/tmp/wut.txt'))\n```\n\n### transformFunction\n\nThe `transformFunction` must have the following signature: `function (chunk, encoding, callback) {}`. A minimal implementation should call the `callback` function to indicate that the transformation is done, even if that transformation means discarding the chunk.\n\nTo queue a new chunk, call `this.push(chunk)`—this can be called as many times as required before the `callback()` if you have multiple pieces to send on.\n\nAlternatively, you may use `callback(err, chunk)` as shorthand for emitting a single chunk or an error.\n\nIf you **do not provide a `transformFunction`** then you will get a simple pass-through stream.\n\n### flushFunction\n\nThe optional `flushFunction` is provided as the last argument (2nd or 3rd, depending on whether you've supplied options) is called just prior to the stream ending. Can be used to finish up any processing that may be in progress.\n\n```js\nfs.createReadStream('/tmp/important.dat')\n .pipe(through2(\n function (chunk, enc, cb) { cb(null, chunk) }, // transform is a noop\n function (cb) { // flush function\n this.push('tacking on an extra buffer to the end');\n cb();\n }\n ))\n .pi
|
||
|
"readmeFilename": "README.md",
|
||
|
"repository": {
|
||
|
"type": "git",
|
||
|
"url": "git+https://github.com/rvagg/through2.git"
|
||
|
},
|
||
|
"scripts": {
|
||
|
"test": "node test/test.js | faucet",
|
||
|
"test-local": "brtapsauce-local test/basic-test.js"
|
||
|
},
|
||
|
"version": "2.0.3"
|
||
|
}
|