UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

23 lines (21 loc) 423 B
import { filter } from "./filter.js"; import { dfdlT } from "@monstermann/dfdl"; //#region src/array/compact.ts /** * `compact(array)` * * Removes all nullable values from `array`. * * ```ts * compact([1, null, undefined]); // [1] * ``` * * ```ts * pipe([1, null, undefined], compact()); // [1] * ``` */ const compact = dfdlT((target) => { return filter(target, (v) => v != null); }, 1); //#endregion export { compact };