Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@ariesclark/number
Advanced tools
Fast, efficient, and easy-to-use number extensions for TypeScript.
Fast, efficient, and easy-to-use number extensions for TypeScript.
npm install @ariesclark/extensions
# Or directly, if you only need the number extension.
npm install @ariesclark/number
clamp
(function)Clamps a number within the range specified by the minimum and maximum values.
Parameters:
number
)number
)number
)returns: number
randomFloat
(function)[object Object],[object Object],[object Object],[object Object],[object Object]
RandomFunction
(type)A random number generator function that returns a float between 0 and 1.
defaultRandom
(variable: RandomFunction)The default random number generator function.
randomFunction
(function)Get the current random number generator function, or set a new one.
Parameters:
RandomFunction
) - The new random number generator function, or undefined
to get the current value, or null
to reset to the default.returns: RandomFunction
import { randomFunction } from '@ariesclark/number/random-function';
import { randomInt } from '@ariesclark/number/random-int';
randomInt(); // Random number between 0 and 100.
randomFunction(() => 0.5);
randomInt(); // Always 50.
pseudoRandomFloat
(function)Create a pseudo-random number generator from a seed.
Parameters:
string
)returns: RandomFunction
import {
pseudoRandomFloat,
randomFunction,
randomInt
} from '@ariesclark/number';
randomFunction(pseudoRandomFloat('hello world'));
randomInt(); // Predictable random number, based on the seed.
randomInt
(function)Get a random value between minimum
and maximum
.
Parameters:
0
*/
minimum (number
)100
*/
maximum (number
)RandomFunction
)returns: number
// eslint-disable-next-line no-shadow-restricted-names NaN, POSITIVE_INFINITY, isFinite, isInteger, isNaN, isSafeInteger, parseFloat, parseInt }` (variable)
sum
(function)Returns the sum of the numbers.
Parameters:
number[]
) - The numbers to sum.returns: number
average
(function)Returns the average of the numbers.
Parameters:
number[]
) - The numbers to average.returns: number
median
(function)Returns the median of the numbers.
Parameters:
number[]
) - The numbers to find the median of.returns: number
FAQs
Fast, efficient, and easy-to-use number extensions for TypeScript.
The npm package @ariesclark/number receives a total of 4 weekly downloads. As such, @ariesclark/number popularity was classified as not popular.
We found that @ariesclark/number demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.