This package empowers you to develop.
yarn add @jamashita/steckdose
> node -v
v20.12.2
> npm -v
10.5.0
> yarn -v
1.22.21
git cz
A class for performing arithmetic operations.
Calculates the average of a series of numbers. The iterable
parameter is an iterable object containing the numbers to
calculate the average of. The method returns the average of the numbers in the iterable
as a floating-point number.
If the length of the given iterable is 0, an ArithmeticError
will be thrown.
Calculates the number of combinations of m
items that can be selected from a set of n
items. The n
and m
parameters are positive integers representing the values to use in the calculation. The method returns the number of
combinations as an integer.
If n
is less than m
, or either n
or m
are not positive integers, an ArithmeticError
will be thrown.
Calculates the deviation of a series of numbers. The iterable
parameter is an iterable object containing the numbers
to
calculate the deviation of. The method returns the deviation of the numbers in the iterable
as a floating-point
number.
If the length of the given iterable is 0, an ArithmeticError
will be thrown.
Calculates the factorial of a number n
. The n
parameter is a positive integer representing the value to use in the
calculation. The method returns the factorial of n
as an integer.
If n
is not a positive integer, an ArithmeticError
will be thrown.
Generates a random floating-point number in the range [min, max), where min
is inclusive and max
is exclusive. The
function returns a random number that is greater than or equal to min
and less than max
.
Calculates the greatest common divisor (GCD) of two positive integers n
and m
. The n
and m
parameters are the
positive integers to use in the calculation. The method returns the GCD of n
and m
as an integer.
If n
is not a positive integer, or if n
is less than m
, an ArithmeticError will be thrown.
Generates a random integer in the range [min, max], inclusive. The function returns a random number that is greater than
or equal to min
and less than or equal to max
.
Calculates the inverse of a number num
. The num parameter is the value to use in the calculation. The method returns
the inverse of num
as a floating-point number.
If num is equal to 0, an ArithmeticError
will be thrown.
Calculates the least common multiple (LCM) of two positive integers n
and m
. The n
and m
parameters are the
positive integers to use in the calculation. The method returns the LCM of n
and m
as an integer.
If n
is not a positive integer, or if n
is less than m
, an ArithmeticError
will be thrown.
Calculates the median of a series of numbers. The iterable
parameter is an iterable object containing the numbers to
calculate the median of. The method returns the median of the numbers in the iterable
as a floating-point number.
If the length of the given iterable is 0, an ArithmeticError
will be thrown.
Calculates the negation of a number num
. The num
parameter is the value to negate. The method returns the negation
of num
as a floating-point number.
Calculates the number of permutations of m
items that can be selected from a set of n
items. The n
and m
parameters are positive integers representing the values to use in the calculation. The method returns the number of
permutations as an integer.
If n
is less than m
, or either n
or m
are not positive integers, an ArithmeticError
will be thrown.
Generates a random floating-point number in the range [0, 1). The function returns a random number that is greater than or equal to 0 and less than 1.
Calculates the variance of a series of numbers. The iterable
parameter is an iterable object containing the numbers to
calculate the variance of. The method returns the variance of the numbers in the iterable
as a floating-point number.
If the length of the given iterable
is 0, an ArithmeticError
will be thrown.
A class for reading configuration files.
The package reads the configuration file in the following format: dir
/env
.json (or .yml, .yaml). The following
conditions apply to the constructor:
The package tries to read the configuration file in the order .json, .yml, .yaml. If a file is found, it stops searching
and does not attempt to read any other files. If no file is found, ConfigError
is thrown.
Regardless of the specified environment, the package will attempt to read the default.json
, default.yml
,
or default.yaml
file. If it exists, it will be merged with the environment-specific file to create the final
configuration object.
Retrieves the value of a specified property from the configuration object. The property parameter is a string that
represents the name of the property to retrieve, and it can handle nested properties using a dot-notation (e.g. a.b.c).
The method returns a value of the specified type T
.
Checks if a specified property exists in the configuration object. The property parameter is a string that represents the name of the property to check and supports dot-notation for nested properties (e.g. a.b.c). The method returns a boolean value indicating whether the property exists in the configuration object.
A class for delaying the process for a certain amount of time in milliseconds.
Creates a new function that will delay the execution of callback
by ms
milliseconds. The new function will be
returned and it can be used to replace the original function callback
.
Creates a promise that will wait for a random number of milliseconds between minMS
and maxMS
. The
Promise will resolve with void after the specified random wait time has passed.
Creates a new function that will limit the rate of execution of callback
to once every ms
milliseconds. The returned
function will replace the original callback
and can be used in its place. The returned function will be called
immediately, and subsequent calls to the function will be ignored until ms
milliseconds have passed.
Returns a Promise that will resolve after ms
milliseconds have passed.
A class for generating and comparing cryptographic hashes, using bcrypt.
Returns a new Digest
instance, with the specified number of rounds
for the bcrypt algorithm. The higher the number
of rounds
, the more secure the resulting hash will be, but it will also take longer to generate.
Compares the given str
with the provided hash
, and returns a promise that resolves to true
if they match,
and false
otherwise.
Generates a cryptographic hash of the provided str
, using the number of rounds specified in the Digest constructor.
Returns a promise that resolves to the resulting hash.
An enum for representing HTTP status codes.
A class for asynchronously parsing JSON from a string and stringifying JSON to a string.
Asynchronously returns a JavaScript object from the provided JSON string.
Asynchronously returns a JSON string representation of the provided JavaScript object.
A class for calculating probabilities. This class implements the Opportunity
interface.
Returns a new Probability
instance that represents the probability of both this event and another event occurring.
Returns a new Probability
instance that represents the probability of the event not occurring.
Returns a new Probability
instance that represents the probability of at least one of the two events occurring.
Returns a new Probability
instance that represents the probability of either event occurring exclusively, meaning that
only one of the events can occur, but not both.
An interface for defining a chance of something happening.
Returns a boolean value indicating whether a random event has occurred. If the probability of the event happening is 1,
then this method will always return true
. If the probability is 0, then this method will always return false
.
Otherwise, the result is determined randomly based on the probability of the event happening.
A class for defining a chance of something happening, based on the probability of multiple events occurring simultaneously. It provides methods to combine the probabilities of individual events to calculate the overall probability of all the events occurring together.
A class that represents the probability of an event occurring as a decimal value. It can be used to define the chance of something happening based on the probability of the event occurring.
A class that represents the probability of an event occurring as a fraction value. It can be used to define the chance of something happening based on the probability of the event occurring. This class allows users to specify the numerator and denominator of a fraction.
A class that represents the probability of an event not occurring. It can be used to define the chance of something happening based on the probability of the event not occurring, or the absence of the event.
A class for generating random values.
Generates a random floating-point number in the range [min, max), where min
is inclusive and max
is exclusive. The
function returns a random number that is greater than or equal to min
and less than max
.
Generates a random integer in the range [min, max], inclusive. The function returns a random number that is greater than
or equal to min
and less than or equal to max
.
Returns a random element from the provided iterable
.
If the iterable
is empty, a RandomError
will be thrown.
Generates a random floating-point number in the range [0, 1). The function returns a random number that is greater than or equal to 0 and less than 1.
Generates a random string of the specified length
using the characters in the pool
string. By default, the pool
string contains all uppercase and lowercase letters and digits, but you can provide a custom pool
string to generate a
string using a different set of characters.
A class for tokenizing a string by a certain delimiter.
Returns a Tokenizer instance.
Returns the number of tokens.
Returns the tokens as an array.