stream-from-array
Advanced tools
Comparing version 0.1.0 to 1.0.0
62
index.js
'use strict'; | ||
var Readable = require('stream').Readable, | ||
inherits = require('util').inherits; | ||
var Readable = require('stream').Readable; | ||
var inherits = require('util').inherits; | ||
function StreamFromArray(array, options) { | ||
if (!(this instanceof StreamFromArray)) { | ||
return new StreamFromArray(array, options); | ||
} | ||
if (!(this instanceof StreamFromArray)) { | ||
return new StreamFromArray(array, options); | ||
} | ||
Readable.call(this, options); | ||
Readable.call(this, options); | ||
this.__array = array; | ||
this.__index = 0; | ||
this.__array = array; | ||
this.__index = 0; | ||
} | ||
inherits(StreamFromArray, Readable); | ||
StreamFromArray.obj = function(array, options) { | ||
options = options || {}; | ||
options.objectMode = true; | ||
return new StreamFromArray(array, options); | ||
StreamFromArray.obj = function (array, options) { | ||
options = options || {}; | ||
options.objectMode = true; | ||
return new StreamFromArray(array, options); | ||
}; | ||
StreamFromArray.prototype._read = function() { | ||
var needMoreData, | ||
value; | ||
while (this.__index < this.__array.length && needMoreData !== false) { | ||
value = this.__array[this.__index++]; | ||
needMoreData = this.push(value); | ||
if (typeof value === 'undefined' || value === null) { | ||
// value signaled end of data | ||
this.__index = this.__array.length; | ||
} else if (this.__index === this.__array.length) { | ||
// end of data | ||
this.push(null); | ||
} | ||
} | ||
StreamFromArray.prototype._read = function () { | ||
var needMoreData; | ||
var value; | ||
if (this.__array.length === 0) { | ||
// end of data | ||
this.push(null); | ||
return; | ||
} | ||
while (this.__index < this.__array.length && needMoreData !== false) { | ||
value = this.__array[this.__index++]; | ||
needMoreData = this.push(value); | ||
if (value === null) { | ||
// value signaled end of data | ||
this.__index = this.__array.length; | ||
} else if (this.__index === this.__array.length) { | ||
// end of data | ||
this.push(null); | ||
} | ||
} | ||
}; | ||
module.exports = StreamFromArray; |
{ | ||
"name": "stream-from-array", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Create streams from arrays of arbitrary Javascript values like strings, functions, arrays, etc.", | ||
@@ -25,19 +25,21 @@ "repository": { | ||
"engines": { | ||
"node": "^0.11 || ^0.10" | ||
"node": ">=0.10.0" | ||
}, | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"test": "./node_modules/gulp/bin/gulp.js && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
"test": "xo && nyc ava --verbose --timeout=10s" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.1", | ||
"gulp": "^3.8.6", | ||
"gulp-istanbul": "^0.2.0", | ||
"gulp-jscs": "^0.6.0", | ||
"gulp-jshint": "^1.7.1", | ||
"gulp-mocha": "^0.5.0", | ||
"merge-stream": "^0.1.5", | ||
"stream-recorder": "^0.3.0", | ||
"vinyl": "^0.2.3" | ||
"ava": "^0.14.0", | ||
"coveralls": "^2.11.6", | ||
"gulp": "^3.9.1", | ||
"merge-stream": "^1.0.0", | ||
"nyc": "^6.4.4", | ||
"stream-recorder": "^0.3.3", | ||
"vinyl": "^1.1.1", | ||
"xo": "^0.15.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8
0
3208
3
38
1
0
1