Methods

static

abs(n) → number

Calculates the absolute value of n

Parameter

Name Type Optional Description

n

number

 

Returns

number 

static

absdiff(a, b) → number

Returns the absolute difference between a and b

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

number 

static

add(a, b) → number

Casts a and b using Number constructor, then adds them using + operator

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

number 

static

ceil(n) → number

Rounds n up to the nearest integer

Parameter

Name Type Optional Description

n

number

 

Returns

number 

static

clamp(n, min, max) → number

Clamps n between min and max

Parameters

Name Type Optional Description

n

number

 

min

number

 

max

number

 

Returns

number 

static

div(a, b) → number

Casts a and b using Number constructor, then divides them using / operator

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

number 

static

even(n) → boolean

Checks if n is even

Parameter

Name Type Optional Description

n

number

 

Returns

boolean 

static

exp(b, e[, m]) → number

Calculates b ** m (optionally modulo m)

Parameters

Name Type Optional Description

b

number

 

e

number

 

m

number

Yes

Returns

number 

static

floor(n) → number

Rounds n down to the nearest integer

Parameter

Name Type Optional Description

n

number

 

Returns

number 

static

gt(a, b) → boolean

Checks if a is greater than b

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

boolean 

static

gte(a, b) → boolean

Checks if a is greater than or equal to b

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

boolean 

static

inrange(n, min, max) → boolean

Checks if n is in the range [min, max] (inclusive)

Parameters

Name Type Optional Description

n

number

 

min

number

 

max

number

 

Returns

boolean 

static

lt(a, b) → boolean

Checks if a is less than b

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

boolean 

static

lte(a, b) → boolean

Checks if a is less than or equal to b

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

boolean 

static

max(iter) → number

Calculates the maximum of an iterable using the builtin Math.max

Example

max([2, 1, 3]) // 3

Parameter

Name Type Optional Description

iter

Iterable containing any type

 

The iterable to find the maximum of

Returns

number 

static

min(iter) → number

Calculates the minimum of an iterable using the builtin Math.min

Example

min([2, 1, 3]) // 1

Parameter

Name Type Optional Description

iter

Iterable containing any type

 

The iterable to find the minimum of

Returns

number 

static

mod(a, b) → number

Casts a and b using Number constructor, then calculates a % b (note: this is not true modulo, just remainder after division)

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

number 

static

mul(a, b) → number

Casts a and b using Number constructor, then multiplies them using * operator

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

number 

static

odd(n) → boolean

Checks if n is odd

Parameter

Name Type Optional Description

n

number

 

Returns

boolean 

static

round(n) → number

Rounds n to the nearest integer

Parameter

Name Type Optional Description

n

number

 

Returns

number 

static

sign(n) → number

Calculates the sign of n

Parameter

Name Type Optional Description

n

number

 

Returns

number 

static

sqrt(n) → number

Calculates the square root of n

Parameter

Name Type Optional Description

n

number

 

Returns

number 

static

sub(a, b) → number

Casts a and b using Number constructor, then subtracts them using - operator

Parameters

Name Type Optional Description

a

number

 

b

number

 

Returns

number 

static

wrapindex(index, length) → number

Wraps index around length (for indexing into to arrays, strings, etc.)

Parameters

Name Type Optional Description

index

number

 

length

number

 

Returns

number