tiinvo

tiinvo / Exports / Fn

Namespace: Fn

Table of contents

Type Aliases

Functions

Type Aliases

AnyAsyncFn

Ƭ AnyAsyncFn: (…args: any[]) => Promise<any>

Type declaration

▸ (...args): Promise<any>

Represents any async function

Parameters
Name Type
...args any[]
Returns

Promise<any>

Defined in

src/Fn.ts:8


AnyFn

Ƭ AnyFn: (…args: any[]) => any

Type declaration

▸ (...args): any

Represents any function

Parameters
Name Type
...args any[]
Returns

any

Defined in

src/Fn.ts:13


Unary

Ƭ Unary<A, R>: (a: A) => R

Type parameters

Name Description
A the first value type
R the return type

Type declaration

▸ (a): R

Represents any unary function

Since

4.0.0

Parameters
Name Type
a A
Returns

R

Defined in

src/Fn.ts:22


Binary

Ƭ Binary<A, B, R>: (a: A, b: B) => R

Type parameters

Name Description
A the first value type
B the second value type
R the return type

Type declaration

▸ (a, b): R

Represents any binary function

Since

4.0.0

Parameters
Name Type
a A
b B
Returns

R

Defined in

src/Fn.ts:32


Ternary

Ƭ Ternary<A, B, C, R>: (a: A, b: B, c: C) => R

Type parameters

Name Description
A the first value type
B the second value type
C the third value type
R the return type

Type declaration

▸ (a, b, c): R

Represents any ternary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
Returns

R

Defined in

src/Fn.ts:43


Quaternary

Ƭ Quaternary<A, B, C, D, R>: (a: A, b: B, c: C, d: D) => R

Type parameters

Name Description
A the 1th value type
B the 2th value type
C the 3th value type
D the 4th value type
R the return type

Type declaration

▸ (a, b, c, d): R

Represents any quaternary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
d D
Returns

R

Defined in

src/Fn.ts:55


Quinary

Ƭ Quinary<A, B, C, D, E, R>: (a: A, b: B, c: C, d: D, e: E) => R

Type parameters

Name Description
A the 1th value type
B the 2th value type
C the 3th value type
D the 4th value type
E the 5th value type
R the return type

Type declaration

▸ (a, b, c, d, e): R

Represents any quinary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
d D
e E
Returns

R

Defined in

src/Fn.ts:68


Senary

Ƭ Senary<A, B, C, D, E, F, R>: (a: A, b: B, c: C, d: D, e: E, f: F) => R

Type parameters

Name Description
A the 1th value type
B the 2th value type
C the 3th value type
D the 4th value type
E the 5th value type
F the 6th value type
R the return type

Type declaration

▸ (a, b, c, d, e, f): R

Represents any senary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
d D
e E
f F
Returns

R

Defined in

src/Fn.ts:82


Septenary

Ƭ Septenary<A, B, C, D, E, F, G, R>: (a: A, b: B, c: C, d: D, e: E, f: F, g: G) => R

Type parameters

Name Description
A the 1th value type
B the 2th value type
C the 3th value type
D the 4th value type
E the 5th value type
F the 6th value type
G the 7th value type
R the return type

Type declaration

▸ (a, b, c, d, e, f, g): R

Represents any septenary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
d D
e E
f F
g G
Returns

R

Defined in

src/Fn.ts:97


Octonary

Ƭ Octonary<A, B, C, D, E, F, G, H, R>: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) => R

Type parameters

Name Description
A the 1th value type
B the 2th value type
C the 3th value type
D the 4th value type
E the 5th value type
F the 6th value type
G the 7th value type
H the 8th value type
R the return type

Type declaration

▸ (a, b, c, d, e, f, g, h): R

Represents any octonary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
d D
e E
f F
g G
h H
Returns

R

Defined in

src/Fn.ts:113


Nonary

Ƭ Nonary<A, B, C, D, E, F, G, H, I, R>: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) => R

Type parameters

Name Description
A the 1th value type
B the 2th value type
C the 3th value type
D the 4th value type
E the 5th value type
F the 6th value type
G the 7th value type
H the 8th value type
I the 9th value type
R the return type

Type declaration

▸ (a, b, c, d, e, f, g, h, i): R

Represents any nonary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
d D
e E
f F
g G
h H
i I
Returns

R

Defined in

src/Fn.ts:130


Decenary

Ƭ Decenary<A, B, C, D, E, F, G, H, I, L, R>: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, l: L) => R

Type parameters

Name Description
A the 1th value type
B the 2th value type
C the 3th value type
D the 4th value type
E the 5th value type
F the 6th value type
G the 7th value type
H the 8th value type
I the 9th value type
L the 10th value type
R the return type

Type declaration

▸ (a, b, c, d, e, f, g, h, i, l): R

Represents any decenary function

Since

4.0.0

Parameters
Name Type
a A
b B
c C
d D
e E
f F
g G
h H
i I
l L
Returns

R

Defined in

src/Fn.ts:148


T

Ƭ T: AnyFn

Represents a generic function T with any arguments and any return value type.

Defined in

src/Fn.ts:153

Functions

pass

pass<A>(a): A

A function which returns it’s first argument.

Use it only as a placeholder

Example

import { Fn } from 'tiinvo'

Fn.pass(10)      // 10
Fn.pass(20)      // 20

Since

4.0.0

Type parameters

Name
A

Parameters

Name Type
a A

Returns

A

Defined in

src/Fn.ts:173


cmp

cmp(a, b): ComparableResult

Compares two function signatures and names.

Example

import { Fn, Num } from 'tiinvo'

Fn.cmp(Num.add, Num.add) // 0
Fn.cmp(Num.add, Num.sub) // -1
Fn.cmp(Num.sub, Num.add) // 1

Since

4.0.0

Parameters

Name Type Description
a AnyFn the first function
b AnyFn the second function

Returns

ComparableResult

Defined in

src/Fn.ts:198

cmp(a): Unary<T, ComparableResult>

Returns a unary function which compares two function signatures and names.

Example

import { Fn, Num } from 'tiinvo'

const cmpMul = Fn.cmp(Num.mul);

cmpMul(Num.mul) // 0
cmpMul(Num.sub) // 1
cmpMul(Num.add) // -1

Since

4.0.0

Parameters

Name Type Description
a AnyFn the second function

Returns

Unary<T, ComparableResult>

the unary function which checks

Defined in

src/Fn.ts:221


eq

eq(a, b): boolean

Checks if two functions are the same.

It will check that both function have:

Example

import { Fn, Num } from 'tiinvo'

Fn.eq(Num.add, Num.add) // true
Fn.eq(Num.add, Num.sub) // false
Fn.eq(Num.sub, Num.add) // false

Since

4.0.0

Parameters

Name Type Description
a AnyFn the first function
b AnyFn the second function

Returns

boolean

Defined in

src/Fn.ts:271

eq(a): Unary<T, boolean>

Returns a unary function which checks if two functions are the same.

It will check that both function have:

Example

import { Fn, Num } from 'tiinvo'

const isadd = Fn.eq(Num.add)

isadd(Num.add) // true
isadd(Num.sub) // false
isadd(Num.add) // false

Since

4.0.0

Parameters

Name Type Description
a AnyFn the first function

Returns

Unary<T, boolean>

the unary function which accepts a second function and returns

Defined in

src/Fn.ts:299


length

length(a): number

Returns a function arguments length

Example

import { Fn } from 'tiinvo'

Fn.length(Fn.cmp)        // 2
Fn.length(Fn.length)     // 1

Since

4.0.0

Parameters

Name Type
a AnyFn

Returns

number

arguments count

Defined in

src/Functors.ts:465


name

name(a): string

Returns a function’s name

Example

import { Fn } from 'tiinvo'

Fn.name(Fn.cmp)        // 'cmp'
Fn.name(Fn.name)       // 'name'

Since

4.0.0

Parameters

Name Type
a AnyFn

Returns

string

the name

Defined in

src/Functors.ts:465


guard

guard(x): x is AnyFn

Checks if an argument x is AnyFn

Example

import { Fn } from 'tiinvo'

Fn.guard(10)         // false
Fn.guard(() => {})   // true

Since

4.0.0

Parameters

Name Type Description
x unknown the value to guard

Returns

x is AnyFn

Defined in

src/Fn.ts:370


map

map<a, b>(...ml): (a: a) => b[]

Maps a value a over a list of Functors.Mappable<a, b> and returns an array of the returning values

Example

import { Fn, Num } from 'tiinvo'

const m = Fn.map(
   Num.add(1), 
   Num.mul(2), 
   Num.sub(3), 
   Num.pow(4),
)

m(2)   // [3, 4, -1, 16]

Since

4.0.0

Type parameters

Name
a
b

Parameters

Name Type Description
...ml Mappable<a, b>[] a list of unary functions which accept the same argument

Returns

fn

an array of the returning values of ml

▸ (a): b[]

Parameters
Name Type
a a
Returns

b[]

Defined in

src/Fn.ts:398