1.0.6 • Published 2 years ago
oddity.js v1.0.6
oddity.js
Oddity is a library of random data generation and utils functions like sum
or sort
.
Installation
JavaScript:
const { odd } = require("oddity.js");
console.log(odd.pick(["Hello!", 1, 10, "Test", "Ciao", 28, false, null]));
//=> "Ciao"
TypeScript:
import { odd } from "oddity.js";
console.log(odd.sort([1, 3, 334, 5, 29, 7]));
//=> [1, 3, 5, 7, 29, 334]
list of function in this lib:
Random data generation
rng
- random number generatorflip
- coin flip, with chance set default at 50%falsy
- pick a random falsy valueletter
- get a random letterstring
- generate a random stringage
- generate a random person's agedate
- generate a random dateroll
- roll any and as many dice as you want!animal
- get a random animal's namename
- get a random first namecountry
- get a random countryemoji
- get a random emojipokemon
- get a random pokemon's nameip
- get a random ip address
Validators
isString
- checks if the input value is a stringisNumber
- checks if the input value is a numberisPrime
- check if the input value is a prime number
Math
fibonacci
- get as many values as you want of the Fibonacci chaininvSqrt
- Quake III algorythm of the inverse square rootfactorial
- calculates the factorial of the input value
Arrays
sum
- returns the sum of all the numbers in an arraysub
- returns the subctraction od all the numbers in an array starting from index 0pick
- returns a random item in an arrayshuffle
- shuffles a given arraysort
- sorts an array (numbers)clone
- clones an arraybinary
- binary search algorythm of a number in an arraypush0toEnd
- pushes all the 0s in an array to the end of it
Misc
deck
- generates a 52 or 54 (Jokers) deck of french playing cardsroulette
- generates an array of colored numbers, which represent a french roulette.
Thank you! 🌸