Skip to content

Instantly share code, notes, and snippets.

@nicohvi

nicohvi/dict.js

Last active Dec 18, 2017
Embed
What would you like to do?
const dict = { 'Roger': { value: 'verdi', validationFn: f1 }, 'Ted': { value: 'verdi', validationFn: f2 } };
R.keys(dict)
.map(key => {
const old = dict[key];
return { key: { value: R.prop('value', old), isValid: R.prop('validationFn', old).apply(null, old) } };
})
.reduce((acc, item) => acc[R.prop('key', item] = item, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment