Skip to content

Instantly share code, notes, and snippets.

@tjconcept
Created September 13, 2022 22:15
Show Gist options
  • Save tjconcept/96bd527afd601de606889599862be07d to your computer and use it in GitHub Desktop.
Save tjconcept/96bd527afd601de606889599862be07d to your computer and use it in GitHub Desktop.
"join" for objects (Promise.props)
export default function using(hash, fn) {
if (typeof fn !== 'function') {
throw new Error('Missing expected function argument')
}
return Promise.all(Object.values(hash)).then((values) =>
fn(
Object.fromEntries(
Object.keys(hash).map((key, idx) => [key, values[idx]])
)
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment