Socket
Socket
Sign inDemoInstall

set-blocking

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-blocking

set blocking stdio and stderr ensuring that terminal output does not truncate


Version published
Maintainers
1
Weekly downloads
24,969,961
increased by1.43%
Install size
4.87 kB

Weekly downloads

Package description

What is set-blocking?

The set-blocking npm package is primarily used to control the blocking behavior of streams in Node.js. This can be particularly useful in scenarios where you need to ensure that stdout or stderr is fully drained before your process exits, especially in the context of CLI applications. The package provides a straightforward API to toggle the blocking behavior of these streams.

What are set-blocking's main functionalities?

Setting stream blocking

This code enables blocking on stdout and stderr, ensuring that all output is flushed to these streams before the process exits. This is particularly useful for CLI tools that output to the terminal and need to ensure that all output is displayed to the user before the process terminates.

require('set-blocking')(true);

Other packages similar to set-blocking

Readme

Source

set-blocking

Build Status NPM version Coverage Status Standard Version

set blocking stdio and stderr ensuring that terminal output does not truncate.

const setBlocking = require('set-blocking')
setBlocking(true)
console.log(someLargeStringToOutput)

Historical Context/Word of Warning

This was created as a shim to address the bug discussed in node #6456. This bug crops up on newer versions of Node.js (0.12+), truncating terminal output.

You should be mindful of the side-effects caused by using set-blocking:

  • if your module sets blocking to true, it will effect other modules consuming your library. In yargs we only call setBlocking(true) once we already know we are about to call process.exit(code).
  • this patch will not apply to subprocesses spawned with isTTY = true, this is the default spawn() behavior.

License

ISC

Keywords

FAQs

Last updated on 17 May 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc