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

Prefer own shallowEqual #353

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/packages/recompose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"module": "es/Recompose.js",
"dependencies": {
"change-emitter": "^0.1.2",
"fbjs": "^0.8.1",
"hoist-non-react-statics": "^1.0.0",
"symbol-observable": "^1.0.4"
},
Expand Down
16 changes: 15 additions & 1 deletion src/packages/recompose/shallowEqual.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
import shallowEqual from 'fbjs/lib/shallowEqual'
const shallowEqual = (a, b) => {
if (a === b) {
return true
}
if (!a || !b) {
return false
}
const keysA = Object.keys(a)
const keysB = Object.keys(b)
if (keysA.length !== keysB.length) {
return false
}
return keysA.every(key => a[key] === b[key])
}

export default shallowEqual