údržba
This commit is contained in:
		
							
								
								
									
										21
									
								
								CyLukTs/lukan/node_modules/end-of-stream/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								CyLukTs/lukan/node_modules/end-of-stream/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
The MIT License (MIT)
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2014 Mathias Buus
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
							
								
								
									
										54
									
								
								CyLukTs/lukan/node_modules/end-of-stream/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								CyLukTs/lukan/node_modules/end-of-stream/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
# end-of-stream
 | 
			
		||||
 | 
			
		||||
A node module that calls a callback when a readable/writable/duplex stream has completed or failed.
 | 
			
		||||
 | 
			
		||||
	npm install end-of-stream
 | 
			
		||||
 | 
			
		||||
[](https://travis-ci.org/mafintosh/end-of-stream)
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
Simply pass a stream and a callback to the `eos`.
 | 
			
		||||
Both legacy streams, streams2 and stream3 are supported.
 | 
			
		||||
 | 
			
		||||
``` js
 | 
			
		||||
var eos = require('end-of-stream');
 | 
			
		||||
 | 
			
		||||
eos(readableStream, function(err) {
 | 
			
		||||
  // this will be set to the stream instance
 | 
			
		||||
	if (err) return console.log('stream had an error or closed early');
 | 
			
		||||
	console.log('stream has ended', this === readableStream);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
eos(writableStream, function(err) {
 | 
			
		||||
	if (err) return console.log('stream had an error or closed early');
 | 
			
		||||
	console.log('stream has finished', this === writableStream);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
eos(duplexStream, function(err) {
 | 
			
		||||
	if (err) return console.log('stream had an error or closed early');
 | 
			
		||||
	console.log('stream has ended and finished', this === duplexStream);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
eos(duplexStream, {readable:false}, function(err) {
 | 
			
		||||
	if (err) return console.log('stream had an error or closed early');
 | 
			
		||||
	console.log('stream has finished but might still be readable');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
eos(duplexStream, {writable:false}, function(err) {
 | 
			
		||||
	if (err) return console.log('stream had an error or closed early');
 | 
			
		||||
	console.log('stream has ended but might still be writable');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
eos(readableStream, {error:false}, function(err) {
 | 
			
		||||
	// do not treat emit('error', err) as a end-of-stream
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## License
 | 
			
		||||
 | 
			
		||||
MIT
 | 
			
		||||
 | 
			
		||||
## Related
 | 
			
		||||
 | 
			
		||||
`end-of-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.
 | 
			
		||||
							
								
								
									
										94
									
								
								CyLukTs/lukan/node_modules/end-of-stream/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								CyLukTs/lukan/node_modules/end-of-stream/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
			
		||||
var once = require('once');
 | 
			
		||||
 | 
			
		||||
var noop = function() {};
 | 
			
		||||
 | 
			
		||||
var isRequest = function(stream) {
 | 
			
		||||
	return stream.setHeader && typeof stream.abort === 'function';
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var isChildProcess = function(stream) {
 | 
			
		||||
	return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var eos = function(stream, opts, callback) {
 | 
			
		||||
	if (typeof opts === 'function') return eos(stream, null, opts);
 | 
			
		||||
	if (!opts) opts = {};
 | 
			
		||||
 | 
			
		||||
	callback = once(callback || noop);
 | 
			
		||||
 | 
			
		||||
	var ws = stream._writableState;
 | 
			
		||||
	var rs = stream._readableState;
 | 
			
		||||
	var readable = opts.readable || (opts.readable !== false && stream.readable);
 | 
			
		||||
	var writable = opts.writable || (opts.writable !== false && stream.writable);
 | 
			
		||||
	var cancelled = false;
 | 
			
		||||
 | 
			
		||||
	var onlegacyfinish = function() {
 | 
			
		||||
		if (!stream.writable) onfinish();
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	var onfinish = function() {
 | 
			
		||||
		writable = false;
 | 
			
		||||
		if (!readable) callback.call(stream);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	var onend = function() {
 | 
			
		||||
		readable = false;
 | 
			
		||||
		if (!writable) callback.call(stream);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	var onexit = function(exitCode) {
 | 
			
		||||
		callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	var onerror = function(err) {
 | 
			
		||||
		callback.call(stream, err);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	var onclose = function() {
 | 
			
		||||
		process.nextTick(onclosenexttick);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	var onclosenexttick = function() {
 | 
			
		||||
		if (cancelled) return;
 | 
			
		||||
		if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error('premature close'));
 | 
			
		||||
		if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error('premature close'));
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	var onrequest = function() {
 | 
			
		||||
		stream.req.on('finish', onfinish);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	if (isRequest(stream)) {
 | 
			
		||||
		stream.on('complete', onfinish);
 | 
			
		||||
		stream.on('abort', onclose);
 | 
			
		||||
		if (stream.req) onrequest();
 | 
			
		||||
		else stream.on('request', onrequest);
 | 
			
		||||
	} else if (writable && !ws) { // legacy streams
 | 
			
		||||
		stream.on('end', onlegacyfinish);
 | 
			
		||||
		stream.on('close', onlegacyfinish);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (isChildProcess(stream)) stream.on('exit', onexit);
 | 
			
		||||
 | 
			
		||||
	stream.on('end', onend);
 | 
			
		||||
	stream.on('finish', onfinish);
 | 
			
		||||
	if (opts.error !== false) stream.on('error', onerror);
 | 
			
		||||
	stream.on('close', onclose);
 | 
			
		||||
 | 
			
		||||
	return function() {
 | 
			
		||||
		cancelled = true;
 | 
			
		||||
		stream.removeListener('complete', onfinish);
 | 
			
		||||
		stream.removeListener('abort', onclose);
 | 
			
		||||
		stream.removeListener('request', onrequest);
 | 
			
		||||
		if (stream.req) stream.req.removeListener('finish', onfinish);
 | 
			
		||||
		stream.removeListener('end', onlegacyfinish);
 | 
			
		||||
		stream.removeListener('close', onlegacyfinish);
 | 
			
		||||
		stream.removeListener('finish', onfinish);
 | 
			
		||||
		stream.removeListener('exit', onexit);
 | 
			
		||||
		stream.removeListener('end', onend);
 | 
			
		||||
		stream.removeListener('error', onerror);
 | 
			
		||||
		stream.removeListener('close', onclose);
 | 
			
		||||
	};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports = eos;
 | 
			
		||||
							
								
								
									
										37
									
								
								CyLukTs/lukan/node_modules/end-of-stream/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								CyLukTs/lukan/node_modules/end-of-stream/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "end-of-stream",
 | 
			
		||||
  "version": "1.4.4",
 | 
			
		||||
  "description": "Call a callback when a readable/writable/duplex stream has completed or failed.",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git://github.com/mafintosh/end-of-stream.git"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "once": "^1.4.0"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": "node test.js"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "index.js"
 | 
			
		||||
  ],
 | 
			
		||||
  "keywords": [
 | 
			
		||||
    "stream",
 | 
			
		||||
    "streams",
 | 
			
		||||
    "callback",
 | 
			
		||||
    "finish",
 | 
			
		||||
    "close",
 | 
			
		||||
    "end",
 | 
			
		||||
    "wait"
 | 
			
		||||
  ],
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/mafintosh/end-of-stream/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "homepage": "https://github.com/mafintosh/end-of-stream",
 | 
			
		||||
  "main": "index.js",
 | 
			
		||||
  "author": "Mathias Buus <mathiasbuus@gmail.com>",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "tape": "^4.11.0"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user