Socket
Socket
Sign inDemoInstall

pause

Package Overview
Dependencies
0
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.1.0

HISTORY.md

70

index.js

@@ -0,29 +1,61 @@

/*!
* pause
* Copyright(c) 2012 TJ Holowaychuk
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
module.exports = function(obj){
var onData
, onEnd
, events = [];
'use strict'
/**
* Module exports.
* @public
*/
module.exports = pause
/**
* Pause the data events on a stream.
*
* @param {object} stream
* @public
*/
function pause(stream) {
var events = []
var onData = createEventListener('data', events)
var onEnd = createEventListener('end', events)
// buffer data
obj.on('data', onData = function(data, encoding){
events.push(['data', data, encoding]);
});
stream.on('data', onData)
// buffer end
obj.on('end', onEnd = function(data, encoding){
events.push(['end', data, encoding]);
});
stream.on('end', onEnd)
return {
end: function(){
obj.removeListener('data', onData);
obj.removeListener('end', onEnd);
end: function end() {
stream.removeListener('data', onData)
stream.removeListener('end', onEnd)
},
resume: function(){
this.end();
for (var i = 0, len = events.length; i < len; ++i) {
obj.emit.apply(obj, events[i]);
resume: function resume() {
this.end()
for (var i = 0; i < events.length; i++) {
stream.emit.apply(stream, events[i])
}
}
};
};
}
}
function createEventListener(name, events) {
return function onEvent() {
var args = new Array(arguments.length + 1)
args[0] = name
for (var i = 0; i < arguments.length; i++) {
args[i + 1] = arguments[i]
}
events.push(args)
}
}
{
"name": "pause",
"version": "0.0.1",
"description": "Pause streams...",
"keywords": [],
"description": "Pause a stream's data events",
"version": "0.1.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"dependencies": {},
"contributors": [
"Douglas Christopher Wilson <doug@somethingdoug.com>"
],
"license": "MIT",
"repository": "stream-utils/pause",
"devDependencies": {
"mocha": "*",
"should": "*"
"after": "0.8.1",
"istanbul": "0.3.17",
"mocha": "1.21.5"
},
"main": "index"
}
"files": [
"HISTORY.md",
"LICENSE",
"README.md",
"index.js"
],
"engines": {
"node": ">= 0.6"
},
"scripts": {
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc