pax_global_header00006660000000000000000000000064127111462320014511gustar00rootroot0000000000000052 comment=bfdc14a2f220b767d62910902aa4bffeac52b77f node-stream-array-1.1.2/000077500000000000000000000000001271114623200150445ustar00rootroot00000000000000node-stream-array-1.1.2/.gitignore000066400000000000000000000001271271114623200170340ustar00rootroot00000000000000*.*~ *.seed *.log *.csv *.dat *.out *.swp *.pid *.gz *.tgz node_modules npm-debug.log node-stream-array-1.1.2/.npmignore000066400000000000000000000001171271114623200170420ustar00rootroot00000000000000*.*~ *.seed *.log *.csv *.dat *.out *.swp *.pid *.gz *.tgz *.lock .travis.yml node-stream-array-1.1.2/.travis.yml000066400000000000000000000012701271114623200171550ustar00rootroot00000000000000sudo: false language: node_js notifications: email: false before_install: - npm install -g npm@2 - npm install -g npm - '[ "${TRAVIS_NODE_VERSION}" == "0.8" -o "${TRAVIS_NODE_VERSION}" == "0.10" ] || npm install -g covert' matrix: fast_finish: true include: - node_js: '0.8' env: TASK=test - node_js: '0.10' env: TASK=test - node_js: '0.12' env: TASK=coverage - node_js: '1' env: TASK=coverage - node_js: '2' env: TASK=coverage - node_js: '3' env: TASK=coverage - node_js: '4' env: TASK=coverage - node_js: '5' env: TASK=coverage - node_js: '6' env: TASK=coverage script: "npm run $TASK" node-stream-array-1.1.2/LICENSE000066400000000000000000000021001271114623200160420ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2013 Matthew I. Metnetsky 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. node-stream-array-1.1.2/README.md000066400000000000000000000043751271114623200163340ustar00rootroot00000000000000# stream-array Pipe an Array through Node.js [Streams][12]. This is rather useful for testing other streams. [![npm version][1]][2] [![build status][3]][4] [![dependencies][5]][6] [![devDependencies][7]][8] [![Inch CI][16]][17] [//]: [![testling][9]][10] ## Usage ```js var streamify = require('stream-array'), os = require('os'); streamify(['1', '2', '3', os.EOL]).pipe(process.stdout); ``` ## API #### streamify(Array) The result of [require][13] is a 'function()' that when invoked, will return a [Readable][11] [Stream][12]. ``` var streamify = require('stream-array'); ``` The source array can contain any type as it is assumed that the receiving stream can handle it. Each element in the array will be [pushed][14] into the [piped][15] stream, **without** modifying the source array. ``` var readable = streamify(['Hello', new Buffer('World')]); ``` This [Stream][12] will [push][14] each element of the source array into the [piped][15] array. ``` readable(['1', '2', '3', os.EOL]).pipe(process.stdout); ``` ``` 123\n ``` ## Install ```sh npm install stream-array ``` [1]: https://badge.fury.io/js/stream-array.svg [2]: https://badge.fury.io/js/stream-array [3]: https://api.travis-ci.org/mimetnet/node-stream-array.svg [4]: https://travis-ci.org/mimetnet/node-stream-array [5]: https://david-dm.org/mimetnet/node-stream-array.svg [6]: https://david-dm.org/mimetnet/node-stream-array [7]: https://david-dm.org/mimetnet/node-stream-array/dev-status.svg?#info=devDependencies [8]: https://david-dm.org/mimetnet/node-stream-array/#info=devDependencies [//]: https://ci.testling.com/mimetnet/node-stream-array.png [//]: https://ci.testling.com/mimetnet/node-stream-array [11]: http://nodejs.org/api/stream.html#stream_class_stream_readable [12]: http://nodejs.org/api/stream.html#stream_stream [13]: http://nodejs.org/api/globals.html#globals_require [14]: https://nodejs.org/api/stream.html#stream_readable_push_chunk_encoding [15]: https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options [16]: https://inch-ci.org/github/mimetnet/node-stream-array.svg?branch=master [17]: http://inch-ci.org/github/mimetnet/node-stream-array ## License [MIT License](https://github.com/mimetnet/node-stream-array/blob/master/LICENSE) node-stream-array-1.1.2/index.js000066400000000000000000000021631271114623200165130ustar00rootroot00000000000000'use strict' var Readable = require('readable-stream').Readable ; /** * Create a new instance of StreamArray * * @access private * @param {Array} list */ function StreamArray(list) { if (!Array.isArray(list)) throw new TypeError('First argument must be an Array'); Readable.call(this, {objectMode:true}); this._i = 0; this._l = list.length; this._list = list; } StreamArray.prototype = Object.create(Readable.prototype, {constructor: {value: StreamArray}}); /** * Read the next item from the source Array and push into NodeJS stream * @access protected * @desc Read the next item from the source Array and push into NodeJS stream * @param {number} size The amount of data to read (ignored) */ StreamArray.prototype._read = function(size) { this.push(this._i < this._l ? this._list[this._i++] : null); }; /** * Create a new instance of StreamArray * * @module stream-array * @desc Push Array elements through a NodeJS stream * @type {function} * @param {Array} list An Array of objects, strings, numbers, etc */ module.exports = function(list) { return new StreamArray(list); }; node-stream-array-1.1.2/package.json000066400000000000000000000023431271114623200173340ustar00rootroot00000000000000{ "name": "stream-array", "version": "1.1.2", "description": "Pipe an Array through Node.js streams", "dependencies": { "readable-stream": "~2.1.0" }, "devDependencies": { "concat-stream": "~1.5.0", "tape": "~4.5.0" }, "scripts": { "test": "./node_modules/.bin/tape ./test/*", "coverage": "covert ./test/*" }, "repository": { "type": "git", "url": "https://github.com/mimetnet/node-stream-array" }, "bugs": { "url": "https://github.com/mimetnet/node-stream-array/issues" }, "homepage": "https://github.com/mimetnet/node-stream-array", "keywords": [ "array", "readable", "stream", "pipe" ], "author": "Matthew I. Metnetsky ", "license": "MIT", "main": "index.js", "directories": { "test": "test" }, "testling": { "files": "test/*.js", "browsers": [ "ie/8..latest", "firefox/3.5", "firefox/latest", "firefox/nightly", "chrome/10", "chrome/latest", "chrome/canary", "opera/12..latest", "opera/next", "safari/5.1..latest", "ipad/6.0..latest", "iphone/6.0..latest", "android-browser/4.2..latest" ] }, "engines": { "node" : ">= 0.8" } } node-stream-array-1.1.2/test/000077500000000000000000000000001271114623200160235ustar00rootroot00000000000000node-stream-array-1.1.2/test/1.js000066400000000000000000000005671271114623200165310ustar00rootroot00000000000000var test = require('tape') , streamify ; test('require', function(t) { streamify = require('..'); t.ok(streamify, 'stream-array exists'); t.equal(typeof(streamify), 'function', 'require returns an object'); t.equal(0, Object.keys(streamify).length, 'No hidden exports exports'); t.equal(1, streamify.length, 'No hidden arguments'); t.end(); }); node-stream-array-1.1.2/test/2.js000066400000000000000000000017771271114623200165360ustar00rootroot00000000000000var test = require('tape') , streamify = require('..') , concat = require('concat-stream') ; test('empty array', function(t) { var s = streamify([]); s.pipe(concat({encoding: 'object'}, function(res) { t.equal(1, arguments.length, 'concat returns 1 arg'); t.equal(0, res.length, 'result is an empty list'); t.deepEqual([], res, 'result matches expectation'); t.end(); })); }); test('array of strings', function(t) { var s = streamify(['1', '2', '3', 'Four']); s.pipe(concat(function(res) { t.equal(1, arguments.length, 'concat returns 1 arg'); t.equal('123Four', res.toString(), 'result matches expectation'); t.end(); })); }); test('array of buffers', function(t) { var s = streamify([new Buffer('One'), new Buffer('Two')]); s.pipe(concat(function(res) { t.equal(1, arguments.length, 'concat returns 1 arg'); t.equal('OneTwo', res.toString(), 'result matches expectation'); t.end(); })); }); node-stream-array-1.1.2/test/3.js000066400000000000000000000012411271114623200165210ustar00rootroot00000000000000var test = require('tape') , streamify = require('..') ; test('ctor', function(t) { t.throws(function() { streamify(); }, 'throws: no argument'); [null, undefined, 1, NaN, 'string', new Object(), function(){}].forEach( function(item) { t.throws(function() { streamify(item); }, 'throws: ' + (!item? 'null/undefined' : item.toString())); } ); [[], [1], [1,2], ['1', '2'], [new Buffer('asdf')]].forEach( function(item) { t.doesNotThrow(function() { streamify(item); }, 'accepts: ' + item.toString()); } ); t.end(); }); node-stream-array-1.1.2/test/4.js000066400000000000000000000006141271114623200165250ustar00rootroot00000000000000var test = require('tape') , streamify = require('..') , concat = require('concat-stream') ; test('immutable', function(t) { var s, a = [1, 2, 3, 4, 5]; s = streamify(a); s.pipe(concat({encoding: 'object'}, function(res) { t.equal(1, arguments.length, 'concat returns 1 arg'); t.deepEqual(a, res, 'result array matches input'); t.end(); })); });