Skip to content

Commit d10c4b6

Browse files
committed
fix(delay): prevent infinite mode from throwing
1 parent 89adbf8 commit d10c4b6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/core/utils/internal/hasRefCounted.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
import { isObject } from './isObject'
2+
13
export function hasRefCounted<T extends object>(
24
value: T,
35
): value is T & NodeJS.RefCounted {
46
return (
7+
/**
8+
* @note Guard against non-object values.
9+
* E.g. `setTimeout` returns an object in Node.js but a number in the browser.
10+
*/
11+
isObject(value) &&
512
typeof Reflect.get(value, 'ref') === 'function' &&
613
typeof Reflect.get(value, 'unref') === 'function'
714
)

0 commit comments

Comments
 (0)