Skip to content

Instantly share code, notes, and snippets.

@zArubaru
Created April 6, 2020 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zArubaru/675752fb1042a560691d7d064e52cff0 to your computer and use it in GitHub Desktop.
Save zArubaru/675752fb1042a560691d7d064e52cff0 to your computer and use it in GitHub Desktop.
lodash/fp mapValuesDeep
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