streamfilter
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "streamfilter", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Filtering streams.", | ||
@@ -29,8 +29,8 @@ "main": "src/index.js", | ||
"istanbul": "^0.3.5", | ||
"mocha": "^2.1.0" | ||
"mocha": "^2.1.0", | ||
"streamtest": "^1.0.0" | ||
}, | ||
"dependencies": { | ||
"readable-stream": "^1.0.33", | ||
"streamtest": "^1.0.0" | ||
"readable-stream": "^1.0.33" | ||
} | ||
} |
@@ -24,3 +24,3 @@ var stream = require('readable-stream'); | ||
this._restoreStreamCallback = null; | ||
this._transform = function(chunk, encoding, done) { | ||
@@ -70,2 +70,1 @@ filterCallback(chunk, encoding, function StreamFilterCallback(filter) { | ||
module.exports = StreamFilter; | ||
var assert = require('assert'); | ||
var Stream = require('stream'); | ||
var StreamTest = require('streamtest'); | ||
@@ -16,3 +17,3 @@ var StreamFilter = require('../src/index'); | ||
}); | ||
// Iterating through versions | ||
@@ -77,3 +78,3 @@ StreamTest.versions.forEach(function(version) { | ||
it('with restore and passthrough option', function(done) { | ||
it('with restore and passthrough option in a differrent pipeline', function(done) { | ||
var inputStream = StreamTest[version].fromObjects([object1, object2]); | ||
@@ -108,2 +109,35 @@ var filter = new StreamFilter(function(chunk, encoding, cb) { | ||
it('with restore and passthrough option in the same pipeline', function(done) { | ||
var passThroughStreamEnded = false; | ||
var inputStream = StreamTest[version].fromObjects([object1, object2]); | ||
var filter = new StreamFilter(function(chunk, encoding, cb) { | ||
if(chunk === object2) { | ||
return cb(true); | ||
} | ||
return cb(false); | ||
}, { | ||
objectMode: true, | ||
restore: true, | ||
passthrough: true | ||
}); | ||
var outputStream = StreamTest[version].toObjects(function(err, objs) { | ||
if(err) { | ||
return done(err); | ||
} | ||
assert.deepEqual(objs, [object1, object2]); | ||
done(); | ||
}); | ||
inputStream.pipe(filter) | ||
.pipe(new Stream.PassThrough({ objectMode: true })) | ||
.on('end', function() { | ||
passThroughStreamEnded = true; | ||
}) | ||
.pipe(filter.restore) | ||
.on('end', function() { | ||
assert(passThroughStreamEnded, | ||
'PassThrough stream ends before the restore one.'); | ||
}) | ||
.pipe(outputStream); | ||
}); | ||
}); | ||
@@ -202,2 +236,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
15878
1
263
4
- Removedstreamtest@^1.0.0
- Removedisarray@1.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstreamtest@1.2.4(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)