better code: suggested by node.js itself
Massimo Melina committed
Jan 3, 2025 at 19:52 UTC
c78d08505624eec8c697a57cf1ab67b49dd0ab6d
1 file changed
+1
-1
src/cross.ts
+1
-1
@@ -378,7 +378,7 @@ export function isNumeric(x: unknown) {
378
}
379
380
export function isPrimitive(x: unknown): x is boolean | string | number | undefined | null {
381
- return !x || Object(x) !== x
381
+ return x === null || typeof x !== 'object' && typeof x !== 'function' // from node's documentation
382
}
383
384
export function isIP(address: string) {