mqtt stuff added
This commit is contained in:
79
node_modules/through2-filter/README.md
generated
vendored
Normal file
79
node_modules/through2-filter/README.md
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
through2-filter
|
||||
===============
|
||||
|
||||
[](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
|
46
node_modules/through2-filter/index.js
generated
vendored
Normal file
46
node_modules/through2-filter/index.js
generated
vendored
Normal file
@ -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)
|
||||
}
|
76
node_modules/through2-filter/package.json
generated
vendored
Normal file
76
node_modules/through2-filter/package.json
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"_from": "through2-filter@^2.0.0",
|
||||
"_id": "through2-filter@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-YLxVoNrLdghdsfna6Zq0P4PWIuw=",
|
||||
"_location": "/through2-filter",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "through2-filter@^2.0.0",
|
||||
"name": "through2-filter",
|
||||
"escapedName": "through2-filter",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/unique-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-2.0.0.tgz",
|
||||
"_shasum": "60bc55a0dacb76085db1f9dae99ab43f83d622ec",
|
||||
"_spec": "through2-filter@^2.0.0",
|
||||
"_where": "/home/wn/workspace-node/PiAlive/node_modules/unique-stream",
|
||||
"author": {
|
||||
"name": "Bryce B. Baril"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/brycebaril/through2-filter/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"through2": "~2.0.0",
|
||||
"xtend": "~4.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"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"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/brycebaril/through2-filter#readme",
|
||||
"jshintConfig": {
|
||||
"asi": true,
|
||||
"globalstrict": true,
|
||||
"validthis": true,
|
||||
"eqnull": true,
|
||||
"node": true,
|
||||
"loopfunc": true,
|
||||
"newcap": false,
|
||||
"eqeqeq": false
|
||||
},
|
||||
"keywords": [
|
||||
"streams",
|
||||
"through",
|
||||
"through2",
|
||||
"filter"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "through2-filter",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/brycebaril/through2-filter.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
Reference in New Issue
Block a user