Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Use a loop intead of reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed May 10, 2016
1 parent da24809 commit 9892f2b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/packages/recompose/utils/pick.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const pick = (obj, keys) =>
keys.reduce((result, key) => {
result[key] = obj[key]
return result
}, {})
const pick = (obj, keys) => {
const result = {}
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if (obj.hasOwnProperty(key)) {
result[key] = obj[key]
}
}
return result
}

export default pick

0 comments on commit 9892f2b

Please sign in to comment.