Gimmea - Give Me A
A set of quick value generation tools.
Usage
npm install gimmea
UUID
Generate a UUID:
Gimmea; // gives something like e61c58d4-68fd-440e-a525-18e4112c7020
Hash
Generate a hash:
Gimmeahash'seed string'; // gives something like 761f2c5fbc3f8e50fa53eec2ceae5efb650846ba91bb58c249afbda70ebd537fGimmeahash'seed string' 10; // gives something like 761f2c5fbc
Slug
Slugifies a string:
Gimmea; // gives 'this-is-the-title'Gimmea; // gives something like 'thing-0e94c54d8d'
Weighted Random Value
Given an array of objects (each with an integer weight property), return one of the objects:
let loadedCoin = name: 'heads' weight: 1 name: 'tails' weight: 0 ;Gimmea; // Always { name: 'heads', weight: 1 } let lottery = name: 'Nathan' tickets: 10 name: 'Lilly' tickets: 1 ;Gimmea; // Nathan has 10 times the chances to win