diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/through2-filter | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) | |
download | wallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz |
add node_modules to address #4364
Diffstat (limited to 'node_modules/through2-filter')
-rw-r--r-- | node_modules/through2-filter/README.md | 79 | ||||
-rw-r--r-- | node_modules/through2-filter/index.js | 46 | ||||
-rw-r--r-- | node_modules/through2-filter/package.json | 106 |
3 files changed, 231 insertions, 0 deletions
diff --git a/node_modules/through2-filter/README.md b/node_modules/through2-filter/README.md new file mode 100644 index 000000000..9ad00b923 --- /dev/null +++ b/node_modules/through2-filter/README.md @@ -0,0 +1,79 @@ +through2-filter +=============== + +[![NPM](https://nodei.co/npm/through2-filter.png)](https://nodei.co/npm/through2-filter/) + +This is a super thin wrapper around [through2](http://npm.im/through2) that works like `Array.prototype.filter` but for streams. + +For when through2 is just too verbose :wink: + +Note you will **NOT** be able to alter the content of the chunks. This is intended for filtering only. If you want to modify the stream content, use either `through2` or `through2-map`. + +```js +var filter = require("through2-filter") + +var skip = filter(function (chunk) { + // skip buffers longer than 100 + return chunk.length < 100 +}) + +// vs. with through2: +var skip = through2(function (chunk, encoding, callback) { + // skip buffers longer than 100 + if (chunk.length < 100) this.push(chunk) + return callback() +}) + +// Then use your filter: +source.pipe(skip).pipe(sink) + +// Additionally accepts `wantStrings` argument to conver buffers into strings +var alphanum = new RegExp("^[A-Za-z0-1]+$") +var scrub = filter({wantStrings: true}, function (str) { + return alphanum.exec(str) +}) + +// Works like `Array.prototype.filter` meaning you can specify a function that +// takes up to two* arguments: fn(element, index) +var skip10 = filter(function (element, index) { + return index > 10 +}) +``` + +*Differences from `Array.prototype.filter`: + * No third `array` callback argument. That would require realizing the entire stream, which is generally counter-productive to stream operations. + * `Array.prototype.filter` doesn't modify the source Array, which is somewhat nonsensical when applied to streams. + +API +--- + +`require("through2-filter")([options], fn)` +--- + +Create a `through2-filter` instance that will call `fn(chunk)`. If `fn(chunk)` returns "true" the chunk will be passed downstream. Otherwise it will be dropped. + +`require("through2-filter").ctor([options], fn)` +--- + +Create a `through2-filter` Type that can be instantiated via `new Type()` or `Type()` to create reusable spies. + +`require("through2-filter").obj([options], fn)` +--- + +Create a `through2-filter` that defaults to `objectMode = true`. + +`require("through2-filter").objCtor([options], fn)` +--- + +Create a `through2-filter` Type that defaults to `objectMode = true`. + +Options +------- + + * wantStrings: Automatically call chunk.toString() for the super lazy. + * all other through2 options + +LICENSE +======= + +MIT diff --git a/node_modules/through2-filter/index.js b/node_modules/through2-filter/index.js new file mode 100644 index 000000000..4ca7f6365 --- /dev/null +++ b/node_modules/through2-filter/index.js @@ -0,0 +1,46 @@ +"use strict"; + +module.exports = make +module.exports.ctor = ctor +module.exports.objCtor = objCtor +module.exports.obj = obj + +var through2 = require("through2") +var xtend = require("xtend") + +function ctor(options, fn) { + if (typeof options == "function") { + fn = options + options = {} + } + + var Filter = through2.ctor(options, function (chunk, encoding, callback) { + if (this.options.wantStrings) chunk = chunk.toString() + if (fn.call(this, chunk, this._index++)) this.push(chunk) + return callback() + }) + Filter.prototype._index = 0 + return Filter +} + +function objCtor(options, fn) { + if (typeof options === "function") { + fn = options + options = {} + } + options = xtend({objectMode: true, highWaterMark: 16}, options) + return ctor(options, fn) +} + +function make(options, fn) { + return ctor(options, fn)() +} + +function obj(options, fn) { + if (typeof options === "function") { + fn = options + options = {} + } + options = xtend({objectMode: true, highWaterMark: 16}, options) + return make(options, fn) +} diff --git a/node_modules/through2-filter/package.json b/node_modules/through2-filter/package.json new file mode 100644 index 000000000..34b61f6b8 --- /dev/null +++ b/node_modules/through2-filter/package.json @@ -0,0 +1,106 @@ +{ + "_args": [ + [ + { + "raw": "through2-filter@^2.0.0", + "scope": null, + "escapedName": "through2-filter", + "name": "through2-filter", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "/home/dold/repos/taler/wallet-webex/node_modules/vinyl-fs" + ] + ], + "_from": "through2-filter@>=2.0.0 <3.0.0", + "_id": "through2-filter@2.0.0", + "_inCache": true, + "_location": "/through2-filter", + "_npmUser": { + "name": "bryce", + "email": "bryce@ravenwall.com" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": {}, + "_requested": { + "raw": "through2-filter@^2.0.0", + "scope": null, + "escapedName": "through2-filter", + "name": "through2-filter", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/vinyl-fs", + "/vinyl-fs/unique-stream" + ], + "_resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-2.0.0.tgz", + "_shasum": "60bc55a0dacb76085db1f9dae99ab43f83d622ec", + "_shrinkwrap": null, + "_spec": "through2-filter@^2.0.0", + "_where": "/home/dold/repos/taler/wallet-webex/node_modules/vinyl-fs", + "author": { + "name": "Bryce B. Baril" + }, + "bugs": { + "url": "https://github.com/brycebaril/through2-filter/issues" + }, + "dependencies": { + "through2": "~2.0.0", + "xtend": "~4.0.0" + }, + "description": "A through2 to create an Array.prototype.filter analog for streams.", + "devDependencies": { + "concat-stream": "^1.4.7", + "stream-spigot": "^3.0.5", + "tape": "^4.0.0" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "60bc55a0dacb76085db1f9dae99ab43f83d622ec", + "tarball": "https://registry.npmjs.org/through2-filter/-/through2-filter-2.0.0.tgz" + }, + "files": [ + "index.js" + ], + "gitHead": "fd290780ed8f8a9e9452c947e7f8cd9f8fefba72", + "homepage": "https://github.com/brycebaril/through2-filter", + "jshintConfig": { + "asi": true, + "globalstrict": true, + "validthis": true, + "eqnull": true, + "node": true, + "loopfunc": true, + "newcap": false, + "eqeqeq": false + }, + "keywords": [ + "streams", + "through", + "through2", + "filter" + ], + "license": "MIT", + "maintainers": [ + { + "name": "bryce", + "email": "bryce@ravenwall.com" + } + ], + "name": "through2-filter", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/brycebaril/through2-filter.git" + }, + "scripts": { + "test": "node test/" + }, + "version": "2.0.0" +} |