UNPKG

typedash

Version:

modern, type-safe collection of utility functions

18 lines (17 loc) 504 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 export { compact as t }; //# sourceMappingURL=compact-DkVw8bE5.js.map