UNPKG

@pulzar/core

Version:

Next-generation Node.js framework for ultra-fast web applications with zero-reflection DI, GraphQL, WebSockets, events, and edge runtime support

100 lines 2.17 kB
/** * Check if a value is an object (but not null, array, or primitive) */ export function isObject(value) { return value !== null && typeof value === "object" && !Array.isArray(value); } /** * Check if a value is a plain object (created with {} or new Object()) */ export function isPlainObject(value) { if (!isObject(value)) return false; const prototype = Object.getPrototypeOf(value); return prototype === Object.prototype || prototype === null; } /** * Check if a value is a function */ export function isFunction(value) { return typeof value === "function"; } /** * Check if a value is a string */ export function isString(value) { return typeof value === "string"; } /** * Check if a value is a number */ export function isNumber(value) { return typeof value === "number" && !isNaN(value); } /** * Check if a value is a boolean */ export function isBoolean(value) { return typeof value === "boolean"; } /** * Check if a value is null or undefined */ export function isNullOrUndefined(value) { return value === null || value === undefined; } /** * Check if a value is an array */ export function isArray(value) { return Array.isArray(value); } /** * Check if a value is a Date object */ export function isDate(value) { return value instanceof Date; } /** * Check if a value is a RegExp object */ export function isRegExp(value) { return value instanceof RegExp; } /** * Check if a value is a Promise */ export function isPromise(value) { return value && typeof value.then === "function"; } /** * Check if a value is an Error object */ export function isError(value) { return value instanceof Error; } /** * Check if a value is a Map */ export function isMap(value) { return value instanceof Map; } /** * Check if a value is a Set */ export function isSet(value) { return value instanceof Set; } /** * Check if a value is a Symbol */ export function isSymbol(value) { return typeof value === "symbol"; } /** * Check if a value is a BigInt */ export function isBigInt(value) { return typeof value === "bigint"; } //# sourceMappingURL=isObject.js.map