Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "src/utils"

Index

Functions

allTrue

  • allTrue<T>(xs: T[], f: Predicate<T>): boolean
  • Check is a predicate evaluates to true for all elements of a list.

    Type parameters

    • T

    Parameters

    Returns boolean

anyTrue

  • anyTrue<T>(xs: T[], f: Predicate<T>): boolean
  • Check is a predicate evaluates to true for any elements of a list.

    Type parameters

    • T

    Parameters

    Returns boolean

bind

  • bind<T>(context: any, f: T): T
  • Bind a function to a specific context, preserving the type of the orginal function.

    Type parameters

    • T: Function

    Parameters

    • context: any
    • f: T

    Returns T

bindP

  • bindP<A, B>(f: Function1<A, Promise<B>>): (Anonymous function)
  • Monadic bind for es6 promises.

    (They handle it internally, but this just helps keep type signatures clear)

    Type parameters

    • A

    • B

    Parameters

    Returns (Anonymous function)

debounce

  • debounce<T>(f: Lazy<T>, wait?: number, context?: any): (Anonymous function)
  • Debounce a lazy execution context such that it won't run until it hasn't been called for wait milliseconds.

    Type parameters

    • T

    Parameters

    • f: Lazy<T>
    • Default value wait: number = 100
    • Optional context: any

    Returns (Anonymous function)

extend

  • extend<A, B>(a: A, b: B): A & B
  • Given two object create a new (shallow clone) object that combines the properties of both. Duplicate keys will be overridden in preference of b.

    Type parameters

    • A

    • B

    Parameters

    • a: A
    • b: B

    Returns A & B

find

  • find<T>(f: Predicate<T>): (Anonymous function)
  • Find the first element in a list that matches a predicate.

    Type parameters

    • T

    Parameters

    Returns (Anonymous function)

getOrThrow

  • getOrThrow(message: string): (Anonymous function)
  • Extract the value from an Option, throwing an exception if it's None.

    Can be used inside Promise chains to either get a value or reject.

    Parameters

    • message: string

    Returns (Anonymous function)

group

  • group<T, K>(xs: T[], prop: K): Map<T[K], T[]>
  • Given a collection of elements of the same type, combine them into a map of lists of like objects, keyed on the chosen property value.

    Type parameters

    • T

    • K: keyof T

    Parameters

    • xs: T[]
    • prop: K

    Returns Map<T[K], T[]>

mapL

  • mapL<A, B>(f: Function1<A, B>): (Anonymous function)
  • Curried map on lists.

    Type parameters

    • A

    • B

    Parameters

    Returns (Anonymous function)

mapO

  • mapO<A, B>(f: Function1<A, B>): (Anonymous function)
  • Curried map on Option types.

    Type parameters

    • A

    • B

    Parameters

    Returns (Anonymous function)

mapP

  • mapP<A, B>(f: Function1<A, B>): (Anonymous function)
  • Curried map onto es6 Promises.

    Type parameters

    • A

    • B

    Parameters

    Returns (Anonymous function)

merge

  • merge<T>(...xs: T[]): T
  • Given a collection of objects of the same type, merge them. Duplicate keys will be overridden such that the right-most is favoured.

    Type parameters

    • T

    Parameters

    • Rest ...xs: T[]

    Returns T

Generated using TypeDoc