Options
All
  • Public
  • Public/Protected
  • All
Menu

fluent-streams

Index

Functions

abc

continually

  • continually<T>(getItem: () => T): Stream<T>
  • Creates an endless stream of values produced by getItem. Function return value is not cached; it's invoked separately to get each item.

    Type parameters

    • T

      Items type

    Parameters

    • getItem: () => T

      Function that produces items.

        • (): T
        • Returns T

    Returns Stream<T>

entryStream

  • entryStream<O>(object: O): Stream<readonly [keyof O, O[keyof O]]>
  • Creates a steam of [key, value] pairs from given object. Keys are retrieved with Object.keys(), which means prototype members are not included.

    Type parameters

    • O: {}

      Input object type

    Parameters

    • object: O

      Object to create [key, value]-pairs stream from.

    Returns Stream<readonly [keyof O, O[keyof O]]>

optional

  • optional<T>(input: Iterable<T>): Optional<T>
  • Creates an optional from given iterable. An empty iterable resolves to an empty optional; otherwise the optional resolves to the first item yielded by iterable, rest elements are discarded.

    Type parameters

    • T

      elements type.

    Parameters

    • input: Iterable<T>

    Returns Optional<T>

optionalOfNullable

  • optionalOfNullable<T>(getInput: () => T | null | undefined): Optional<T>
  • Creates an optional which resolves to a value returned by getInput if that value is not null or undefined, or which resolves to empty otherwise.

    Type parameters

    • T

      Non-nullable input value type

    Parameters

    • getInput: () => T | null | undefined

      Function which produces value or null or undefined

        • (): T | null | undefined
        • Returns T | null | undefined

    Returns Optional<T>

range

  • range(from: number, bound: number): Stream<number>
  • Creates a stream of ascending numbers starting with from up to bound exclusively.

    Parameters

    • from: number

      Start value inclusively

    • bound: number

      End value exclusively

    Returns Stream<number>

same

  • same<T>(value: T): Stream<T>
  • Creates an endless stream of value

    Type parameters

    • T

      Value type

    Parameters

    • value: T

      An item to repeat endlessly

    Returns Stream<T>

stream

  • stream<T>(input: Iterable<T>): Stream<T>
  • Creates a stream from an iterable (for example, array, set etc). Streams created with this function never modify input; if you want the opposite use streamFromModifiable.

    Type parameters

    • T

      Items type

    Parameters

    • input: Iterable<T>

      Input to create the stream from. Can be array, set, or any other iterable, including user-defined, as long as it correctly implements iteration protocol. If you implement your own iterable please note: a) next() is not expected to take any arguments, and b) value returned with {done: true} is discarded.

    Returns Stream<T>

streamFromModifiable

  • streamFromModifiable<T>(input: T[]): Stream<T>
  • Creates a stream from an array but, unlike stream, allows input modifications. That's useful for operations like Stream.sortBy and Stream.shuffle which otherwise copy input to the new array.

    Type parameters

    • T

      Elements type

    Parameters

    • input: T[]

      array allowed for modifications to create stream from

    Returns Stream<T>

streamOf

  • streamOf<T>(...input: T[]): Stream<T>

Generated using TypeDoc