Skip to content

Commit

Permalink
Start cwds
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 27, 2022
1 parent dc0ad1a commit 36b70ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/recurse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import { mapValues } from './map.js'

// Apply a mapping function over all values of an object or array.
// Only recurse over arrays and plain objects.
export const recurseValues = function (value, mapper) {
export const recurseValues = function (
value,
mapper,
canRecurseObj = isPlainObj,
) {
const valueA = mapper(value)

if (isPlainObj(valueA)) {
if (canRecurseObj(valueA)) {
return mapValues(valueA, (child) => recurseValues(child, mapper))
}

Expand Down

0 comments on commit 36b70ce

Please sign in to comment.