2.0.0 • Published 5 years ago

gimmea v2.0.0

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

Gimmea - Give Me A

CircleCI

A set of quick value generation tools.

Usage

npm install gimmea

UUID

Generate a UUID:

Gimmea.uuid(); // gives something like e61c58d4-68fd-440e-a525-18e4112c7020

Hash

Generate a hash:

Gimmea.hash('seed string'); // gives something like 761f2c5fbc3f8e50fa53eec2ceae5efb650846ba91bb58c249afbda70ebd537f
Gimmea.hash('seed string', 10); // gives something like 761f2c5fbc

Slug

Slugifies a string:

Gimmea.slug('This is the Title!'); // gives 'this-is-the-title'
Gimmea.slug('Thing', 10); // 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.weightedRandomValue(loadedCoin); // Always { name: 'heads', weight: 1 }

let lottery = [
  {
    name: 'Nathan',
    tickets: 10
  },
  {
    name: 'Lilly',
    tickets: 1
  }
];
Gimmea.weightedRandomValue(lottery, 'tickets'); // Nathan has 10 times the chances to win
2.0.0

5 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago