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

stdout-stderr

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stdout-stderr

mock stdout and stderr

  • 0.1.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
231K
increased by21.67%
Maintainers
1
Weekly downloads
 
Created

What is stdout-stderr?

The stdout-stderr npm package is a utility for capturing and manipulating the standard output (stdout) and standard error (stderr) streams in Node.js applications. It is particularly useful for testing and debugging purposes, allowing developers to intercept and inspect the output of their code.

What are stdout-stderr's main functionalities?

Capture stdout

This feature allows you to capture the standard output (stdout) stream. The code sample demonstrates how to start capturing stdout, print a message, stop capturing, and then inspect the captured output.

const stdio = require('stdout-stderr');

stdio.stdout.start();
console.log('Hello, World!');
stdio.stdout.stop();
console.log(stdio.stdout.output); // ['Hello, World!\n']

Capture stderr

This feature allows you to capture the standard error (stderr) stream. The code sample demonstrates how to start capturing stderr, print an error message, stop capturing, and then inspect the captured output.

const stdio = require('stdout-stderr');

stdio.stderr.start();
console.error('An error occurred!');
stdio.stderr.stop();
console.log(stdio.stderr.output); // ['An error occurred!\n']

Combined stdout and stderr capture

This feature allows you to capture both stdout and stderr streams simultaneously. The code sample demonstrates how to start capturing both streams, print messages to both stdout and stderr, stop capturing, and then inspect the combined output.

const stdio = require('stdout-stderr');

stdio.start();
console.log('Hello, World!');
console.error('An error occurred!');
stdio.stop();
console.log(stdio.output); // ['Hello, World!\n', 'An error occurred!\n']

Suppress output

This feature allows you to suppress the output to stdout or stderr. The code sample demonstrates how to suppress stdout, print a message that will not be shown, restore stdout, and then print a message that will be shown.

const stdio = require('stdout-stderr');

stdio.stdout.suppress();
console.log('This will not be shown');
stdio.stdout.restore();
console.log('This will be shown');

Other packages similar to stdout-stderr

Keywords

FAQs

Package last updated on 09 Feb 2020

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