Socket
Socket
Sign inDemoInstall

hook-std

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

index.d.ts

30

index.js
'use strict';
const hook = (stream, opts, transform) => {
if (typeof opts !== 'object') {
transform = opts;
opts = {};
const hook = (stream, options, transform) => {
if (typeof options !== 'object') {
transform = options;
options = {};
}
opts = Object.assign({
options = Object.assign({
silent: true,
once: false
}, opts);
}, options);

@@ -27,7 +27,7 @@ let unhookFn;

if (opts.once) {
if (options.once) {
unhook();
}
if (opts.silent) {
if (options.silent) {
return typeof cbRet === 'boolean' ? cbRet : true;

@@ -37,3 +37,2 @@ }

let ret;
if (typeof cbRet === 'string') {

@@ -56,5 +55,5 @@ ret = typeof enc === 'string' ? Buffer.from(cbRet).toString(enc) : cbRet;

module.exports = (opts, transform) => {
const streams = opts.streams || [process.stdout, process.stderr];
const streamPromises = streams.map(stream => hook(stream, opts, transform));
const hookStd = (options, transform) => {
const streams = options.streams || [process.stdout, process.stderr];
const streamPromises = streams.map(stream => hook(stream, options, transform));

@@ -71,3 +70,6 @@ const promise = Promise.all(streamPromises);

module.exports.stdout = (...args) => hook(process.stdout, ...args);
module.exports.stderr = (...args) => hook(process.stderr, ...args);
hookStd.stdout = (...args) => hook(process.stdout, ...args);
hookStd.stderr = (...args) => hook(process.stderr, ...args);
module.exports = hookStd;
module.exports.default = hookStd;
{
"name": "hook-std",
"version": "1.1.0",
"version": "1.2.0",
"description": "Hook and modify stdout/stderr",

@@ -16,6 +16,7 @@ "license": "MIT",

"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd-check"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],

@@ -40,5 +41,7 @@ "keywords": [

"devDependencies": {
"ava": "*",
"xo": "*"
"@types/node": "^10.12.9",
"ava": "^0.25.0",
"tsd-check": "^0.2.1",
"xo": "^0.23.0"
}
}

@@ -63,2 +63,4 @@ # hook-std [![Build Status](https://travis-ci.org/sindresorhus/hook-std.svg?branch=master)](https://travis-ci.org/sindresorhus/hook-std)

Type: `Object`
##### silent

@@ -78,8 +80,2 @@

#### transform
Type: `Function`
Receives stdout/stderr as the first argument and the unhook method as the second argument. Return a string to modify it. Optionally, when in silent mode, you may return a `boolean` to influence the return value of `.write(...)`.
##### streams

@@ -92,5 +88,11 @@

#### transform
Type: `Function`
Receives stdout/stderr as the first argument and the unhook method as the second argument. Return a string to modify it. Optionally, when in silent mode, you may return a `boolean` to influence the return value of `.write(...)`.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
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