Skip to main content

neon_crisp / Modules / utils/numbers

Module: utils/numbers

Table of contents​

Functions​

Functions​

applyPercentage​

▸ applyPercentage(percentage, full): number

Calculates the value that corresponds to a given percentage of a full value.

Parameters​

NameTypeDescription
percentagenumberThe percentage to apply.
fullnumberThe full or maximum possible value.

Returns​

number

The calculated value based on the given percentage.

Example

applyPercentage(50, 32); // Returns 16

Defined in​

utils/numbers.ts:40


getPercentage​

▸ getPercentage(current, full): number

Calculates what percentage the current value is of the full value.

Parameters​

NameTypeDescription
currentnumberThe current value.
fullnumberThe full or maximum possible value.

Returns​

number

The percentage representation of the current value.

Example

getPercentage(250, 500); // Returns 50

Defined in​

utils/numbers.ts:26


percentageToDegrees​

▸ percentageToDegrees(whole, current, flip?): number

Converts a percentage to a value between 0 and 360, with an optional flag to flip the output.

Parameters​

NameTypeDefault valueDescription
wholenumberundefinedThe total or maximum value.
currentnumberundefinedThe current value to calculate the percentage of.
flipbooleanfalseOptional flag to flip the output (default is false).

Returns​

number

A number between 0 and 360 representing the percentage of the whole.

Defined in​

utils/numbers.ts:8