Prelude API
    Preparing search index...

    Function defined

    • Creates a generator that yields all values from an iterable except undefined.

      Type Parameters

      • T

        Type of elements in the iterable

      Parameters

      • values: Iterable<T>

        The source iterable to filter

      Returns Generator<Defined<T>>

      A generator that filters out undefined values

      All non-undefined values from the source iterable

      // Filter out undefined values
      const results = [...defined([1, undefined, 2, undefined, 3])]
      // Result: [1, 2, 3]
      // Null values are preserved (unlike with compact)
      const results = [...defined([1, null, 2, undefined, 3])]
      // Result: [1, null, 2, 3]

      compact - For filtering out both null and undefined values