Skip to content

Commit

Permalink
Use es6 default args syntax, rebuild, clarify docs a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean O'Donohue committed Feb 1, 2017
1 parent 865b809 commit bb7812f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Use cases:
const Random = require('rando-js');

// Simulate a coinflip
if (Random.coinflip()) { /* something that has ~50% chance of happening */}
if (Random.coinflip()) { /* something that has ~50% chance of happening */ }

// Roll a stat for your D&D character
const charisma = Random.roll(3, 6) // anything from 3 to 18
const d20 = Random.roll() // default args are 1, 20.

// Get something from an array
const choice = Random.fromArray([a, b, c, d]) // a, b, c, or d
Expand Down
7 changes: 4 additions & 3 deletions dist/rando.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/rando.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/rando.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/rando.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rando-js",
"version": "0.1.0",
"version": "0.1.1",
"description": "Randomization utilities for NodeJS in es6",
"main": "rando.js",
"devDependencies": {
Expand Down
4 changes: 1 addition & 3 deletions rando.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ class Random {
* @return int Result of roll
*/

static roll(dice, sides) {
dice = dice || 1;
sides = sides || 20;
static roll(dice = 1, sides = 20) {
return dice * (Math.floor(sides * Math.random()) + 1);
}

Expand Down

0 comments on commit bb7812f

Please sign in to comment.