summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream')
-rw-r--r--deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/LICENSE21
-rw-r--r--deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/README.md52
-rw-r--r--deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/index.js87
-rw-r--r--deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/package.json66
4 files changed, 226 insertions, 0 deletions
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/LICENSE b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/LICENSE
new file mode 100644
index 0000000000..757562ec59
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/LICENSE
@@ -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. \ No newline at end of file
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/README.md b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/README.md
new file mode 100644
index 0000000000..f2560c939d
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/README.md
@@ -0,0 +1,52 @@
+# 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
+
+## 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.
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/index.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/index.js
new file mode 100644
index 0000000000..be426c227c
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/index.js
@@ -0,0 +1,87 @@
+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 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() {
+ if (readable && !(rs && rs.ended)) return callback.call(stream, new Error('premature close'));
+ if (writable && !(ws && ws.ended)) 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() {
+ 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;
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/package.json b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/package.json
new file mode 100644
index 0000000000..17fba30234
--- /dev/null
+++ b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/package.json
@@ -0,0 +1,66 @@
+{
+ "_from": "end-of-stream@^1.1.0",
+ "_id": "end-of-stream@1.4.1",
+ "_inBundle": false,
+ "_integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
+ "_location": "/pacote/make-fetch-happen/mississippi/end-of-stream",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "end-of-stream@^1.1.0",
+ "name": "end-of-stream",
+ "escapedName": "end-of-stream",
+ "rawSpec": "^1.1.0",
+ "saveSpec": null,
+ "fetchSpec": "^1.1.0"
+ },
+ "_requiredBy": [
+ "/pacote/make-fetch-happen/mississippi",
+ "/pacote/make-fetch-happen/mississippi/duplexify",
+ "/pacote/make-fetch-happen/mississippi/pump",
+ "/pacote/make-fetch-happen/mississippi/pumpify/pump",
+ "/pacote/make-fetch-happen/mississippi/stream-each"
+ ],
+ "_resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
+ "_shasum": "ed29634d19baba463b6ce6b80a37213eab71ec43",
+ "_spec": "end-of-stream@^1.1.0",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi",
+ "author": {
+ "name": "Mathias Buus",
+ "email": "mathiasbuus@gmail.com"
+ },
+ "bugs": {
+ "url": "https://github.com/mafintosh/end-of-stream/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "once": "^1.4.0"
+ },
+ "deprecated": false,
+ "description": "Call a callback when a readable/writable/duplex stream has completed or failed.",
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/mafintosh/end-of-stream",
+ "keywords": [
+ "stream",
+ "streams",
+ "callback",
+ "finish",
+ "close",
+ "end",
+ "wait"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "end-of-stream",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mafintosh/end-of-stream.git"
+ },
+ "scripts": {
+ "test": "node test.js"
+ },
+ "version": "1.4.1"
+}