summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/map-values-deep/index.js
blob: d023a9ea3b3d20c21b3d0f2ace8d99e4ebe684e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'use strict'

const { map, isArray, isObject, isPlainObject, mapValues } = require('lodash')

const mapValuesDeep = (obj, fn, key) =>
  isArray(obj)
    ? map(obj, (innerObj, idx) => mapValuesDeep(innerObj, fn, idx))
    : isPlainObject(obj)
      ? mapValues(obj, (val, key) => mapValuesDeep(val, fn, key))
      : isObject(obj)
        ? obj
        : fn(obj, key)

module.exports = mapValuesDeep