Options
All
  • Public
  • Public/Protected
  • All
Menu

functional-programming-library

Index

Type aliases

PredicateFunction

PredicateFunction<T>: UnaryFunction<T, boolean>

A type representing a predicate function.

Type parameters

  • T

    the input type of the function

UnaryFunction

UnaryFunction<In, Out>: (arg0: In) => Out

A type representing a single-argument function.

Type parameters

  • In

    the type of the parameter

  • Out

    the return type of the function

Type declaration

    • (arg0: In): Out
    • Parameters

      • arg0: In

      Returns Out

Consumption Functions

all

  • all<T>(pred: (arg0: T) => boolean): (arg0: Iterable<T>) => boolean
  • all<T>(pred: (arg0: T) => boolean, iter: Iterable<T>): boolean
  • Exhausts the iterable and returns true if all elements satisfy the predicate function. This version is curried to allow for succient composition of operators.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    Returns (arg0: Iterable<T>) => boolean

    A function that takes an iterable of type T. This function exhausts the iterable and returns true if all elements satisfy the predicate.

      • (arg0: Iterable<T>): boolean
      • Parameters

        • arg0: Iterable<T>

        Returns boolean

  • Exhausts the iterable and returns true if all elements satisfy the predicate function.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    • iter: Iterable<T>

    Returns boolean

    true if all the elements satisfy the predicate, false otherwise

Other Functions

any

  • any<T>(pred: (arg0: T) => boolean): (arg0: Iterable<T>) => boolean
  • any<T>(pred: (arg0: T) => boolean, iter: Iterable<T>): boolean
  • Exhausts the iterable and returns true if any elements satisfy the predicate function.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    Returns (arg0: Iterable<T>) => boolean

    A function that takes an iterable of type T. This function exhausts the iterable and returns true if any elements satisfy the predicate.

      • (arg0: Iterable<T>): boolean
      • Parameters

        • arg0: Iterable<T>

        Returns boolean

  • Exhausts the iterable and returns true if any elements satisfy the predicate function.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    • iter: Iterable<T>

    Returns boolean

    true if any element satisfy the predicate, false otherwise

compose

dedupe

  • dedupe<T>(): (arg0: Iterable<T>) => Generator<T>
  • dedupe<T>(iter: Iterable<T>): Generator<T>
  • dedupe

    A curried verison of the dedupe operator. This overload takes no parameters and returns an operator that can be used to filter out any duplicate values in an iterable.

    Type parameters

    • T

    Returns (arg0: Iterable<T>) => Generator<T>

    An iterable that contains only the first of each distinct value.

      • (arg0: Iterable<T>): Generator<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Generator<T>

  • dedupe

    Type parameters

    • T

    Parameters

    • iter: Iterable<T>

    Returns Generator<T>

    An iterable that contains only the first of each distinct value.

drop

  • drop<T>(n: number): (arg0: Iterable<T>) => Generator<T>
  • drop<T>(n: number, iter: Iterable<T>): Generator<T>
  • drop(n)

    Removes the first n elements from the iterable

    Type parameters

    • T

    Parameters

    • n: number

    Returns (arg0: Iterable<T>) => Generator<T>

    A function that takes an iterable as a parameter. This function removes the first n elements from an interable

      • (arg0: Iterable<T>): Generator<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Generator<T>

  • Removes the first n elements from the iterable

    Type parameters

    • T

    Parameters

    • n: number
    • iter: Iterable<T>

    Returns Generator<T>

    The first n elements from the iterable

dropWhile

  • dropWhile<T>(pred: (arg0: T) => boolean): (arg0: Iterable<T>) => Iterable<T>
  • dropWhile<T>(pred: (arg0: T) => boolean, iter: Iterable<T>): Iterable<T>
  • dropWhile

    Removes elements from the iterable while the predicate returns true.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    Returns (arg0: Iterable<T>) => Iterable<T>

    A function that will consume an iterable until the predicate function returns false, then yields the rest of the iterable.

      • (arg0: Iterable<T>): Iterable<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Iterable<T>

  • dropWhile

    Removes elements from the iterable while the predicate returns true.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    • iter: Iterable<T>

    Returns Iterable<T>

    All elements in the source iterable after the predicate initially returns false.

