interruptor
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

/interruptor/

    Package Sidebar

    Install

    npm i interruptor

    Weekly Downloads

    30,484

    Version

    1.0.1

    License

    Apache-2.0

    Unpacked Size

    24 kB

    Total Files

    14

    Last publish

    Collaborators

    • orechova
    • himanshusinghs
    • c-buckingham
    • mongo-j
    • mabaasit
    • alexander_schroll
    • chuck.kalmanek
    • mongodb-js-user
    • rueckstiess
    • durran
    • lerouxb
    • fredtruman
    • mbroadst
    • hswolff
    • satyasinha
    • matt_d_rat
    • rhysm
    • tomhollander
    • alena.khineika
    • jeff-allen-mongo
    • mmarcon
    • jonathan.balsano
    • mongodb-build
    • jack.weir
    • stennie
    • mcasimir
    • kristina.stefano
    • jarjee
    • shaketbaby
    • devtoolsbot
    • addaleax
    • gribnoysup
    • mutukrish