summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/get-stream
diff options
context:
space:
mode:
authorKat Marchán <kzm@zkat.tech>2019-01-29 14:43:00 -0800
committerMyles Borins <mylesborins@google.com>2019-02-12 00:06:29 -0800
commit43dd49c9782848c25e5b03448c8a0f923f13c158 (patch)
treef7ac5d645019b2b844f26be66c291bbae734d097 /deps/npm/node_modules/get-stream
parentb361f9577fbd72e518438d3fa0b01f7d34d814a5 (diff)
downloadandroid-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.tar.gz
android-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.tar.bz2
android-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.zip
deps: upgrade npm to 6.7.0
PR-URL: https://github.com/nodejs/node/pull/25804 Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/get-stream')
-rw-r--r--deps/npm/node_modules/get-stream/buffer-stream.js10
-rw-r--r--deps/npm/node_modules/get-stream/index.js61
-rw-r--r--deps/npm/node_modules/get-stream/license20
-rw-r--r--deps/npm/node_modules/get-stream/package.json46
-rw-r--r--deps/npm/node_modules/get-stream/readme.md26
5 files changed, 80 insertions, 83 deletions
diff --git a/deps/npm/node_modules/get-stream/buffer-stream.js b/deps/npm/node_modules/get-stream/buffer-stream.js
index ae45d3d9e7..4121c8e56f 100644
--- a/deps/npm/node_modules/get-stream/buffer-stream.js
+++ b/deps/npm/node_modules/get-stream/buffer-stream.js
@@ -1,11 +1,11 @@
'use strict';
-const PassThrough = require('stream').PassThrough;
+const {PassThrough} = require('stream');
-module.exports = opts => {
- opts = Object.assign({}, opts);
+module.exports = options => {
+ options = Object.assign({}, options);
- const array = opts.array;
- let encoding = opts.encoding;
+ const {array} = options;
+ let {encoding} = options;
const buffer = encoding === 'buffer';
let objectMode = false;
diff --git a/deps/npm/node_modules/get-stream/index.js b/deps/npm/node_modules/get-stream/index.js
index 2dc5ee96af..7e5584a63d 100644
--- a/deps/npm/node_modules/get-stream/index.js
+++ b/deps/npm/node_modules/get-stream/index.js
@@ -1,51 +1,50 @@
'use strict';
+const pump = require('pump');
const bufferStream = require('./buffer-stream');
-function getStream(inputStream, opts) {
+class MaxBufferError extends Error {
+ constructor() {
+ super('maxBuffer exceeded');
+ this.name = 'MaxBufferError';
+ }
+}
+
+function getStream(inputStream, options) {
if (!inputStream) {
return Promise.reject(new Error('Expected a stream'));
}
- opts = Object.assign({maxBuffer: Infinity}, opts);
+ options = Object.assign({maxBuffer: Infinity}, options);
- const maxBuffer = opts.maxBuffer;
- let stream;
- let clean;
+ const {maxBuffer} = options;
- const p = new Promise((resolve, reject) => {
- const error = err => {
- if (err) { // null check
- err.bufferedData = stream.getBufferedValue();
+ let stream;
+ return new Promise((resolve, reject) => {
+ const rejectPromise = error => {
+ if (error) { // A null check
+ error.bufferedData = stream.getBufferedValue();
}
-
- reject(err);
+ reject(error);
};
- stream = bufferStream(opts);
- inputStream.once('error', error);
- inputStream.pipe(stream);
+ stream = pump(inputStream, bufferStream(options), error => {
+ if (error) {
+ rejectPromise(error);
+ return;
+ }
+
+ resolve();
+ });
stream.on('data', () => {
if (stream.getBufferedLength() > maxBuffer) {
- reject(new Error('maxBuffer exceeded'));
+ rejectPromise(new MaxBufferError());
}
});
- stream.once('error', error);
- stream.on('end', resolve);
-
- clean = () => {
- // some streams doesn't implement the `stream.Readable` interface correctly
- if (inputStream.unpipe) {
- inputStream.unpipe(stream);
- }
- };
- });
-
- p.then(clean, clean);
-
- return p.then(() => stream.getBufferedValue());
+ }).then(() => stream.getBufferedValue());
}
module.exports = getStream;
-module.exports.buffer = (stream, opts) => getStream(stream, Object.assign({}, opts, {encoding: 'buffer'}));
-module.exports.array = (stream, opts) => getStream(stream, Object.assign({}, opts, {array: true}));
+module.exports.buffer = (stream, options) => getStream(stream, Object.assign({}, options, {encoding: 'buffer'}));
+module.exports.array = (stream, options) => getStream(stream, Object.assign({}, options, {array: true}));
+module.exports.MaxBufferError = MaxBufferError;
diff --git a/deps/npm/node_modules/get-stream/license b/deps/npm/node_modules/get-stream/license
index 654d0bfe94..e7af2f7710 100644
--- a/deps/npm/node_modules/get-stream/license
+++ b/deps/npm/node_modules/get-stream/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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:
+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 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.
+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.
diff --git a/deps/npm/node_modules/get-stream/package.json b/deps/npm/node_modules/get-stream/package.json
index 3042176e14..a34aa1daf0 100644
--- a/deps/npm/node_modules/get-stream/package.json
+++ b/deps/npm/node_modules/get-stream/package.json
@@ -1,29 +1,35 @@
{
- "_from": "get-stream@^3.0.0",
- "_id": "get-stream@3.0.0",
+ "_from": "get-stream@",
+ "_id": "get-stream@4.1.0",
"_inBundle": false,
- "_integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=",
+ "_integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==",
"_location": "/get-stream",
"_phantomChildren": {},
"_requested": {
- "type": "range",
+ "type": "tag",
"registry": true,
- "raw": "get-stream@^3.0.0",
+ "raw": "get-stream@",
"name": "get-stream",
"escapedName": "get-stream",
- "rawSpec": "^3.0.0",
+ "rawSpec": "",
"saveSpec": null,
- "fetchSpec": "^3.0.0"
+ "fetchSpec": "latest"
},
"_requiredBy": [
- "/execa",
- "/got",
+ "#DEV:/",
+ "#USER",
+ "/libnpm/libnpmhook",
+ "/libnpmaccess",
+ "/libnpmorg",
+ "/libnpmpublish",
+ "/libnpmsearch",
+ "/libnpmteam",
"/pacote"
],
- "_resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
- "_shasum": "8e943d1358dc37555054ecbe2edb05aa174ede14",
- "_spec": "get-stream@^3.0.0",
- "_where": "/Users/rebecca/code/npm/node_modules/pacote",
+ "_resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz",
+ "_shasum": "c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5",
+ "_spec": "get-stream@",
+ "_where": "/Users/zkat/Documents/code/work/npm",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
@@ -33,6 +39,9 @@
"url": "https://github.com/sindresorhus/get-stream/issues"
},
"bundleDependencies": false,
+ "dependencies": {
+ "pump": "^3.0.0"
+ },
"deprecated": false,
"description": "Get a stream as a string, buffer, or array",
"devDependencies": {
@@ -41,7 +50,7 @@
"xo": "*"
},
"engines": {
- "node": ">=4"
+ "node": ">=6"
},
"files": [
"index.js",
@@ -54,7 +63,6 @@
"promise",
"concat",
"string",
- "str",
"text",
"buffer",
"read",
@@ -63,8 +71,7 @@
"readable",
"readablestream",
"array",
- "object",
- "obj"
+ "object"
],
"license": "MIT",
"name": "get-stream",
@@ -75,8 +82,5 @@
"scripts": {
"test": "xo && ava"
},
- "version": "3.0.0",
- "xo": {
- "esnext": true
- }
+ "version": "4.1.0"
}
diff --git a/deps/npm/node_modules/get-stream/readme.md b/deps/npm/node_modules/get-stream/readme.md
index 73b188fb42..b87a4d37ce 100644
--- a/deps/npm/node_modules/get-stream/readme.md
+++ b/deps/npm/node_modules/get-stream/readme.md
@@ -6,7 +6,7 @@
## Install
```
-$ npm install --save get-stream
+$ npm install get-stream
```
@@ -15,10 +15,11 @@ $ npm install --save get-stream
```js
const fs = require('fs');
const getStream = require('get-stream');
-const stream = fs.createReadStream('unicorn.txt');
-getStream(stream).then(str => {
- console.log(str);
+(async () => {
+ const stream = fs.createReadStream('unicorn.txt');
+
+ console.log(await getStream(stream));
/*
,,))))))));,
__)))))))))))))),
@@ -40,7 +41,7 @@ getStream(stream).then(str => {
\~\
~~
*/
-});
+})();
```
@@ -54,6 +55,8 @@ Get the `stream` as a string.
#### options
+Type: `Object`
+
##### encoding
Type: `string`<br>
@@ -66,7 +69,7 @@ Default: `utf8`
Type: `number`<br>
Default: `Infinity`
-Maximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected.
+Maximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected with a `getStream.MaxBufferError` error.
### getStream.buffer(stream, [options])
@@ -92,11 +95,14 @@ It honors both the `maxBuffer` and `encoding` options. The behavior changes slig
If the input stream emits an `error` event, the promise will be rejected with the error. The buffered data will be attached to the `bufferedData` property of the error.
```js
-getStream(streamThatErrorsAtTheEnd('unicorn'))
- .catch(err => {
- console.log(err.bufferedData);
+(async () => {
+ try {
+ await getStream(streamThatErrorsAtTheEnd('unicorn'));
+ } catch (error) {
+ console.log(error.bufferedData);
//=> 'unicorn'
- });
+ }
+})()
```