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

blocked

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blocked

check if the event loop is blocked

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59K
decreased by-5.9%
Maintainers
3
Weekly downloads
 
Created
Source

blocked

Check if a node event loop is blocked.

If You're running Node.js 8+ you can get a stacktrace pointing to the blocking function using very similar blocked-at package.

Installation

$ npm install blocked

Description

The blocked() function reports every value over the configured threshold (defaulted to 10ms). You can then do whatever you want with that value, graph it, log it, alert, etc.

The process won't be kept open through this.

Params and return value

var timer = blocked(fn, options);
  • fn: The callback function to execute when the event loop is blocked. Will send in the amount of time in ms that the event loop was blocked.
  • options: Optional. Options object to configure the behaviour.
    • threshold determines the amount of ms used to determine if the function callback should be executed; useful to speed up tests.
    • interval determines the frequency with which the event loop is checked in ms.
blocked(function(ms) {
    console.log("Blocked");
}, {threshold:1, interval: 1000});

Returns: A reference to the timer. Useful for clearing the timer.

var timer = blocked(function(ms) {
                console.log("Blocked");
            });
clearInterval(timer);

License

MIT

Keywords

FAQs

Package last updated on 25 Oct 2019

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