Socket
Socket
Sign inDemoInstall

interruptor

Package Overview
Dependencies
2
Maintainers
31
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    interruptor

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


Version published
Weekly downloads
27K
decreased by-12.61%
Maintainers
31
Created
Weekly downloads
 

Readme

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).

Keywords

FAQs

Last updated on 15 Jan 2021

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