Package: effect
Module: Array
Maps over an array and flattens the result, removing null and undefined values.
Example
import { Array } from "effect"
const result = Array.flatMapNullable([1, 2, 3], n => (n % 2 === 0 ? null : n))
console.log(result) // [1, 3]
// Explanation:
// The array of numbers [1, 2, 3] is mapped with a function that returns null for even numbers
// and the number itself for odd numbers. The resulting array [1, null, 3] is then flattened
// to remove null values, resulting in [1, 3].
Signature
declare const flatMapNullable: { <A, B>(f: (a: A) => B | null | undefined): (self: ReadonlyArray<A>) => Array<NonNullable<B>>; <A, B>(self: ReadonlyArray<A>, f: (a: A) => B | null | undefined): Array<NonNullable<B>>; }
Since v2.0.0