Simplify mapKey and mapValue.

This commit is contained in:
John-David Dalton
2017-04-15 23:23:17 -05:00
parent 0bdc73195f
commit 8b74809f1c
2 changed files with 5 additions and 8 deletions

View File

@@ -1,5 +1,3 @@
import baseAssignValue from './.internal/baseAssignValue.js'
/**
* The opposite of `mapValue` this method creates an object with the
* same values as `object` and keys generated by running each own enumerable
@@ -21,8 +19,9 @@ import baseAssignValue from './.internal/baseAssignValue.js'
*/
function mapKey(object, iteratee) {
const result = {}
Object.keys(object).forEach((value, key, object) => {
baseAssignValue(result, iteratee(value, key, object), value)
Object.keys(Object(object)).forEach((key) => {
const value = object[key]
result[iteratee(value, key, object)] = value
})
return result
}