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

interruptor

Package Overview
Dependencies
Maintainers
33
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interruptor

Run a function with the possibility to interrupt it from another thread

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42K
increased by32.04%
Maintainers
33
Weekly downloads
 
Created
Source

interruptor – Run a function with the possibility to interrupt it from another thread

Usage Example

import { runInterruptible, interrupt } from 'interruptor';
runInterruptible(handle => {
  // pass handle to another thread using .postMessage();

  while(true);
});

// In another thread:
interrupt(handle);

Caveats

This is a native addon, and currently no pre-built binaries are available.

This only interrupts synchronous execution inside the callback, not async functions (although the microtaskMode option for the vm module in Node.js 14 and above can help with Promises here).

This will not fully interrupt the running code, and not run any catch or finally blocks. In particular, if a module is being loaded at the time of interruption, the incomplete module may remain in the module loader cache.

Keywords

FAQs

Package last updated on 13 May 2024

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