This commit is contained in:
sentsin
2017-08-21 08:50:25 +08:00
parent 06c11ba9cd
commit 7feaa4eca0
1899 changed files with 181363 additions and 22513 deletions

3
node_modules/unique-stream/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
*.swp
.DS_Store
node_modules/

3
node_modules/unique-stream/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
language: node_js
node_js:
- "0.10"

20
node_modules/unique-stream/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright 2014 Eugene Ware
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

89
node_modules/unique-stream/README.md generated vendored Normal file
View File

@@ -0,0 +1,89 @@
# unique-stream
node.js through stream that emits a unique stream of objects based on criteria
[![build status](https://secure.travis-ci.org/eugeneware/unique-stream.png)](http://travis-ci.org/eugeneware/unique-stream)
## Installation
Install via npm:
```
$ npm install unique-stream
```
## Examples
### Dedupe a ReadStream based on JSON.stringify:
``` js
var unique = require('unique-stream')
, Stream = require('stream');
// return a stream of 3 identical objects
function makeStreamOfObjects() {
var s = new Stream;
s.readable = true;
var count = 3;
for (var i = 0; i < 3; i++) {
setImmediate(function () {
s.emit('data', { name: 'Bob', number: 123 });
--count && end();
});
}
function end() {
s.emit('end');
}
return s;
}
// Will only print out one object as the rest are dupes. (Uses JSON.stringify)
makeStreamOfObjects()
.pipe(unique())
.on('data', console.log);
```
### Dedupe a ReadStream based on an object property:
``` js
// Use name as the key field to dedupe on. Will only print one object
makeStreamOfObjects()
.pipe(unique('name'))
.on('data', console.log);
```
### Dedupe a ReadStream based on a custom function:
``` js
// Use a custom function to dedupe on. Use the 'number' field. Will only print one object.
makeStreamOfObjects()
.pipe(function (data) {
return data.number;
})
.on('data', console.log);
```
## Dedupe multiple streams
The reason I wrote this was to dedupe multiple object streams:
``` js
var aggregator = unique();
// Stream 1
makeStreamOfObjects()
.pipe(aggregator);
// Stream 2
makeStreamOfObjects()
.pipe(aggregator);
// Stream 3
makeStreamOfObjects()
.pipe(aggregator);
aggregator.on('data', console.log);
```

54
node_modules/unique-stream/index.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
var Stream = require('stream');
function prop(propName) {
return function (data) {
return data[propName];
};
}
module.exports = unique;
function unique(propName) {
var keyfn = JSON.stringify;
if (typeof propName === 'string') {
keyfn = prop(propName);
} else if (typeof propName === 'function') {
keyfn = propName;
}
var seen = {};
var s = new Stream();
s.readable = true;
s.writable = true;
var pipes = 0;
s.write = function (data) {
var key = keyfn(data);
if (seen[key] === undefined) {
seen[key] = true;
s.emit('data', data);
}
};
var ended = 0;
s.end = function (data) {
if (arguments.length) s.write(data);
ended++;
if (ended === pipes || pipes === 0) {
s.writable = false;
s.emit('end');
}
};
s.destroy = function (data) {
s.writable = false;
};
s.on('pipe', function () {
pipes++;
});
s.on('unpipe', function () {
pipes--;
});
return s;
}

89
node_modules/unique-stream/package.json generated vendored Normal file
View File

@@ -0,0 +1,89 @@
{
"_args": [
[
{
"raw": "unique-stream@^1.0.0",
"scope": null,
"escapedName": "unique-stream",
"name": "unique-stream",
"rawSpec": "^1.0.0",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"D:\\web\\layui\\res\\layui\\node_modules\\glob-stream"
]
],
"_from": "unique-stream@>=1.0.0 <2.0.0",
"_id": "unique-stream@1.0.0",
"_inCache": true,
"_location": "/unique-stream",
"_npmUser": {
"name": "eugeneware",
"email": "eugene@noblesamurai.com"
},
"_npmVersion": "1.4.3",
"_phantomChildren": {},
"_requested": {
"raw": "unique-stream@^1.0.0",
"scope": null,
"escapedName": "unique-stream",
"name": "unique-stream",
"rawSpec": "^1.0.0",
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/glob-stream"
],
"_resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz",
"_shasum": "d59a4a75427447d9aa6c91e70263f8d26a4b104b",
"_shrinkwrap": null,
"_spec": "unique-stream@^1.0.0",
"_where": "D:\\web\\layui\\res\\layui\\node_modules\\glob-stream",
"author": {
"name": "Eugene Ware",
"email": "eugene@noblesamurai.com"
},
"bugs": {
"url": "https://github.com/eugeneware/unique-stream/issues"
},
"dependencies": {},
"description": "node.js through stream that emits a unique stream of objects based on criteria",
"devDependencies": {
"after": "~0.8.1",
"chai": "~1.7.2",
"mocha": "^1.18.2"
},
"directories": {},
"dist": {
"shasum": "d59a4a75427447d9aa6c91e70263f8d26a4b104b",
"tarball": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz"
},
"homepage": "https://github.com/eugeneware/unique-stream",
"keywords": [
"unique",
"stream",
"unique-stream",
"streaming",
"streams"
],
"license": "BSD",
"main": "index.js",
"maintainers": [
{
"name": "eugeneware",
"email": "eugene@noblesamurai.com"
}
],
"name": "unique-stream",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/eugeneware/unique-stream.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.0.0"
}

109
node_modules/unique-stream/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
var expect = require('chai').expect
, unique = require('..')
, Stream = require('stream')
, after = require('after')
, setImmediate = global.setImmediate || process.nextTick;
describe('unique stream', function() {
function makeStream(type) {
var s = new Stream();
s.readable = true;
var n = 10;
var next = after(n, function () {
setImmediate(function () {
s.emit('end');
});
});
for (var i = 0; i < n; i++) {
var o = {
type: type,
name: 'name ' + i,
number: i * 10
};
(function (o) {
setImmediate(function () {
s.emit('data', o);
next();
});
})(o);
}
return s;
}
it('should be able to uniqueify objects based on JSON data', function(done) {
var aggregator = unique();
makeStream('a')
.pipe(aggregator);
makeStream('a')
.pipe(aggregator);
var n = 0;
aggregator
.on('data', function () {
n++;
})
.on('end', function () {
expect(n).to.equal(10);
done();
});
});
it('should be able to uniqueify objects based on a property', function(done) {
var aggregator = unique('number');
makeStream('a')
.pipe(aggregator);
makeStream('b')
.pipe(aggregator);
var n = 0;
aggregator
.on('data', function () {
n++;
})
.on('end', function () {
expect(n).to.equal(10);
done();
});
});
it('should be able to uniqueify objects based on a function', function(done) {
var aggregator = unique(function (data) {
return data.name;
});
makeStream('a')
.pipe(aggregator);
makeStream('b')
.pipe(aggregator);
var n = 0;
aggregator
.on('data', function () {
n++;
})
.on('end', function () {
expect(n).to.equal(10);
done();
});
});
it('should be able to handle uniqueness when not piped', function(done) {
var stream = unique();
var count = 0;
stream.on('data', function (data) {
expect(data).to.equal('hello');
count++;
});
stream.on('end', function() {
expect(count).to.equal(1);
done();
});
stream.write('hello');
stream.write('hello');
stream.end();
});
});