UNPKG

typedash

Version:

modern, type-safe collection of utility functions

21 lines (17 loc) 617 B
import { M as Maybe } from './Maybe-D6dwMjD9.js'; /** * A type that represents all the falsey values in JavaScript. */ type Falsey = null | undefined | false | '' | 0 | 0n; /** * 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] * ``` */ declare function compact<T>(array: Maybe<ReadonlyArray<T | Falsey>>): T[]; export { type Falsey as F, compact as c };