@tienedev/datype
Version:
Modern TypeScript utility library with pragmatic typing and zero dependencies
78 lines • 2.23 kB
TypeScript
/**
* Checks if a value is a plain object (not an array, function, Date, etc.).
*
* @param value - The value to check
* @returns True if the value is a plain object, false otherwise
*
* @example
* ```typescript
* import { isPlainObject } from 'datype';
*
* isPlainObject({}); // true
* isPlainObject({ name: 'John' }); // true
* isPlainObject(new Object()); // true
* isPlainObject(Object.create(null)); // true
*
* isPlainObject([]); // false
* isPlainObject(new Date()); // false
* isPlainObject(/regex/); // false
* isPlainObject(function() {}); // false
* isPlainObject(null); // false
* isPlainObject(undefined); // false
* isPlainObject('string'); // false
* isPlainObject(42); // false
* ```
*/
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
/**
* Checks if a value is an array.
*
* @param value - The value to check
* @returns True if the value is an array, false otherwise
*
* @example
* ```typescript
* import { isArray } from 'datype';
*
* isArray([]); // true
* isArray([1, 2, 3]); // true
* isArray(new Array()); // true
* isArray(Array.from({length: 3})); // true
*
* isArray({}); // false
* isArray('string'); // false
* isArray(42); // false
* isArray(null); // false
* isArray(undefined); // false
* isArray(arguments); // false (in a function context)
* ```
*/
export declare function isArray(value: unknown): value is unknown[];
/**
* Checks if a value is a function.
*
* @param value - The value to check
* @returns True if the value is a function, false otherwise
*
* @example
* ```typescript
* import { isFunction } from 'datype';
*
* isFunction(function() {}); // true
* isFunction(() => {}); // true
* isFunction(async function() {}); // true
* isFunction(function* () {}); // true
* isFunction(Math.max); // true
* isFunction(Date); // true
* isFunction(Array); // true
*
* isFunction({}); // false
* isFunction([]); // false
* isFunction('string'); // false
* isFunction(42); // false
* isFunction(null); // false
* isFunction(undefined); // false
* ```
*/
export declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
//# sourceMappingURL=index.d.ts.map