source: node_modules/es-toolkit/dist/array/compact.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 607 bytes
Line 
1type NotFalsey<T> = Exclude<T, false | null | 0 | 0n | '' | undefined>;
2/**
3 * Removes falsey values (false, null, 0, -0, 0n, '', undefined, NaN) from an array.
4 *
5 * @template T - The type of elements in the array.
6 * @param {T[]} arr - The input array to remove falsey values.
7 * @returns {Array<Exclude<T, false | null | 0 | 0n | '' | undefined>>} - A new array with all falsey values removed.
8 *
9 * @example
10 * compact([0, -0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
11 * Returns: [1, 2, 3, 4, 5]
12 */
13declare function compact<T>(arr: readonly T[]): Array<NotFalsey<T>>;
14
15export { compact };
Note: See TracBrowser for help on using the repository browser.