capture-console
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -128,2 +128,47 @@ var argle = require('argle'); | ||
/** | ||
* Delegate to #capture with a quiet passthrough. | ||
* | ||
* @param stream a stream to listen on. | ||
* @param opts to set flags on the capture. | ||
* @param exec the function to call with the output. | ||
* @returns {Array} a list of stream outputs. | ||
*/ | ||
function intercept(stream, opts, exec) { | ||
return _wrapIntercept(capture, stream, opts, exec); | ||
} | ||
/** | ||
* Delegate to #captureStdio with a quiet passthrough. | ||
* | ||
* @param opts to set flags on the capture. | ||
* @param exec the function execute inside the capture. | ||
* @returns {String} | ||
*/ | ||
function interceptStdio(opts, exec) { | ||
return _wrapIntercept(captureStdio, opts, exec); | ||
} | ||
/** | ||
* Delegate to #captureStderr with a quiet passthrough. | ||
* | ||
* @param opts to set flags on the capture. | ||
* @param exec the function execute inside the capture. | ||
* @returns {String} | ||
*/ | ||
function interceptStderr(opts, exec) { | ||
return _wrapIntercept(captureStderr, opts, exec); | ||
} | ||
/** | ||
* Delegate to #captureStdout with a quiet passthrough. | ||
* | ||
* @param opts to set flags on the capture. | ||
* @param exec the function execute inside the capture. | ||
* @returns {String} | ||
*/ | ||
function interceptStdout(opts, exec) { | ||
return _wrapIntercept(captureStdout, opts, exec); | ||
} | ||
/** | ||
* Starts a capture on the provided stream using the | ||
@@ -157,2 +202,24 @@ * provided options and stream execution. | ||
/** | ||
* Delegate to #startCapture with a quiet passthrough. | ||
* | ||
* @param stream a stream to listen on. | ||
* @param opts to set flags on the capture. | ||
* @param exec the function to call with the output. | ||
* @returns {boolean} | ||
*/ | ||
function startIntercept(stream, opts, exec) { | ||
return _wrapIntercept(startCapture, stream, opts, exec); | ||
} | ||
/** | ||
* Delegate to #stopCapture with a quiet passthrough. | ||
* | ||
* @param stream a stream to stop the capture on. | ||
* @returns {boolean} | ||
*/ | ||
function stopIntercept(stream) { | ||
return stopCapture(stream); | ||
} | ||
/* Exports */ | ||
@@ -165,12 +232,10 @@ | ||
module.exports.captureStdout = captureStdout; | ||
module.exports.intercept = _wrapIntercept(capture); | ||
module.exports.interceptStdio = _wrapIntercept(captureStdio); | ||
module.exports.interceptStderr = _wrapIntercept(captureStderr); | ||
module.exports.interceptStdout = _wrapIntercept(captureStdout); | ||
module.exports.intercept = intercept; | ||
module.exports.interceptStdio = interceptStdio; | ||
module.exports.interceptStderr = interceptStderr; | ||
module.exports.interceptStdout = interceptStdout; | ||
module.exports.startCapture = startCapture; | ||
module.exports.stopCapture = stopCapture; | ||
module.exports.startIntercept = _wrapIntercept(startCapture); | ||
module.exports.stopIntercept = function stopIntercept(stream) { | ||
return stopCapture(stream); | ||
}; | ||
module.exports.startIntercept = startIntercept; | ||
module.exports.stopIntercept = stopIntercept; | ||
@@ -213,24 +278,21 @@ /* Private */ | ||
* | ||
* @param func the function to wrap. | ||
* @returns {Function} | ||
* @param func the function to delegate to. | ||
* @param stream a stream to listen on. | ||
* @param opts to set flags on the capture. | ||
* @param exec the function to call with the output. | ||
* @returns {*} | ||
* @private | ||
*/ | ||
function _wrapIntercept(func) { | ||
var interceptor = function intercept(stream, opts, exec) { | ||
var idex = Number(arguments.length > 2); | ||
var args = _shift(arguments[idex], arguments[idex + 1]); | ||
function _wrapIntercept(func, stream, opts, exec) { | ||
var idex = Number(arguments.length > 3); | ||
var args = _shift(arguments[idex + 1], arguments[idex + 2]); | ||
opts = args[0]; | ||
exec = args[1]; | ||
opts = args[0]; | ||
exec = args[1]; | ||
opts.quiet = true; | ||
opts.quiet = true; | ||
return idex | ||
? func(stream, opts, exec) | ||
: func(opts, exec); | ||
}; | ||
interceptor.name = func.name | ||
.replace('capture', 'intercept') | ||
.replace('Capture', 'Intercept'); | ||
return interceptor; | ||
return idex | ||
? func(stream, opts, exec) | ||
: func(opts, exec); | ||
} |
{ | ||
"name": "capture-console", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Simple and easy stdio capture for Node.js", | ||
@@ -5,0 +5,0 @@ "author": { |
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
12037
254