Skip to content

Commit 75694c0

Browse files
committed
Use map-obj utility
1 parent 266b0bd commit 75694c0

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"figures": "^3.2.0",
5757
"filter-obj": "^2.0.1",
5858
"jest-validate": "^25.1.0",
59+
"map-obj": "^4.1.0",
5960
"moize": "^5.4.5",
6061
"supports-color": "^7.1.0"
6162
},

src/utils.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import mapObj from 'map-obj'
2+
13
// Like Lodash mapValues()
24
export const mapValues = function (object, mapper) {
3-
const pairs = Object.entries(object).map(([key, value]) => [
4-
key,
5-
mapper(value, key),
6-
])
7-
return Object.fromEntries(pairs)
5+
return mapObj(object, (key, value) => [key, mapper(value, key)])
86
}
97

108
// Like Lodash result(), but faster

0 commit comments

Comments
 (0)