Guest User

Untitled

a guest
Feb 17th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. config = reduce(argv, (acc, val, key) => {
  2. if (key === '_') return acc;
  3. return Object.assign(acc, { [key]: val });
  4. }, config);
  5.  
  6. function reduce(obj, callback, initalValue) {
  7. return Object.keys(obj).reduce((acc, key) => {
  8. return callback(acc, obj[key], key);
  9. }, initalValue);
  10. }
  11.  
  12. reduce({ test: 12 }, (acc, val, key) => Object.assign(acc, { [key]: val }), { test: 122 });
Add Comment
Please, Sign In to add comment