npm.io
1.0.2 • Published 4 years ago

tiny-set-immediate

Licence
MIT
Version
1.0.2
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
3

tiny-set-immediate

A minimal polyfill of setImmediate, for modern browsers using window.postMessage, and MessageChannel in workers.

If the native functions are available they will be returned instead of a polyfill.

import { setImmediate, clearImmediate } from 'tiny-set-immediate';

const handle = setImmediate(
  (...args) => {
    console.log(args);
  },
  [1, 2],
);

clearImmediate(handle);

This implementation does not allow string callbacks, and will not eval it.