From 425647bcf09f351c75ab6fe4ec789f2a89f70ae3 Mon Sep 17 00:00:00 2001 From: planttheidea Date: Thu, 6 Jun 2019 08:56:35 -0700 Subject: [PATCH] fix contrived example, both in test and in README --- README.md | 2 +- __tests__/__fixtures__/nested/contrived/code.js | 12 ++++++++---- __tests__/__fixtures__/nested/contrived/output.js | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4459322e..2df82d6e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ function contrivedExample(array) { const doubleObject = reduce(doubled, (object, value) => ({ ...object, [value]: value - }); + }, {}); if (someObject(doubleObject, (value) => value > 100)) { console.log('I am large!'); diff --git a/__tests__/__fixtures__/nested/contrived/code.js b/__tests__/__fixtures__/nested/contrived/code.js index 00e8021b..0af757f0 100644 --- a/__tests__/__fixtures__/nested/contrived/code.js +++ b/__tests__/__fixtures__/nested/contrived/code.js @@ -2,10 +2,14 @@ import { map, reduce, someObject } from '../../../../src/inline-loops.macro'; if ( someObject( - reduce(map(array, value => value * 2), (object, value) => ({ - ...object, - [value]: value, - })), + reduce( + map(array, value => value * 2), + (object, value) => ({ + ...object, + [value]: value, + }), + {}, + ), value => value > 100, ) ) { diff --git a/__tests__/__fixtures__/nested/contrived/output.js b/__tests__/__fixtures__/nested/contrived/output.js index fd8efa11..16f8e11b 100644 --- a/__tests__/__fixtures__/nested/contrived/output.js +++ b/__tests__/__fixtures__/nested/contrived/output.js @@ -6,9 +6,9 @@ for (let _key = 0, _length = array.length, _value; _key < _length; ++_key) { _result.push(_value * 2); } -let _result2 = _result[0]; +let _result2 = {}; -for (let _key2 = 1, _length2 = _result.length, _value2; _key2 < _length2; ++_key2) { +for (let _key2 = 0, _length2 = _result.length, _value2; _key2 < _length2; ++_key2) { _value2 = _result[_key2]; _result2 = { ..._result2, [_value2]: _value2