enumerate

  • enumerate<T>(iter: Iterable<T>): Iterable<[number, T]>
  • enumerate

    Converts a regular iterable into an indexed iterable.

    Type parameters

    • T

    Parameters

    • iter: Iterable<T>

    Returns Iterable<[number, T]>

    Pairs, where the first value in the pair is index and the second is the value

filter

  • filter<T>(pred: (arg0: T) => boolean): (arg0: Iterable<T>) => Iterable<T>
  • filter<T>(pred: (arg0: T) => boolean, iter: Iterable<T>): Iterable<T>
  • filter

    Exhausts an interable and yields only values that satisfy the prediate function. Operates the same as the built-in Array.filter function.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    Returns (arg0: Iterable<T>) => Iterable<T>

    A function that takes an iterable and filters it with the pred function.

      • (arg0: Iterable<T>): Iterable<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Iterable<T>

  • filter

    Exhausts an interable and yields only values that satisfy the prediate function. Operates the same as the built-in Array.filter function.

    Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    • iter: Iterable<T>

    Returns Iterable<T>

    An iterable of the values in iter that satisfy pred.

find

  • find<T>(pred: (arg0: T) => boolean): (arg0: Iterable<T>) => Optional<T>
  • find<T>(pred: (arg0: T) => boolean, iter: Iterable<T>): Optional<T>
  • Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    Returns (arg0: Iterable<T>) => Optional<T>

      • (arg0: Iterable<T>): Optional<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Optional<T>

  • Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    • iter: Iterable<T>

    Returns Optional<T>

findIndex

  • findIndex<T>(pred: (arg0: T) => boolean): (arg0: Iterable<T>) => Optional<number>
  • findIndex<T>(pred: (arg0: T) => boolean, iter: Iterable<T>): Optional<number>
  • Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    Returns (arg0: Iterable<T>) => Optional<number>

      • (arg0: Iterable<T>): Optional<number>
      • Parameters

        • arg0: Iterable<T>

        Returns Optional<number>

  • Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    • iter: Iterable<T>

    Returns Optional<number>

into

  • into<T>(structure: "array"): (arg0: Iterable<T>) => T[]
  • into<T>(structure: "array", iter: Iterable<T>): T[]
  • into<T>(structure: "set"): (arg0: Iterable<T>) => Set<T>
  • into<T>(structure: "set", iter: Iterable<T>): Set<T>
  • into('array')

    Exhausts the source iterable and returns all values from the interable in an array.

    Type parameters

    • T

    Parameters

    • structure: "array"

    Returns (arg0: Iterable<T>) => T[]

    A function that can be used to convert from the source iterable to an array

      • (arg0: Iterable<T>): T[]
      • Parameters

        • arg0: Iterable<T>

        Returns T[]

  • into('array', iter)

    Exhausts the source iterable and returns all values from the interable in an array.

    Type parameters

    • T

    Parameters

    • structure: "array"
    • iter: Iterable<T>

    Returns T[]

    An array of all elements in the source iterable.

  • into('set')

    Exhausts the source iterable and returns all values from the interable in an set.

    Type parameters

    • T

    Parameters

    • structure: "set"

    Returns (arg0: Iterable<T>) => Set<T>

    A function that can be used to convert from the source iterable to set.

      • (arg0: Iterable<T>): Set<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Set<T>

  • into('set', iter)

    Exhausts the source iterable and returns all values from the interable in a set.

    Type parameters

    • T

    Parameters

    • structure: "set"
    • iter: Iterable<T>

    Returns Set<T>

    A set of all elements in the source iterable.

