Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hook-std

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hook-std

Hook and modify stdout/stderr

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
787K
decreased by-42.82%
Maintainers
1
Weekly downloads
 
Created

What is hook-std?

The hook-std npm package allows you to hook into and modify the standard output (stdout) and standard error (stderr) streams in Node.js. This can be useful for capturing logs, testing console output, or redirecting output for various purposes.

What are hook-std's main functionalities?

Capture stdout

This feature allows you to capture and manipulate the standard output (stdout) stream. The code sample demonstrates how to capture console.log output and process it.

const hookStd = require('hook-std');

(async () => {
  const unhook = hookStd.stdout({silent: true}, output => {
    console.log('Captured output:', output);
  });

  console.log('This will be captured');

  await unhook();
})();

Capture stderr

This feature allows you to capture and manipulate the standard error (stderr) stream. The code sample demonstrates how to capture console.error output and process it.

const hookStd = require('hook-std');

(async () => {
  const unhook = hookStd.stderr({silent: true}, output => {
    console.error('Captured error:', output);
  });

  console.error('This error will be captured');

  await unhook();
})();

Modify stdout

This feature allows you to modify the standard output (stdout) stream before it is printed to the console. The code sample demonstrates how to prepend a string to the console.log output.

const hookStd = require('hook-std');

(async () => {
  const unhook = hookStd.stdout(output => {
    return 'Modified output: ' + output;
  });

  console.log('This will be modified');

  await unhook();
})();

Modify stderr

This feature allows you to modify the standard error (stderr) stream before it is printed to the console. The code sample demonstrates how to prepend a string to the console.error output.

const hookStd = require('hook-std');

(async () => {
  const unhook = hookStd.stderr(output => {
    return 'Modified error: ' + output;
  });

  console.error('This error will be modified');

  await unhook();
})();

Other packages similar to hook-std

Keywords

FAQs

Package last updated on 10 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc