From 138bf0690eada58869756f42f7479f6c073e9a0b Mon Sep 17 00:00:00 2001 From: Trevor Richardson Date: Thu, 27 Jul 2017 13:50:34 -0500 Subject: [PATCH 1/4] feat(build): Added bable-preset-stage-3 that supports destructuring --- .babelrc | 3 ++- package.json | 1 + rollup.config.js | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.babelrc b/.babelrc index 57491d25..2f924bc4 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,7 @@ { "presets": [ - "es2015-node" + "es2015-node", + "stage-3" ], "plugins": [ "babel-plugin-transform-exponentiation-operator" diff --git a/package.json b/package.json index 0e4712cd..83cc4680 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-preset-es2015-node": "6.1.1", "babel-preset-es2015-rollup": "3.0.0", + "babel-preset-stage-3": "6.24.1", "babel-register": "6.24.1", "chai": "4.1.0", "coveralls": "2.13.1", diff --git a/rollup.config.js b/rollup.config.js index 237c7520..6e0b7d7f 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -7,7 +7,10 @@ export default { babel({ babelrc: false, exclude: ['./node_modules/**'], - presets: ['es2015-rollup'], + presets: [ + 'es2015-rollup', + 'stage-3' + ], plugins: ['babel-plugin-transform-exponentiation-operator'] }) ], From 9eda5d8a0df6dd9717edf5a95cbb652b40d30c03 Mon Sep 17 00:00:00 2001 From: Trevor Richardson Date: Thu, 27 Jul 2017 14:01:51 -0500 Subject: [PATCH 2/4] feat(word): Word generation now defaults to 3 syllables Previously issues were being caused by times when keys were being generated as `id` for example. This caused issues when wanting to do things like `{[any.word()]: any.string(), id: any.simpleObject()}` as the desired 'id' key would get stomped. --- any.js | 4 ++-- test/unit/any-test.js | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/any.js b/any.js index a2caeff7..f0d619db 100644 --- a/any.js +++ b/any.js @@ -16,7 +16,7 @@ const DEFAULT_SIZE_RANGE = {max: 20, min: 1}; const integer = options => chance.natural(options); const float = options => chance.floating(options); const string = options => chance.string(options); -const word = options => chance.word(options); +const word = options => chance.word({syllables: 3, ...options}); const sentence = options => chance.sentence(options); const paragraph = options => chance.paragraph(options); const url = options => chance.url(options); @@ -29,7 +29,7 @@ function simpleObject() { const size = integer(DEFAULT_SIZE_RANGE); for (let i = 0; i < size; i += 1) { - object[word({syllables: 3})] = string(); + object[word()] = string(); } return object; diff --git a/test/unit/any-test.js b/test/unit/any-test.js index b69997ca..596ee135 100644 --- a/test/unit/any-test.js +++ b/test/unit/any-test.js @@ -48,11 +48,19 @@ suite('random data generator', () => { test('that a word is generated', () => { const word = chance.word(); - chanceStub.word.withArgs(options).returns(word); + chanceStub.word.withArgs({syllables: 3, ...options}).returns(word); assert.equal(any.word(options), word); }); + test('that syllables can be overridden', () => { + const word = chance.word(); + const expectedSyllables = any.integer(); + chanceStub.word.withArgs({syllables: expectedSyllables, ...options}).returns(word); + + assert.equal(any.word({syllables: expectedSyllables, ...options}), word); + }); + test('that a sentence is generated', () => { const sentence = chance.sentence(); chanceStub.sentence.withArgs(options).returns(sentence); From 6b3937774843288910f5215a456ffa3b1ca7924f Mon Sep 17 00:00:00 2001 From: Trevor Richardson Date: Fri, 28 Jul 2017 10:24:34 -0500 Subject: [PATCH 3/4] feat(npmrc): Now enforcing pinning exact versions for deps --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..cffe8cde --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +save-exact=true From 382ec8a7e3754af90b0a7c8c601acbf62a0ff578 Mon Sep 17 00:00:00 2001 From: Trevor Richardson Date: Fri, 28 Jul 2017 10:34:09 -0500 Subject: [PATCH 4/4] chore(package-contributors): Added Trevor Richardson as project contributor --- package.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package.json b/package.json index 83cc4680..67d596d3 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,13 @@ "chance" ], "author": "Matt Travi (https://matt.travi.org/)", + "contributors": [ + { + "name": "Trevor Richardson", + "email": "tr@trevorrichardson.me", + "url": "https://twitter.com/intelxdesign" + } + ], "license": "MIT", "bugs": { "url": "https://github.com/travi/any/issues"