Comparing version 4.0.1 to 4.1.0
@@ -5,2 +5,7 @@ <!--remark setext--> | ||
4.1.0 / 2016-06-11 | ||
================== | ||
* Update to inline `pipe`, slimming down bundled size ([`712474f`](https://github.com/wooorm/unified/commit/712474f)) | ||
4.0.1 / 2016-05-24 | ||
@@ -7,0 +12,0 @@ ================== |
@@ -18,3 +18,3 @@ /** | ||
var events = require('events'); | ||
var originalPipe = require('stream').Stream.prototype.pipe; | ||
var once = require('once'); | ||
var extend = require('extend'); | ||
@@ -147,8 +147,2 @@ var bail = require('bail'); | ||
/* | ||
* Initialise events. | ||
*/ | ||
events.init.call(processor); | ||
/* | ||
* Mix in methods. | ||
@@ -158,5 +152,3 @@ */ | ||
for (key in emitter) { | ||
if (isFunction(emitter[key])) { | ||
processor[key] = emitter[key]; | ||
} | ||
processor[key] = emitter[key]; | ||
} | ||
@@ -556,2 +548,3 @@ | ||
processor.emit('data', file.contents); | ||
processor.emit('end'); | ||
} else { | ||
@@ -571,5 +564,7 @@ // Don’t enter an infinite error throwing loop. | ||
* | ||
* Aside from setting options, all arguments | ||
* are passed to `Stream#pipe`. | ||
* Basically `Stream#pipe`, but inlined and | ||
* simplified to keep the bundled size down. | ||
* | ||
* @see https://github.com/nodejs/node/blob/master/lib/stream.js#L26 | ||
* | ||
* @param {Stream} dest - Writable stream. | ||
@@ -581,7 +576,68 @@ * @param {Object?} [options] - Processing | ||
function pipe(dest, options) { | ||
var onend = once(function () { | ||
dest.end(); | ||
}); | ||
assertConcrete('pipe'); | ||
settings = options; | ||
settings = options || {}; | ||
return originalPipe.apply(this, arguments); | ||
/** | ||
* Handle data. | ||
* | ||
* @param {*} chunk - Data to pass through. | ||
*/ | ||
function ondata(chunk) { | ||
if (dest.writable) { | ||
dest.write(chunk); | ||
} | ||
} | ||
/** | ||
* Clean listeners. | ||
*/ | ||
function cleanup() { | ||
processor.removeListener('data', ondata); | ||
processor.removeListener('end', onend); | ||
processor.removeListener('error', onerror); | ||
processor.removeListener('end', cleanup); | ||
processor.removeListener('close', cleanup); | ||
dest.removeListener('error', onerror); | ||
dest.removeListener('close', cleanup); | ||
} | ||
/** | ||
* Close dangling pipes and handle unheard errors. | ||
* | ||
* @param {Error} err - Exception. | ||
*/ | ||
function onerror(err) { | ||
var handlers = processor._events.error; | ||
cleanup(); | ||
// can’t use `listenerCount` in node <= 0.12. | ||
if (!handlers || !handlers.length || handlers === onerror) { | ||
throw err; // Unhandled stream error in pipe. | ||
} | ||
} | ||
processor.on('data', ondata); | ||
processor.on('error', onerror); | ||
processor.on('end', cleanup); | ||
processor.on('close', cleanup); | ||
// If the 'end' option is not supplied, dest.end() will be called when | ||
// the 'end' or 'close' events are received. Only dest.end() once. | ||
if (!dest._isStdio && settings.end !== false) { | ||
processor.on('end', onend); | ||
} | ||
dest.on('error', onerror); | ||
dest.on('close', cleanup); | ||
dest.emit('pipe', processor); | ||
return dest; | ||
} | ||
@@ -588,0 +644,0 @@ |
{ | ||
"name": "unified", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Pluggable text processing interface", | ||
@@ -19,2 +19,3 @@ "license": "MIT", | ||
"extend": "^3.0.0", | ||
"once": "^1.3.3", | ||
"vfile": "^1.0.0" | ||
@@ -52,3 +53,3 @@ }, | ||
"remark-github": "^4.0.1", | ||
"remark-lint": "^3.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-toc": "^3.0.0", | ||
@@ -55,0 +56,0 @@ "remark-validate-links": "^3.0.0", |
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
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
45269
738
0
4
+ Addedonce@^1.3.3
+ Addedonce@1.4.0(transitive)
+ Addedwrappy@1.0.2(transitive)