compact

compact

Filters nullish items from an array

Import

import { compact } from '@fullstacksjs/toolbox';

Signature

function compact<T extends readonly unknown[]>(xs: T): FilterNullish<T> {}

Examples

compact([])                                    // []
compact([1])                                   // [1]
compact([0, '', null, false, NaN, undefined]) // [0, '', false, NaN, {}]