diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/stream-to-array/README.md | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/stream-to-array/README.md')
-rw-r--r-- | node_modules/stream-to-array/README.md | 73 |
1 files changed, 38 insertions, 35 deletions
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 [](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 |