Function map

  • Returns an Iterable populated with the results of calling a function for every element of the passed-in iterable.

    Type Parameters

    • Iter extends AnyIt<unknown>
    • R

    Parameters

    • iter: Iter

      An iterable or async iterable.

    • func: ValFunc<AnyItV<Iter>, R>

      The function used to map each element.

    Returns AnyItResultIt<Iter, R>

    An Iterable or AsyncIterable with each element being the result of func.

    Example

    // Returns an Iterable representing [2, 4, 6]
    it.map([1,2,3], x => x * 2)