Created
April 6, 2020 13:19
-
-
Save zArubaru/675752fb1042a560691d7d064e52cff0 to your computer and use it in GitHub Desktop.
lodash/fp mapValuesDeep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fp from 'lodash/fp'; | |
const mapValuesDeep = (callback, value) => { | |
if (fp.isArray(value)) { | |
return fp.map(value => mapValuesDeep(callback, value), value); | |
} else if (fp.isObject(value)) { | |
return fp.mapValues(value => mapValuesDeep(callback, value), value); | |
} else { | |
return callback(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment