diff --git a/src/utils/bindActionCreators.js b/src/utils/bindActionCreators.js index 801665492c..f9a81a5a80 100644 --- a/src/utils/bindActionCreators.js +++ b/src/utils/bindActionCreators.js @@ -1,4 +1,4 @@ -import mapValues from 'lodash/object/mapValues'; +import mapValues from '../utils/mapValues'; export default function bindActionCreators(actionCreators, dispatch) { return mapValues(actionCreators, actionCreator => diff --git a/src/utils/composeStores.js b/src/utils/composeStores.js index 49b76c6d74..4122006ce4 100644 --- a/src/utils/composeStores.js +++ b/src/utils/composeStores.js @@ -1,4 +1,4 @@ -import mapValues from 'lodash/object/mapValues'; +import mapValues from '../utils/mapValues'; import pick from 'lodash/object/pick'; export default function composeStores(stores) { diff --git a/src/utils/mapValues.js b/src/utils/mapValues.js new file mode 100644 index 0000000000..29d203cf61 --- /dev/null +++ b/src/utils/mapValues.js @@ -0,0 +1,6 @@ +export default function mapValues(obj, fn) { + return Object.keys(obj).reduce((result, key) => { + result[key] = fn(obj[key], key); + return result; + }, {}); +} diff --git a/test/utils/mapValues.spec.js b/test/utils/mapValues.spec.js new file mode 100644 index 0000000000..36c3c6b2c9 --- /dev/null +++ b/test/utils/mapValues.spec.js @@ -0,0 +1,12 @@ +import expect from 'expect'; +import mapValues from '../../src/utils/mapValues'; + +describe('Utils', () => { + describe('mapValues', () => { + it('should return object with mapped values', () => { + const test = { 'a': 'c', 'b': 'd' }; + expect(mapValues(test, (val, key) => val + key)).toEqual({ 'a': 'ca', 'b': 'db' }); + }); + }); +}); +