0.1.5 • Published 7 years ago

reduce-keys v0.1.5

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

reduce-keys

Implementation

See https://github.com/evanx/reduce-keys/blob/master/index.js

module.exports = (keys, fn, defaultObject = {}) => keys.reduce((object, key) => {
    object[key] = fn(key);
    return object;
}, defaultObject);

Test

See https://github.com/evanx/reduce-keys/blob/master/test.js

const reduceKeys = require('./index.js');
const result = reduceKeys(['a', 'b'], key => 'c');
const expectedResult = { a: 'c', b: 'c' };
console.log({result});
if (JSON.stringify(result) !== JSON.stringify(expectedResult)) {
    throw new Error('FAIL');
}
console.log('PASS');

https://twitter.com/@evanxsummers

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago