Guest User

Untitled

a guest
Jan 16th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /******************************************************************************
  2. * A reduce on an object (using lodash), returning result of promises.
  3. ******************************************************************************/
  4.  
  5. const getAll = async (connection, node) =>
  6. _.reduce(node, async (op, v, k) => {
  7. const o = await op
  8.  
  9. if (_.isString(v)) { o[k] = await executor(connection, v) }
  10. if (_.isObject(v)) { o[k] = await getAll(connection, v) }
  11.  
  12. return o
  13. }, Promise.resolve({}))
  14.  
  15. // initial does not really need to be a promise, but it's seem to be more clear
Add Comment
Please, Sign In to add comment