Module: "urx/src/utils"#

Utils includes

  • a handful of functional utilities inspired by or taken from the Ramda library;
  • TypeScript crutches - the tup function.

Use these for your convenience - they are here so that urx is zero-dependency package.

Index#

Functions#

Functions#

always#

â–¸ always<T>(value: T): (Anonymous function)

Defined in urx/src/utils.ts:77

returns a function which when called always returns the passed value

Type parameters:#

Name
T

Parameters:#

NameType
valueT

Returns: (Anonymous function)


call#

â–¸ call(proc: Proc): void

Defined in urx/src/utils.ts:70

Calls the passed function.

Parameters:#

NameType
procProc

Returns: void


compose#

â–¸ compose<I, A, R>(a: (arg: A) => R, b: (arg: I) => A): function

Defined in urx/src/utils.ts:19

Performs left to right composition of two functions.

Type parameters:#

Name
I
A
R

Parameters:#

NameType
a(arg: A) => R
b(arg: I) => A

Returns: function


curry1to0#

â–¸ curry1to0<T, R>(proc: (arg: T) => R, arg: T): function

Defined in urx/src/utils.ts:40

Takes a 1 argument function and returns a function which when called, executes it with the provided argument.

Type parameters:#

Name
T
R

Parameters:#

NameType
proc(arg: T) => R
argT

Returns: function


curry2to1#

â–¸ curry2to1<T, K, R>(proc: (arg1: T, arg2: K) => R, arg1: T): function

Defined in urx/src/utils.ts:33

Takes a 2 argument function and partially applies the first argument.

Type parameters:#

Name
T
K
R

Parameters:#

NameType
proc(arg1: T, arg2: K) => R
arg1T

Returns: function


joinProc#

â–¸ joinProc(...procs: Proc[]): (Anonymous function)

Defined in urx/src/utils.ts:85

returns a function which calls all passed functions in the passed order. joinProc does not pass arguments or collect return values.

Parameters:#

NameType
...procsProc[]

Returns: (Anonymous function)


noop#

â–¸ noop(): void

Defined in urx/src/utils.ts:91

Returns: void


prop#

â–¸ prop(property: string): (Anonymous function)

Defined in urx/src/utils.ts:47

Returns a function which extracts the property from from the passed object.

Parameters:#

NameType
propertystring

Returns: (Anonymous function)


tap#

â–¸ tap<T>(arg: T, proc: (arg: T) => any): T

Defined in urx/src/utils.ts:54

Calls callback with the first argument, and returns it.

Type parameters:#

Name
T

Parameters:#

NameType
argT
proc(arg: T) => any

Returns: T


thrush#

â–¸ thrush<I, K>(arg: I, proc: (arg: I) => K): K

Defined in urx/src/utils.ts:26

Takes a value and applies a function to it.

Type parameters:#

Name
I
K

Parameters:#

NameType
argI
proc(arg: I) => K

Returns: K


tup#

â–¸ tup<T>(...args: T): T

Defined in urx/src/utils.ts:63

Utility function to help typescript figure out that what we pass is a tuple and not a generic array. Taken from (this StackOverflow tread)[https://stackoverflow.com/questions/49729550/implicitly-create-a-tuple-in-typescript/52445008#52445008]

Type parameters:#

NameType
TArray<any>

Parameters:#

NameType
...argsT

Returns: T