All files / src setTimeoutUnref.ts

100% Statements 5/5
83.33% Branches 5/6
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14              1x 1x 1x     46x  
export type TSetTimeout = (callback: (...args) => void, time?: number, args?: any[]) => any;
 
/**
 * `setTimeoutUnref` is just like `setTimeout`,
 * only in Node's environment it will "unref" its macro task.
 */
function setTimeoutUnref(callback, time?, args?): object {
  const ref = setTimeout.apply(typeof globalThis !== 'undefined' ? globalThis : global, arguments);
  if (ref && typeof ref === 'object' && typeof ref.unref === 'function') ref.unref();
  return ref;
}
 
export default setTimeoutUnref;