@tienedev/datype
Version:
Modern TypeScript utility library with pragmatic typing and zero dependencies
35 lines • 1.08 kB
TypeScript
/**
* Checks if a value is empty.
*
* @template T - The type of the value to check
* @param value - The value to check for emptiness
* @returns `true` if the value is empty, `false` otherwise
*
* A value is considered empty if it is:
* - `null` or `undefined`
* - An empty string (`""`)
* - An empty array (`[]`)
* - An empty object (`{}`) - only own enumerable properties are considered
* - An empty Set or Map
*
* @example
* ```typescript
* import { isEmpty } from 'datype';
*
* isEmpty(null); // true
* isEmpty(undefined); // true
* isEmpty(''); // true
* isEmpty([]); // true
* isEmpty({}); // true
* isEmpty(new Set()); // true
* isEmpty(new Map()); // true
*
* isEmpty('hello'); // false
* isEmpty([1, 2, 3]); // false
* isEmpty({key: 'value'}); // false
* isEmpty(0); // false
* isEmpty(false); // false
* ```
*/
export declare function isEmpty(value: unknown): value is null | undefined | '' | [] | Record<string, never>;
//# sourceMappingURL=index.d.ts.map