uapte
This commit is contained in:
1
node_modules/multipipe/.npmignore
generated
vendored
Normal file
1
node_modules/multipipe/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
3
node_modules/multipipe/.travis.yml
generated
vendored
Normal file
3
node_modules/multipipe/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
25
node_modules/multipipe/History.md
generated
vendored
Normal file
25
node_modules/multipipe/History.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
0.1.1 / 2014-06-01
|
||||
==================
|
||||
|
||||
* update duplexer2 dep
|
||||
|
||||
0.1.0 / 2014-05-24
|
||||
==================
|
||||
|
||||
* add optional callback
|
||||
|
||||
0.0.2 / 2014-02-20
|
||||
==================
|
||||
|
||||
* fix infinite loop
|
||||
|
||||
0.0.1 / 2014-01-15
|
||||
==================
|
||||
|
||||
* fix error bubbling
|
||||
|
||||
0.0.0 / 2014-01-13
|
||||
==================
|
||||
|
||||
* initial release
|
||||
10
node_modules/multipipe/Makefile
generated
vendored
Normal file
10
node_modules/multipipe/Makefile
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
node_modules: package.json
|
||||
@npm install
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--reporter spec \
|
||||
--timeout 100
|
||||
|
||||
.PHONY: test
|
||||
102
node_modules/multipipe/Readme.md
generated
vendored
Normal file
102
node_modules/multipipe/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
# multipipe
|
||||
|
||||
A better `Stream#pipe` that creates duplex streams and lets you handle errors in one place.
|
||||
|
||||
[](http://travis-ci.org/segmentio/multipipe)
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var pipe = require('multipipe');
|
||||
|
||||
// pipe streams
|
||||
var stream = pipe(streamA, streamB, streamC);
|
||||
|
||||
// centralized error handling
|
||||
stream.on('error', fn);
|
||||
|
||||
// creates a new stream
|
||||
source.pipe(stream).pipe(dest);
|
||||
|
||||
// optional callback on finish or error
|
||||
pipe(streamA, streamB, streamC, function(err){
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
## Duplex streams
|
||||
|
||||
Write to the pipe and you'll really write to the first stream, read from the pipe and you'll read from the last stream.
|
||||
|
||||
```js
|
||||
var stream = pipe(a, b, c);
|
||||
|
||||
source
|
||||
.pipe(stream)
|
||||
.pipe(destination);
|
||||
```
|
||||
|
||||
In this example the flow of data is:
|
||||
|
||||
* source ->
|
||||
* a ->
|
||||
* b ->
|
||||
* c ->
|
||||
* destination
|
||||
|
||||
## Error handling
|
||||
|
||||
Each `pipe` forwards the errors the streams it wraps emit, so you have one central place to handle errors:
|
||||
|
||||
```js
|
||||
var stream = pipe(a, b, c);
|
||||
|
||||
stream.on('error', function(err){
|
||||
// called three times
|
||||
});
|
||||
|
||||
a.emit('error', new Error);
|
||||
b.emit('error', new Error);
|
||||
c.emit('error', new Error);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### pipe(stream, ...)
|
||||
|
||||
Pass a variable number of streams and each will be piped to the next one.
|
||||
|
||||
A stream will be returned that wraps passed in streams in a way that errors will be forwarded and you can write to and/or read from it.
|
||||
|
||||
Pass a function as last argument to be called on `error` or `finish` of the last stream.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install multipipe
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Segment.io Inc. <friends@segment.io>
|
||||
Copyright (c) 2014 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
||||
72
node_modules/multipipe/index.js
generated
vendored
Normal file
72
node_modules/multipipe/index.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var duplexer = require('duplexer2');
|
||||
var Stream = require('stream');
|
||||
|
||||
/**
|
||||
* Slice reference.
|
||||
*/
|
||||
|
||||
var slice = [].slice;
|
||||
|
||||
/**
|
||||
* Duplexer options.
|
||||
*/
|
||||
|
||||
var opts = {
|
||||
bubbleErrors: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose `pipe`.
|
||||
*/
|
||||
|
||||
module.exports = pipe;
|
||||
|
||||
/**
|
||||
* Pipe.
|
||||
*
|
||||
* @param {Stream,...,[Function]}
|
||||
* @return {Stream}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function pipe(){
|
||||
if (arguments.length == 1) return arguments[0];
|
||||
var streams = slice.call(arguments);
|
||||
var cb;
|
||||
if ('function' == typeof streams[streams.length - 1]) {
|
||||
cb = streams.splice(-1)[0];
|
||||
}
|
||||
var first = streams[0];
|
||||
var last = streams[streams.length - 1];
|
||||
var ret;
|
||||
|
||||
if (first.writable && last.readable) ret = duplexer(opts, first, last);
|
||||
else if (first.writable) ret = first;
|
||||
else if (last.readable) ret = last;
|
||||
else ret = new Stream;
|
||||
|
||||
streams.forEach(function(stream, i){
|
||||
var next = streams[i+1];
|
||||
if (next) stream.pipe(next);
|
||||
if (stream != ret) stream.on('error', ret.emit.bind(ret, 'error'));
|
||||
});
|
||||
|
||||
if (cb) {
|
||||
var ended = false;
|
||||
ret.on('error', end);
|
||||
last.on('finish', end);
|
||||
function end(err){
|
||||
if (ended) return;
|
||||
ended = true;
|
||||
cb(err);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
48
node_modules/multipipe/package.json
generated
vendored
Normal file
48
node_modules/multipipe/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"_from": "multipipe@^0.1.2",
|
||||
"_id": "multipipe@0.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=",
|
||||
"_location": "/multipipe",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "multipipe@^0.1.2",
|
||||
"name": "multipipe",
|
||||
"escapedName": "multipipe",
|
||||
"rawSpec": "^0.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gulp-util"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz",
|
||||
"_shasum": "2a8f2ddf70eed564dff2d57f1e1a137d9f05078b",
|
||||
"_spec": "multipipe@^0.1.2",
|
||||
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-util",
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/multipipe/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"duplexer2": "0.0.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "pipe streams with centralized error handling",
|
||||
"devDependencies": {
|
||||
"mocha": "~1.17.0"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/multipipe#readme",
|
||||
"license": "MIT",
|
||||
"name": "multipipe",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/juliangruber/multipipe.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "0.1.2"
|
||||
}
|
||||
141
node_modules/multipipe/test/multipipe.js
generated
vendored
Normal file
141
node_modules/multipipe/test/multipipe.js
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
var assert = require('assert');
|
||||
var pipe = require('..');
|
||||
var Stream = require('stream');
|
||||
|
||||
describe('pipe(a)', function(){
|
||||
it('should return a', function(){
|
||||
var readable = Readable();
|
||||
var stream = pipe(readable);
|
||||
assert.equal(stream, readable);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pipe(a, b, c)', function(){
|
||||
it('should pipe internally', function(done){
|
||||
pipe(Readable(), Transform(), Writable(done));
|
||||
});
|
||||
|
||||
it('should be writable', function(done){
|
||||
var stream = pipe(Transform(), Writable(done));
|
||||
assert(stream.writable);
|
||||
Readable().pipe(stream);
|
||||
});
|
||||
|
||||
it('should be readable', function(done){
|
||||
var stream = pipe(Readable(), Transform());
|
||||
assert(stream.readable);
|
||||
stream.pipe(Writable(done));
|
||||
});
|
||||
|
||||
it('should be readable and writable', function(done){
|
||||
var stream = pipe(Transform(), Transform());
|
||||
assert(stream.readable);
|
||||
assert(stream.writable);
|
||||
Readable()
|
||||
.pipe(stream)
|
||||
.pipe(Writable(done));
|
||||
});
|
||||
|
||||
describe('errors', function(){
|
||||
it('should reemit', function(done){
|
||||
var a = Transform();
|
||||
var b = Transform();
|
||||
var c = Transform();
|
||||
var stream = pipe(a, b, c);
|
||||
var err = new Error;
|
||||
var i = 0;
|
||||
|
||||
stream.on('error', function(_err){
|
||||
i++;
|
||||
assert.equal(_err, err);
|
||||
assert(i <= 3);
|
||||
if (i == 3) done();
|
||||
});
|
||||
|
||||
a.emit('error', err);
|
||||
b.emit('error', err);
|
||||
c.emit('error', err);
|
||||
});
|
||||
|
||||
it('should not reemit endlessly', function(done){
|
||||
var a = Transform();
|
||||
var b = Transform();
|
||||
var c = Transform();
|
||||
c.readable = false;
|
||||
var stream = pipe(a, b, c);
|
||||
var err = new Error;
|
||||
var i = 0;
|
||||
|
||||
stream.on('error', function(_err){
|
||||
i++;
|
||||
assert.equal(_err, err);
|
||||
assert(i <= 3);
|
||||
if (i == 3) done();
|
||||
});
|
||||
|
||||
a.emit('error', err);
|
||||
b.emit('error', err);
|
||||
c.emit('error', err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('pipe(a, b, c, fn)', function(){
|
||||
it('should call on finish', function(done){
|
||||
var finished = false;
|
||||
var a = Readable();
|
||||
var b = Transform();
|
||||
var c = Writable(function(){
|
||||
finished = true;
|
||||
});
|
||||
|
||||
pipe(a, b, c, function(err){
|
||||
assert(!err);
|
||||
assert(finished);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call with error once', function(done){
|
||||
var a = Readable();
|
||||
var b = Transform();
|
||||
var c = Writable();
|
||||
var err = new Error;
|
||||
|
||||
pipe(a, b, c, function(err){
|
||||
assert(err);
|
||||
done();
|
||||
});
|
||||
|
||||
a.emit('error', err);
|
||||
b.emit('error', err);
|
||||
c.emit('error', err);
|
||||
});
|
||||
});
|
||||
|
||||
function Readable(){
|
||||
var readable = new Stream.Readable({ objectMode: true });
|
||||
readable._read = function(){
|
||||
this.push('a');
|
||||
this.push(null);
|
||||
};
|
||||
return readable;
|
||||
}
|
||||
|
||||
function Transform(){
|
||||
var transform = new Stream.Transform({ objectMode: true });
|
||||
transform._transform = function(chunk, _, done){
|
||||
done(null, chunk.toUpperCase());
|
||||
};
|
||||
return transform;
|
||||
}
|
||||
|
||||
function Writable(cb){
|
||||
var writable = new Stream.Writable({ objectMode: true });
|
||||
writable._write = function(chunk, _, done){
|
||||
assert.equal(chunk, 'A');
|
||||
done();
|
||||
cb();
|
||||
};
|
||||
return writable;
|
||||
}
|
||||
Reference in New Issue
Block a user