Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
dispatch keyed values to keyed functions
const branchDispatch = (obj, table, defaultFn) =>
.map(([key, value]) =>
table[key] != null
? [key, table[key](value)]
: typeof defaultFn === 'function'
? [key, defaultFn(value)]
: [key, undefined]
.reduce((results, [key, value]) => {
results[key] = value
return results
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment