setTimeoutUnref.js 495 B

12345678910111213
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. /**
  4. * `setTimeoutUnref` is just like `setTimeout`,
  5. * only in Node's environment it will "unref" its macro task.
  6. */
  7. function setTimeoutUnref(callback, time, args) {
  8. const ref = setTimeout.apply(typeof globalThis !== 'undefined' ? globalThis : global, arguments);
  9. if (ref && typeof ref === 'object' && typeof ref.unref === 'function')
  10. ref.unref();
  11. return ref;
  12. }
  13. exports.default = setTimeoutUnref;