is_none

  • is_none<T>(opt: Optional<T>): opt is None
  • is_none

    A function to determine if an object is a None object. This function is a type assertion, to allow for strong type inference in if statements and switch statements.

    Type parameters

    • T

    Parameters

    • opt: Optional<T>

      an object of type Optional

    Returns opt is None

    true if the object is a None object, otherwise false

is_some

  • is_some<T>(opt: Optional<T>): opt is Some<T>
  • is_some

    A function to determine if an object is a Some object. This function is a type assertion, to allow for strong type inference in if statements and switch statements.

    Type parameters

    • T

    Parameters

    • opt: Optional<T>

      an object of type Optional

    Returns opt is Some<T>

    true if the object is a Some object, otherwise false

iterate

  • iterate<T>(func: (arg0: T) => T, seed: T): Generator<T>
  • iterate

    Type parameters

    • T

    Parameters

    • func: (arg0: T) => T
        • (arg0: T): T
        • Parameters

          • arg0: T

          Returns T

    • seed: T

    Returns Generator<T>

    infinite sequence of func(seed), func(func(seed)), func(func(func(seed))), ...

map

  • map<In, Out>(f: (arg0: In) => Out): MapTransform<In, Out>
  • map<In, Out>(f: (arg0: In) => Out, iter: Iterable<In>): Generator<Out>
  • Type parameters

    • In

    • Out

    Parameters

    • f: (arg0: In) => Out
        • (arg0: In): Out
        • Parameters

          • arg0: In

          Returns Out

    Returns MapTransform<In, Out>

  • Type parameters

    • In

    • Out

    Parameters

    • f: (arg0: In) => Out
        • (arg0: In): Out
        • Parameters

          • arg0: In

          Returns Out

    • iter: Iterable<In>

    Returns Generator<Out>

none

  • none(): None
  • none

    remarks

    Constructs an object of the None type

    Returns None

    a none object.

pipe

range

  • range(): Generator<number>
  • range(stop: number): Generator<number>
  • range(start: number, stop: number): Generator<number>
  • range(start: number, stop: number, step: number): Generator<number>

repeat

  • repeat<T>(value: T): Generator<T>
  • repeat

    Produces an infinite iterable, yielding the given value over and over again

    Type parameters

    • T

    Parameters

    • value: T

    Returns Generator<T>

    An infinite iterable of the provided value

some

  • some<T>(data: T): Some<T>
  • Constructs an object of the Some type

    Type parameters

    • T

    Parameters

    • data: T

    Returns Some<T>

    a some object, containing the parameter as its data

take

  • take<T>(n: number): (arg0: Iterable<T>) => Generator<T>
  • take<T>(n: number, iter: Iterable<T>): Generator<T>
  • Type parameters

    • T

    Parameters

    • n: number

    Returns (arg0: Iterable<T>) => Generator<T>

      • (arg0: Iterable<T>): Generator<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Generator<T>

  • Type parameters

    • T

    Parameters

    • n: number
    • iter: Iterable<T>

    Returns Generator<T>

takeWhile

  • takeWhile<T>(pred: (arg0: T) => boolean): (arg0: Iterable<T>) => Iterable<T>
  • takeWhile<T>(pred: (arg0: T) => boolean, iter: Iterable<T>): Iterable<T>
  • Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    Returns (arg0: Iterable<T>) => Iterable<T>

      • (arg0: Iterable<T>): Iterable<T>
      • Parameters

        • arg0: Iterable<T>

        Returns Iterable<T>

  • Type parameters

    • T

    Parameters

    • pred: (arg0: T) => boolean
        • (arg0: T): boolean
        • Parameters

          • arg0: T

          Returns boolean

    • iter: Iterable<T>

    Returns Iterable<T>

zip2

  • zip2<T, S>(iter1: Iterable<T>, iter2: Iterable<S>): Generator<[T, S]>
  • Combines two iterables into a single iterable. yields pairs of values

    Type parameters

    • T

    • S

    Parameters

    • iter1: Iterable<T>
    • iter2: Iterable<S>

    Returns Generator<[T, S]>

    pairs in the form [value1, value2]

Generated using TypeDoc