Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- * A reduce on an object (using lodash), returning result of promises.
- ******************************************************************************/
- const getAll = async (connection, node) =>
- _.reduce(node, async (op, v, k) => {
- const o = await op
- if (_.isString(v)) { o[k] = await executor(connection, v) }
- if (_.isObject(v)) { o[k] = await getAll(connection, v) }
- return o
- }, Promise.resolve({}))
- // 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