Prelude API
    Preparing search index...

    Variable filterConst

    filter: Filter = ...

    Creates a generator that yields only elements from an iterable that pass a predicate test. Similar to Array.prototype.filter(), but works with any iterable.

    Type of elements in the input iterable

    Type of filtered elements (for type predicates)

    Function to test each element and its index

    A function that takes an iterable and returns a generator of filtered elements

    Elements that pass the predicate test

    // Filter out even numbers
    const odds = [...filter((n: number) => n % 2 === 1)([1, 2, 3, 4, 5])]
    // Result: [1, 3, 5]
    // Filter using index
    const everyOther = [...filter((_, idx) => idx % 2 === 0)(['a', 'b', 'c', 'd', 'e'])]
    // Result: ['a', 'c', 'e']
    // Using a type predicate to narrow types
    const isString = (val: unknown): val is string => typeof val === 'string'
    const strings = [...filter(isString)([1, 'a', 2, 'b', true])]
    // Result: ['a', 'b'] (with correct string[] type)