stream-array
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,12 +0,6 @@ | ||
var Readable = require('stream').Readable | ||
var Readable = require('readable-stream').Readable | ||
, Queue = require('fastqueue') | ||
; | ||
if (!Readable) { | ||
Readable = require('readable-stream/readable'); | ||
} | ||
function StreamArray(list) { | ||
if (!(this instanceof(StreamArray))) | ||
return new StreamArray(list); | ||
if (!Array.isArray(list)) | ||
@@ -13,0 +7,0 @@ throw new TypeError('First argument must be an Array'); |
{ | ||
"name": "stream-array", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Pipe an Array through Node.js streams", | ||
@@ -10,7 +10,8 @@ "dependencies": { | ||
"devDependencies": { | ||
"tap": "~0.4.0", | ||
"concat-stream": "~1.4.0" | ||
"concat-stream": "~1.4.6", | ||
"tape": "~3.0.2" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/tap ./test/" | ||
"test": "./node_modules/.bin/tape ./test/*", | ||
"coverage": "covert ./test/*" | ||
}, | ||
@@ -25,2 +26,3 @@ "repository": { | ||
"keywords": [ | ||
"array", | ||
"readable", | ||
@@ -41,2 +43,20 @@ "stream", | ||
}, | ||
"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": [ | ||
@@ -43,0 +63,0 @@ "node >= 0.8.0" |
@@ -6,5 +6,7 @@ # stream-array | ||
[![build status][1]][2] [![npm version][3]][4] [![dependencies][5]][6] [![devDependencies][7]][8] | ||
[![npm version][1]][2] [![build status][3]][4] [![dependencies][5]][6] [![devDependencies][7]][8] | ||
[//]: [![testling][9]][10] | ||
## Usage | ||
@@ -23,6 +25,24 @@ | ||
#### streamify(Array) | ||
Provide an Array to streamify which will be iterated over. Each element will | ||
dequeued and pushed into the following piped stream. | ||
The result of [require][13] is a 'function' that when invoked, will return a [Readable][11] [Stream][12]. | ||
``` | ||
var streamify = require('stream-array'); | ||
``` | ||
The Array passed into stream-array() can contain any type, as it assumes the receiving stream can handle it. Each element will be dequeued and pushed into the following piped stream. | ||
``` | ||
var readable = streamify(['Hello', new Buffer('World')]); | ||
``` | ||
This [Stream][12] will emit each element of the source array as chunks. | ||
``` | ||
readable(['1', '2', '3', os.EOL]).pipe(process.stdout); | ||
``` | ||
``` | ||
123\n | ||
``` | ||
## Install | ||
@@ -34,10 +54,18 @@ | ||
[1]: https://api.travis-ci.org/mimetnet/node-stream-array.png | ||
[2]: https://travis-ci.org/mimetnet/node-stream-array | ||
[3]: https://badge.fury.io/js/stream-array.png | ||
[4]: https://badge.fury.io/js/stream-array | ||
[5]: https://david-dm.org/mimetnet/node-stream-array.png | ||
[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.png?#info=devDependencies | ||
[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 | ||
## License | ||
[MIT License](https://github.com/mimetnet/node-stream-array/blob/master/LICENSE) |
@@ -1,2 +0,2 @@ | ||
var test = require('tap').test | ||
var test = require('tape') | ||
, Queue = require('fastqueue') | ||
@@ -9,7 +9,7 @@ ; | ||
*/ | ||
test('require', function(t) { | ||
test('fastqueue', function(t) { | ||
var q; | ||
t.ok(Queue, 'fastqueue exists'); | ||
t.type(Queue, 'function', 'require returns an object'); | ||
t.equal(typeof(Queue), 'function', 'require returns an object'); | ||
t.equal(0, Object.keys(Queue).length, 'No hidden exports'); | ||
@@ -19,4 +19,4 @@ | ||
t.type(q, 'object', 'new Queue() returns an object'); | ||
t.type(q.length, 'number', 'q.length'); | ||
t.equal(typeof(q), 'object', 'new Queue() returns an object'); | ||
t.equal(typeof(q.length), 'number', 'q.length'); | ||
@@ -23,0 +23,0 @@ t.ok(Array.isArray(q.head), 'q.head = []'); |
@@ -1,3 +0,2 @@ | ||
var tap = require('tap') | ||
, test = tap.test | ||
var test = require('tape') | ||
, streamify | ||
@@ -10,3 +9,3 @@ ; | ||
t.ok(streamify, 'stream-array exists'); | ||
t.type(streamify, 'function', 'require returns an object'); | ||
t.equal(typeof(streamify), 'function', 'require returns an object'); | ||
t.equal(0, Object.keys(streamify).length, 'No hidden exports exports'); | ||
@@ -13,0 +12,0 @@ t.equal(1, streamify.length, 'No hidden arguments'); |
@@ -1,3 +0,2 @@ | ||
var tap = require('tap') | ||
, test = tap.test | ||
var test = require('tape') | ||
, streamify = require('..') | ||
@@ -4,0 +3,0 @@ , concat = require('concat-stream') |
@@ -1,3 +0,2 @@ | ||
var tap = require('tap') | ||
, test = tap.test | ||
var test = require('tape') | ||
, streamify = require('..') | ||
@@ -9,9 +8,21 @@ ; | ||
streamify(); | ||
}, {name:'TypeError', message:'First argument must be an Array'}, 'Throws TypeError'); | ||
}, 'throws: no argument'); | ||
t.doesNotThrow(function() { | ||
streamify([]); | ||
}, 'Valid argument'); | ||
[null, undefined, 1, '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(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7934
105
69