A collection of functions for JavaScript that simplify my life. All functions are wrapped if objects, which serve to categorize them.
A collection of functions for generating random numbers. Wrapped in rand object.
float(): random number generator
Usage:
rand.float()
- returns random number between 0 and 1rand.float(max)
- returns random number between 0 and max.rand.float(min, max)
- returns random number between min and max, max excluded.
int(): random integer generator
Usage:
rand.int()
- returns 0 or 1rand.int(max)
- returns random integer between 0 and max.rand.int(min, max)
- returns random integer between min and max, max included.
fint(): random floored integer generator
Usage:
rand.int(max)
- returns random integer between 0 and max, max excluded.rand.int(min, max)
- returns random integer between min and max, max excluded.
A collection of converting functions Wrapped in convert object.
itoa(): Converts integer to a character. Number is treated as character unicode value.
Usage:
convert.itoa(int)
- returs character of int code. For example specifying 75 as int will result in return of 'K' char.
atoi(): Converts a character to it's unicode value.
Usage:
convert.atoi(char)
- returns unicode value of specified character.
ith(): Converts integer to it's hex value.
Usage:
convert.ith(int)
- returns hex value of specified integer.
itph(): Converts integer to it's hax value, padding it with zeroes.
Usage:
convert.itph(int, lenght)
- returns hex value of specified integer, padded with n zeroes. Parameterlenght
indicates lenght of returned string.
Example:convert.itph(30, 4);
will return001E
.
The string will not get trimmed
Example:convert.itph(300, 1);
will result in12C
.
- Hex to int converter
- int to bin converter
- bin to int converter