Skip to content

compact

ts
function Array.compact<T>(
    target: readonly T[],
): readonly Exclude<T, null | undefined>[]

Removes all nullable values from array.

Example

ts
import { Array } from "@monstermann/array";

Array.compact([1, null, undefined]); // [1]
ts
import { Array } from "@monstermann/array";

pipe([1, null, undefined], Array.compact()); // [1]