Class Stream<T>

A readonly wrapper around an array that lets you chain method calls.

Type Parameters

  • T

Hierarchy

  • Stream

Methods

  • Removes all null and undefined values from the array.

    Returns

    a new array without any null or undefined values

    Returns Stream<NonNullable<T>>

  • Filters out elements for which the given properties are null or undefined. Elements that are null or undefined themselves are filtered out.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • Rest ...props: K[]

    Returns Stream<RequireProps<NonNullable<T>, K>>

  • Filters the array by a predicate function.

    Returns

    a new stream with the filtered result

    Parameters

    • predicate: ((value: T) => boolean)

      a function by which to filter

        • (value: T): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns Stream<T>

  • Exits the chain by grouping elements into an object of arrays based on the given property key

    Type Parameters

    • K extends string | number | symbol

    • TK extends string | number | symbol

    Parameters

    • key: K

      the property to group by

    Returns Record<TK, T[]>

  • Exits the chain by grouping elements into an object of arrays based on the results the getKey function

    Type Parameters

    • TK extends string | number | symbol

    Parameters

    • getKey: KeyFun<T, TK>

      a function that returns the value to group by

    Returns Record<TK, T[]>

  • Exits the chain by mapping each item to a unique key

    Type Parameters

    • K extends string | number | symbol

    • TK extends string | number | symbol

    Parameters

    • key: K

    Returns Record<TK, T>

  • Maps the elements in the array using a function.

    Returns

    a new stream with the mapped array values

    Type Parameters

    • S

    Parameters

    • fn: ((value: T) => S)

      a function that operates on each value in the array

        • (value: T): S
        • Parameters

          • value: T

          Returns S

    Returns Stream<S>

  • Sorts the array by an object key.

    Returns

    the sorted array

    Type Parameters

    • S extends object

    • K extends string

    Parameters

    • key: K

      the sort key

    • dir: SortDir = "asc"

      the sort direction

    Returns Stream<S>

  • Exits the chain by returning the modified array

    Returns

    the actual array

    Returns T[]

  • Returns the unique elements of the array.

    Returns

    a new stream with the unique elements

    Parameters

    • Optional by: ((a: T) => string | number)

      an optional comparison function

        • (a: T): string | number
        • Parameters

          • a: T

          Returns string | number

    Returns Stream<T>

Generated using TypeDoc