object-stream-tools
Advanced tools
Comparing version 1.0.0 to 1.1.0
37
index.js
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
const stream = require('stream'); | ||
@@ -5,16 +7,17 @@ const through2Concurrent = require('through2-concurrent'); | ||
'use strict'; | ||
function thru(transform, flush) { | ||
return new stream.Transform({ | ||
objectMode: true, | ||
transform: (obj, enc, cb) => transform(obj, cb), | ||
flush | ||
}); | ||
} | ||
const thru = (transform, flush) => new stream.Transform({ | ||
objectMode: true, | ||
transform, | ||
flush | ||
}); | ||
function thruParallel(maxConcurrency, transform, flush) { | ||
return through2Concurrent.obj({ maxConcurrency }, | ||
(obj, enc, cb) => transform(obj, cb), flush | ||
); | ||
} | ||
const thruParallel = (transform, maxConcurrency) => | ||
thruConcurrent.obj({ maxConcurrency }, transform); | ||
const devNull = require('fs').createWriteStream('/dev/null'); | ||
const arrayToStream = (data) => { | ||
function arrayToStream(data) { | ||
const newStream = new stream.Readable({ objectMode: true }); | ||
@@ -26,3 +29,3 @@ data.forEach(item => newStream.push(item)); | ||
const streamToSet = (stream) => { | ||
function streamToSet(stream) { | ||
return new Promise((resolve, reject) => { | ||
@@ -37,3 +40,3 @@ const set = new Set(); | ||
const newReadable = () => { | ||
function newReadable() { | ||
const rs = new stream.Readable({ objectMode: true }); | ||
@@ -66,10 +69,4 @@ rs._read = () => {}; | ||
}; | ||
module.exports = { | ||
thru, | ||
Stream, | ||
devNull, | ||
thruConcurrent, | ||
thruParallel, | ||
@@ -76,0 +73,0 @@ arrayToStream, |
{ | ||
"name": "object-stream-tools", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Useful tools for manipulating object streams. Will be especially helpful to developers used to map - filter - reduce approach of nodejs arrays.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node_modules/tap/bin/run.js test/test.js" | ||
}, | ||
@@ -30,3 +30,11 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/kichooo/object-stream-tools#readme" | ||
"homepage": "https://github.com/kichooo/object-stream-tools#readme", | ||
"devDependencies": { | ||
"JSONStream": "^1.1.1", | ||
"tap": "^5.7.2" | ||
}, | ||
"dependencies": { | ||
"stream-to-array": "^2.3.0", | ||
"through2-concurrent": "^1.1.1" | ||
} | ||
} |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
7649
8
153
0
2
2
+ Addedstream-to-array@^2.3.0
+ Addedthrough2-concurrent@^1.1.1
+ Addedany-promise@1.3.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstream-to-array@2.3.0(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedthrough2@2.0.5(transitive)
+ Addedthrough2-concurrent@1.1.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)