reduce-keys
v0.1.5
Published
Get Refile URL from key using SHA.
Downloads
5
Readme
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