ubdate
This commit is contained in:
21
node_modules/through2-concurrent/LICENSE.txt
generated
vendored
Normal file
21
node_modules/through2-concurrent/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Thomas Parslow
|
||||
|
||||
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.
|
||||
71
node_modules/through2-concurrent/README.md
generated
vendored
Normal file
71
node_modules/through2-concurrent/README.md
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
through2-concurrent
|
||||
===================
|
||||
|
||||
[](https://nodei.co/npm/through2-concurrent/)
|
||||
|
||||
A simple way to create a Node.JS Transform stream which processes in
|
||||
parallel. You can limit the concurrency (default is 16) and order is
|
||||
*not* preserved (so chunks/objects can end up in a different order to
|
||||
the order they started in if the transform functions take different
|
||||
amounts of time).
|
||||
|
||||
Built using [through2](https://github.com/rvagg/through2) and has the
|
||||
same API with the addition of a `maxConcurrency` option.
|
||||
|
||||
Non-`objectMode` streams are supported for completeness but I'm not
|
||||
sure they'd be useful for anything.
|
||||
|
||||
Written by Thomas Parslow
|
||||
([almostobsolete.net](http://almostobsolete.net) and
|
||||
[tomparslow.co.uk](http://tomparslow.co.uk)) as part of Active Inbox
|
||||
([activeinboxhq.com](http://activeinboxhq.com/)).
|
||||
|
||||
[](https://travis-ci.org/almost/through2-concurrent)
|
||||
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
```bash
|
||||
npm install --save through2-concurrent
|
||||
```
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Process lines from a CSV in paralel. The order the results end up in
|
||||
the `all` variable is not deterministic.
|
||||
|
||||
```javascript
|
||||
var through2Concurrent = require('through2-concurrent');
|
||||
|
||||
var all = [];
|
||||
|
||||
fs.createReadStream('data.csv')
|
||||
.pipe(csv2())
|
||||
.pipe(through2Concurrent.obj(
|
||||
{maxConcurrency: 10},
|
||||
function (chunk, enc, callback) {
|
||||
var self = this;
|
||||
someThingAsync(chunk, function (newChunk) {
|
||||
self.push(newChunk);
|
||||
callback();
|
||||
});
|
||||
}))
|
||||
.on('data', function (data) {
|
||||
all.push(data)
|
||||
})
|
||||
.on('end', function () {
|
||||
doSomethingSpecial(all)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Fixed or improved stuff? Great! Send me a pull request [through GitHub](http://github.com/almost/through2-concurrent)
|
||||
or get in touch on Twitter [@almostobsolete][#tom-twitter] or email at tom@almostobsolete.net
|
||||
|
||||
[#tom]: http://www.almostobsolete.net
|
||||
[#tom-twitter]: https://twitter.com/almostobsolete
|
||||
68
node_modules/through2-concurrent/package.json
generated
vendored
Normal file
68
node_modules/through2-concurrent/package.json
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"_from": "through2-concurrent@^2.0.0",
|
||||
"_id": "through2-concurrent@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-R5/jLkfMvdmDD+seLwN7vB+mhbqzWop5fAjx5IX8/yQq7VhBhzDmhXgaHAOnhnWkCpRMM7gToYHycB0CS/pd+A==",
|
||||
"_location": "/through2-concurrent",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "through2-concurrent@^2.0.0",
|
||||
"name": "through2-concurrent",
|
||||
"escapedName": "through2-concurrent",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gulp-imagemin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/through2-concurrent/-/through2-concurrent-2.0.0.tgz",
|
||||
"_shasum": "c9dd2c146504ec9962dbc86a5168b63d662669fa",
|
||||
"_spec": "through2-concurrent@^2.0.0",
|
||||
"_where": "/var/www/html/jason/WeihnachtenMelly/node_modules/gulp-imagemin",
|
||||
"author": {
|
||||
"name": "Thomas Parslow",
|
||||
"email": "tom@almostobsolete.net",
|
||||
"url": "http://almostobsolete.net/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/almost/through2-concurrent/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Like through2 except runs in parallel with limited concurrency",
|
||||
"devDependencies": {
|
||||
"expect.js": "^0.3.1",
|
||||
"mocha": "^2.2.1",
|
||||
"underscore": "^1.8.2"
|
||||
},
|
||||
"files": [
|
||||
"through2-concurrent.js"
|
||||
],
|
||||
"homepage": "https://github.com/almost/through2-concurrent#readme",
|
||||
"keywords": [
|
||||
"through2",
|
||||
"streams",
|
||||
"streams2",
|
||||
"through",
|
||||
"transform",
|
||||
"concurrency",
|
||||
"parallel"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "through2-concurrent.js",
|
||||
"name": "through2-concurrent",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/almost/through2-concurrent.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
||||
101
node_modules/through2-concurrent/through2-concurrent.js
generated
vendored
Normal file
101
node_modules/through2-concurrent/through2-concurrent.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
// Like through2 except execute in parallel with a set maximum
|
||||
// concurrency
|
||||
"use strict";
|
||||
var through2 = require('through2');
|
||||
|
||||
function cbNoop (cb) {
|
||||
cb();
|
||||
}
|
||||
|
||||
module.exports = function concurrentThrough (options, transform, flush) {
|
||||
var concurrent = 0, lastCallback = null, pendingFinish = null;
|
||||
|
||||
if (typeof options === 'function') {
|
||||
flush = transform;
|
||||
transform = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
var maxConcurrency = options.maxConcurrency || 16;
|
||||
|
||||
function _transform (message, enc, callback) {
|
||||
var self = this;
|
||||
var callbackCalled = false;
|
||||
concurrent++;
|
||||
if (concurrent < maxConcurrency) {
|
||||
// Ask for more right away
|
||||
callback();
|
||||
} else {
|
||||
// We're at the concurrency limit, save the callback for
|
||||
// when we're ready for more
|
||||
lastCallback = callback;
|
||||
}
|
||||
|
||||
transform.call(this, message, enc, function (err) {
|
||||
// Ignore multiple calls of the callback (shouldn't ever
|
||||
// happen, but just in case)
|
||||
if (callbackCalled) return;
|
||||
callbackCalled = true;
|
||||
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
} else if (arguments.length > 1) {
|
||||
self.push(arguments[1]);
|
||||
}
|
||||
|
||||
concurrent--;
|
||||
if (lastCallback) {
|
||||
var cb = lastCallback;
|
||||
lastCallback = null;
|
||||
cb();
|
||||
}
|
||||
if (concurrent === 0 && pendingFinish) {
|
||||
pendingFinish();
|
||||
pendingFinish = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// We need to pass in final to through2 even if the caller has
|
||||
// not given us a final option so that it will wait for all
|
||||
// transform callbacks to complete before emitting a "finish"
|
||||
// and "end" event.
|
||||
if (typeof options.final !== 'function') {
|
||||
options.final = cbNoop;
|
||||
}
|
||||
// We also wrap flush to make sure anyone using an ancient version
|
||||
// of through2 without support for final will get the old behaviour.
|
||||
// TODO: don't wrap flush after upgrading through2 to a version with guaranteed `_final`
|
||||
if (typeof flush !== 'function') {
|
||||
flush = cbNoop;
|
||||
}
|
||||
|
||||
// Flush is always called only after Final has finished
|
||||
// to ensure that data from Final gets processed, so we only need one pending callback at a time
|
||||
function callOnFinish (original) {
|
||||
return function (callback) {
|
||||
if (concurrent === 0) {
|
||||
original.call(this, callback);
|
||||
} else {
|
||||
pendingFinish = original.bind(this, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
options.final = callOnFinish(options.final);
|
||||
return through2(options, _transform, callOnFinish(flush));
|
||||
};
|
||||
|
||||
module.exports.obj = function (options, transform, flush) {
|
||||
if (typeof options === 'function') {
|
||||
flush = transform;
|
||||
transform = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
options.objectMode = true;
|
||||
if (options.highWaterMark == null) {
|
||||
options.highWaterMark = 16;
|
||||
}
|
||||
return module.exports(options, transform, flush);
|
||||
};
|
||||
Reference in New Issue
Block a user