UNPKG

typedash

Version:

modern, type-safe collection of utility functions

24 lines (22 loc) 594 B
//#region src/functions/compact/compact.ts /** * Creates an array with all falsey values removed. * The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are falsey. * @param array The array to compact. * @returns The new array of filtered values. * @example * ```ts * compact([0, 1, false, 2, '', 3, null, 4, undefined]) // [1, 2, 3, 4] * ``` */ function compact(array) { return array?.filter(Boolean) ?? []; } //#endregion Object.defineProperty(exports, 'compact', { enumerable: true, get: function () { return compact; } }); //# sourceMappingURL=compact-BIRStvYt.cjs.map