From 90d683127147975a08df45bac0de6b719ca07ce4 Mon Sep 17 00:00:00 2001 From: Ali Hasani Date: Thu, 9 Apr 2020 03:14:39 +0430 Subject: feat(std/node): add isPrimitive (#4673) --- std/node/util.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'std/node/util.ts') diff --git a/std/node/util.ts b/std/node/util.ts index 9879da513..73cbbf823 100644 --- a/std/node/util.ts +++ b/std/node/util.ts @@ -46,6 +46,12 @@ export function isRegExp(value: unknown): boolean { return value instanceof RegExp; } +export function isPrimitive(value: unknown): boolean { + return ( + value === null || (typeof value !== "object" && typeof value !== "function") + ); +} + export function validateIntegerRange( value: number, name: string, -- cgit v1.2.3