• Maps the given iterable to a new array with the given transform function. The result of the transform function will only be included in the returned array, if and only if the result was strictly not equal to undefined.

    Thus, the returned array can never include undefined. However, it could include null.

    Use this if you want to map and filter simultaneously; avoiding unnecessary loops.

    See

    mapNotNullish

    Example

    const accounts = [{ id: 0, name: 'A' }, { id: 1 }];
    const names: string[] = mapNotUndefined(accounts, account => account.name);

    Type Parameters

    Type Parameters

    • T

      the type of the items in the iterable

    • U

      the type of the items in the returned array

    Parameters

    • iterable: Iterable<T>

      an iterable to transform

    • transform: ((value: T) => undefined | U)

      the transform function

        • (value: T): undefined | U
        • Parameters

          • value: T

          Returns undefined | U

    Returns U[]

Generated using TypeDoc