Skip to content

Commit

Permalink
refactored to use es6
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Jun 1, 2016
1 parent c4f66c8 commit 23a61c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 46 deletions.
67 changes: 22 additions & 45 deletions any.js
@@ -1,38 +1,15 @@
var Chance = require('chance'),
chance = new Chance();
import Chance from 'chance';
const chance = new Chance();

const DEFAULT_SIZE_RANGE = {
max: 20,
min: 1
};

function integer(options) {
return chance.natural(options);
}

function string(options) {
return chance.string(options);
}

function word() {
return chance.word();
}
const DEFAULT_SIZE_RANGE = {max: 20, min: 1};

function url(options) {
return chance.url(options);
}

function boolean() {
return chance.bool();
}

function email() {
return chance.email();
}

function date() {
return chance.date({string: true});
}
const integer = (options) => chance.natural(options);
const string = (options) => chance.string(options);
const word = () => chance.word();
const url = (options) => chance.url(options);
const boolean = () => chance.bool();
const email = () => chance.email();
const date = () => chance.date({string: true});

function simpleObject() {
var object = {},
Expand All @@ -45,8 +22,8 @@ function simpleObject() {
return object;
}

function listOf(constructor, options) {
var options = options || {},
function listOf(constructor, options = {}) {
const
list = [],
listSize = options.size || integer(Object.assign({}, DEFAULT_SIZE_RANGE, options));

Expand All @@ -57,14 +34,14 @@ function listOf(constructor, options) {
return list;
}

module.exports = {
string: string,
word: word,
integer: integer,
boolean: boolean,
url: url,
email: email,
date: date,
simpleObject: simpleObject,
listOf: listOf
export {
string,
word,
integer,
boolean,
url,
email,
date,
simpleObject,
listOf
};
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -42,7 +42,7 @@
"grunt-contrib-clean": "1.0.0",
"grunt-mocha-istanbul": "5.0.1",
"grunt-rollup": "0.7.1",
"istanbul": "0.4.3",
"istanbul": "1.0.0-alpha.2",
"load-grunt-config": "0.19.2",
"mocha": "2.5.3",
"proxyquire": "1.7.9",
Expand Down

0 comments on commit 23a61c4

Please sign in to comment.