aboutsummaryrefslogtreecommitdiff
path: root/node_modules/stream-to-array
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/stream-to-array
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
downloadwallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz
update packages
Diffstat (limited to 'node_modules/stream-to-array')
-rw-r--r--node_modules/stream-to-array/.npmignore1
-rw-r--r--node_modules/stream-to-array/.travis.yml7
-rw-r--r--node_modules/stream-to-array/Makefile12
-rw-r--r--node_modules/stream-to-array/README.md73
-rw-r--r--node_modules/stream-to-array/index.js85
-rw-r--r--node_modules/stream-to-array/package.json35
6 files changed, 106 insertions, 107 deletions
diff --git a/node_modules/stream-to-array/.npmignore b/node_modules/stream-to-array/.npmignore
deleted file mode 100644
index 602eb8e1b..000000000
--- a/node_modules/stream-to-array/.npmignore
+++ /dev/null
@@ -1 +0,0 @@
-test.js \ No newline at end of file
diff --git a/node_modules/stream-to-array/.travis.yml b/node_modules/stream-to-array/.travis.yml
deleted file mode 100644
index 251c95a3b..000000000
--- a/node_modules/stream-to-array/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-node_js:
-- "0.10"
-- "0.11"
-language: node_js
-matrix:
- allow_failures:
- - node_js: "0.11" \ No newline at end of file
diff --git a/node_modules/stream-to-array/Makefile b/node_modules/stream-to-array/Makefile
deleted file mode 100644
index 74096766c..000000000
--- a/node_modules/stream-to-array/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-NODE ?= node
-BIN = ./node_modules/.bin/
-
-test:
- @${NODE} ${BIN}mocha \
- --reporter spec \
- --bail
-
-clean:
- @rm -rf node_modules
-
-.PHONY: test clean \ No newline at end of file
diff --git a/node_modules/stream-to-array/README.md b/node_modules/stream-to-array/README.md
index 56adf2dc5..0af44eb86 100644
--- a/node_modules/stream-to-array/README.md
+++ b/node_modules/stream-to-array/README.md
@@ -1,4 +1,11 @@
-# Stream to Array [![Build Status](https://travis-ci.org/stream-utils/stream-to-array.png)](https://travis-ci.org/stream-utils/stream-to-array)
+# Stream to Array
+
+[![NPM version][npm-image]][npm-url]
+[![Build status][travis-image]][travis-url]
+[![Test coverage][coveralls-image]][coveralls-url]
+[![Dependency Status][david-image]][david-url]
+[![License][license-image]][license-url]
+[![Downloads][downloads-image]][downloads-url]
Concatenate a readable stream's data into a single array.
@@ -10,7 +17,6 @@ You may also be interested in:
```js
var toArray = require('stream-to-array')
-var stream = fs.createReadStream('some file.txt')
```
### toArray([stream], [callback(err, arr)])
@@ -19,7 +25,8 @@ Returns all the data objects in an array.
This is useful for streams in object mode if you want to just use an array.
```js
-streamTo.array(stream, function (err, arr) {
+var stream = new Stream.Readable()
+toArray(stream, function (err, arr) {
assert.ok(Array.isArray(arr))
})
```
@@ -34,44 +41,40 @@ stream.toArray(function (err, arr) {
})
```
-If `callback` is not defined, then it is assumed that it is being yielded within a generator.
+If `callback` is not defined, then it returns a promise.
```js
-function* () {
- var stream = new Stream.Readable()
- stream.toArray = toArray
- var arr = yield stream.toArray()
-}
+toArray(stream)
+ .then(function (parts) {
+
+ })
```
If you want to return a buffer, just use `Buffer.concat(arr)`
```js
-var stream = new Stream.Readable()
-var arr = yield toArray(stream)
-var buffer = Buffer.concat(arr)
+toArray(stream)
+ .then(function (parts) {
+ var buffers = []
+ for (var i = 0, l = parts.length; i < l ; ++i) {
+ var part = parts[i]
+ buffers.push((part instanceof Buffer) ? part : new Buffer(part))
+ }
+ return Buffer.concat(buffers)
+ })
```
-## License
-
-The MIT License (MIT)
-
-Copyright (c) 2013 Jonathan Ong me@jongleberry.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.
+[npm-image]: https://img.shields.io/npm/v/stream-to-array.svg?style=flat-square
+[npm-url]: https://npmjs.org/package/stream-to-array
+[github-tag]: http://img.shields.io/github/tag/stream-utils/stream-to-array.svg?style=flat-square
+[github-url]: https://github.com/stream-utils/stream-to-array/tags
+[travis-image]: https://img.shields.io/travis/stream-utils/stream-to-array.svg?style=flat-square
+[travis-url]: https://travis-ci.org/stream-utils/stream-to-array
+[coveralls-image]: https://img.shields.io/coveralls/stream-utils/stream-to-array.svg?style=flat-square
+[coveralls-url]: https://coveralls.io/r/stream-utils/stream-to-array?branch=master
+[david-image]: http://img.shields.io/david/stream-utils/stream-to-array.svg?style=flat-square
+[david-url]: https://david-dm.org/stream-utils/stream-to-array
+[license-image]: http://img.shields.io/npm/l/stream-to-array.svg?style=flat-square
+[license-url]: LICENSE
+[downloads-image]: http://img.shields.io/npm/dm/stream-to-array.svg?style=flat-square
+[downloads-url]: https://npmjs.org/package/stream-to-array
diff --git a/node_modules/stream-to-array/index.js b/node_modules/stream-to-array/index.js
index 76fcd1fc6..2d6aaa0fb 100644
--- a/node_modules/stream-to-array/index.js
+++ b/node_modules/stream-to-array/index.js
@@ -1,3 +1,6 @@
+
+var Promise = require('any-promise')
+
module.exports = function (stream, done) {
if (!stream) {
// no arguments, meaning stream = this
@@ -8,42 +11,50 @@ module.exports = function (stream, done) {
stream = this
}
- // if stream is already ended,
- // return an array
- if (!stream.readable) {
- process.nextTick(function () {
- done(null, [])
- })
- return defer
- }
-
- var arr = []
-
- stream.on('data', onData)
- stream.once('end', onEnd)
- stream.once('error', onEnd)
- stream.once('close', cleanup)
-
- return defer
-
- function defer(fn) {
- done = fn
- }
-
- function onData(doc) {
- arr.push(doc)
+ var deferred
+ if (!stream.readable) deferred = Promise.resolve([])
+ else deferred = new Promise(function (resolve, reject) {
+ // stream is already ended
+ if (!stream.readable) return resolve([])
+
+ var arr = []
+
+ stream.on('data', onData)
+ stream.on('end', onEnd)
+ stream.on('error', onEnd)
+ stream.on('close', onClose)
+
+ function onData(doc) {
+ arr.push(doc)
+ }
+
+ function onEnd(err) {
+ if (err) reject(err)
+ else resolve(arr)
+ cleanup()
+ }
+
+ function onClose() {
+ resolve(arr)
+ cleanup()
+ }
+
+ function cleanup() {
+ arr = null
+ stream.removeListener('data', onData)
+ stream.removeListener('end', onEnd)
+ stream.removeListener('error', onEnd)
+ stream.removeListener('close', onClose)
+ }
+ })
+
+ if (typeof done === 'function') {
+ deferred.then(function (arr) {
+ process.nextTick(function() {
+ done(null, arr)
+ })
+ }, done)
}
- function onEnd(err) {
- done(err, arr)
- cleanup()
- }
-
- function cleanup() {
- arr = null
- stream.removeListener('data', onData)
- stream.removeListener('end', onEnd)
- stream.removeListener('error', onEnd)
- stream.removeListener('close', cleanup)
- }
-} \ No newline at end of file
+ return deferred
+}
diff --git a/node_modules/stream-to-array/package.json b/node_modules/stream-to-array/package.json
index 8dfe674d8..67e7b3df5 100644
--- a/node_modules/stream-to-array/package.json
+++ b/node_modules/stream-to-array/package.json
@@ -1,7 +1,7 @@
{
"name": "stream-to-array",
"description": "Concatenate a readable stream's data into a single array",
- "version": "1.0.0",
+ "version": "2.3.0",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
@@ -9,23 +9,28 @@
"twitter": "https://twitter.com/jongleberry"
},
"license": "MIT",
- "repository": {
- "type": "git",
- "url": "https://github.com/stream-utils/stream-to-array.git"
- },
- "bugs": {
- "mail": "me@jongleberry.com",
- "url": "https://github.com/stream-utils/stream-to-array/issues"
+ "repository": "stream-utils/stream-to-array",
+ "dependencies": {
+ "any-promise": "^1.1.0"
},
"devDependencies": {
- "co": "*",
- "gnode": "*",
- "mocha": "*"
+ "bluebird": "^3.1.1",
+ "istanbul": "^0.4.2",
+ "mocha": "^2.3.3"
},
"scripts": {
- "test": "NODE=gnode make test"
+ "test": "mocha --reporter spec --bail",
+ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
+ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
},
- "engines": {
- "node": ">= 0.10.0"
- }
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "stream",
+ "streams",
+ "buffer",
+ "array",
+ "concat"
+ ]
}