Math Methods
average
Computes the average of the values
Since: 0.1.0
Arguments
Param | Type | Description |
---|---|---|
value | number[] | The values to calculate. |
Returns
Type | Description |
---|---|
number | Returns the average of values |
Declaration
declare function average(values: number[]): number;
Examples
average([1, 2, 3]); // 2
between
Checks if n is between start and up to end
Since: 0.1.0
Arguments
Param | Type | Description |
---|---|---|
number | number | The number to check. |
start | number | The start of the range. |
end | number | The end of the range. |
Returns
Type | Description |
---|---|
boolean | Returns true if number is in the range, else false . |
Declaration
declare function between(number: number, start: number, end: number): boolean;
Examples
between(3, 1, 5); // true
between(8, 1, 5); // false
clamp
Clamp number
Since: 0.1.0
Arguments
Param | Type | Description |
---|---|---|
number | number | The number to clamp |
lower | number | The lower bound |
upper | number | The upper bound |
Returns
Type | Description |
---|---|
number | Returns the clamped number |
Declaration
declare function clamp(number: number, lower: number, upper: number): number;
Examples
clamp(3, 1, 5); // 3
clamp(8, 1, 5); // 5
sum
Computes the sum of the values
Since: 0.1.0
Arguments
Param | Type | Description |
---|---|---|
value | number[] | The values to calculate. |
Returns
Type | Description |
---|---|
number | Returns the sum of values |
Declaration
declare function sum(values: number[]): number;
Examples
sum([1, 2, 3]); // 6