diff options
author | Vincent LE GOFF <g_n_s@hotmail.fr> | 2019-11-12 21:51:14 +0100 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-11-12 15:51:14 -0500 |
commit | ee1b8dc883db1531d913f7b10a8d1160f3209d93 (patch) | |
tree | 3ba17c471d465555fbffc7aa9027503b901ccc26 /std/node/util.ts | |
parent | 0f33bf68859c162eb3d65ab53a7c71092585e1d1 (diff) |
feat: std/node (#3319)
Diffstat (limited to 'std/node/util.ts')
-rw-r--r-- | std/node/util.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/std/node/util.ts b/std/node/util.ts new file mode 100644 index 000000000..d0187e616 --- /dev/null +++ b/std/node/util.ts @@ -0,0 +1,47 @@ +export function isArray(value: unknown): boolean { + return Array.isArray(value); +} + +export function isBoolean(value: unknown): boolean { + return typeof value === "boolean" || value instanceof Boolean; +} + +export function isNull(value: unknown): boolean { + return value === null; +} + +export function isNullOrUndefined(value: unknown): boolean { + return value === null || value === undefined; +} + +export function isNumber(value: unknown): boolean { + return typeof value === "number" || value instanceof Number; +} + +export function isString(value: unknown): boolean { + return typeof value === "string" || value instanceof String; +} + +export function isSymbol(value: unknown): boolean { + return typeof value === "symbol"; +} + +export function isUndefined(value: unknown): boolean { + return value === undefined; +} + +export function isObject(value: unknown): boolean { + return value !== null && typeof value === "object"; +} + +export function isError(e: unknown): boolean { + return e instanceof Error; +} + +export function isFunction(value: unknown): boolean { + return typeof value === "function"; +} + +export function isRegExp(value: unknown): boolean { + return value instanceof RegExp; +} |