through2
Advanced tools
Comparing version 0.2.3 to 0.3.0
{ | ||
"name": "through2", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise", | ||
"main": "through2.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "node test/test.js", | ||
"test-local": "brtapsauce-local test/basic-test.js" | ||
}, | ||
@@ -22,10 +23,11 @@ "repository": { | ||
"dependencies": { | ||
"readable-stream": "~1.1.9", | ||
"readable-stream": "~1.0.17", | ||
"xtend": "~2.1.1" | ||
}, | ||
"devDependencies": { | ||
"tape": "~1.1.1", | ||
"bl": "~0.4.1", | ||
"stream-spigot": "~2.1.2" | ||
"tape": "~2.3.0", | ||
"bl": "~0.6.0", | ||
"stream-spigot": "~3.0.1", | ||
"brtapsauce": "~0.2.2" | ||
} | ||
} |
@@ -5,6 +5,12 @@ # through2 | ||
[![Build Status](https://saucelabs.com/browser-matrix/through2-sauce.svg)](https://travis-ci.org/rvagg/through2) | ||
[![NPM](https://nodei.co/npm/through2.png?compact=true)](https://nodei.co/npm/through2/) | ||
<!-- | ||
not happy with these, we need to peg to readable-stream@1.0.x so it'll always report out-of-date | ||
[![david-dm](https://david-dm.org/rvagg/through2.png)](https://david-dm.org/rvagg/through2/) | ||
[![david-dm](https://david-dm.org/rvagg/through2/dev-status.png)](https://david-dm.org/rvagg/through2#info=devDependencies/) | ||
--> | ||
@@ -11,0 +17,0 @@ **A tiny wrapper around Node streams.Transform (Streams2) to avoid explicit subclassing noise** |
@@ -1,5 +0,7 @@ | ||
const Transform = require('stream').Transform || require('readable-stream/transform') | ||
const Transform = require('readable-stream/transform') | ||
, inherits = require('util').inherits | ||
, xtend = require('xtend') | ||
// a noop _transform funciton | ||
function noop (chunk, enc, callback) { | ||
@@ -9,12 +11,40 @@ callback(null, chunk) | ||
function ctor (options, transform, flush) { | ||
if (typeof options == 'function') { | ||
flush = transform | ||
transform = options | ||
options = {} | ||
// create a new export function, used by both the main export and | ||
// the .ctor export, contains common logic for dealing with arguments | ||
function through2 (construct) { | ||
return function (options, transform, flush) { | ||
if (typeof options == 'function') { | ||
flush = transform | ||
transform = options | ||
options = {} | ||
} | ||
if (typeof transform != 'function') | ||
transform = noop | ||
if (typeof flush != 'function') | ||
flush = null | ||
return construct(options, transform, flush) | ||
} | ||
} | ||
if (typeof transform != 'function') | ||
transform = noop | ||
// main export, just make me a transform stream! | ||
module.exports = through2(function (options, transform, flush) { | ||
var t2 = new Transform(options) | ||
t2._transform = transform | ||
if (flush) | ||
t2._flush = flush | ||
return t2 | ||
}) | ||
// make me a reusable prototype that I can `new`, or implicitly `new` | ||
// with a constructor call | ||
module.exports.ctor = through2(function (options, transform, flush) { | ||
function Through2 (override) { | ||
@@ -25,2 +55,3 @@ if (!(this instanceof Through2)) | ||
this.options = xtend(options, override) | ||
Transform.call(this, this.options) | ||
@@ -33,13 +64,6 @@ } | ||
if (typeof flush == 'function') | ||
if (flush) | ||
Through2.prototype._flush = flush | ||
return Through2 | ||
} | ||
function make (options, transform, flush) { | ||
return ctor(options, transform, flush)() | ||
} | ||
module.exports = make | ||
module.exports.ctor = ctor | ||
}) |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
20599
12
376
113
4
4
1
+ Addedreadable-stream@1.0.34(transitive)
- Removedreadable-stream@1.1.14(transitive)
Updatedreadable-stream@~1.0.17