diginext-utils
Version:
README.md
17 lines • 530 B
TypeScript
/**
* Creates an array with all falsy values removed.
* Falsy values are: false, null, 0, "", undefined, and NaN.
*
* @template T - The type of elements in the array
* @param array - The array to compact
* @returns A new array with falsy values removed
*
* @example
* ```ts
* compact([0, 1, false, 2, '', 3, null, undefined, NaN]);
* // [1, 2, 3]
* compact(['a', '', 'b', null, 'c']); // ['a', 'b', 'c']
* ```
*/
export declare function compact<T>(array: T[]): NonNullable<T>[];
//# sourceMappingURL=compact.d.ts.map