UNPKG
imma
Version:
latest (0.0.1)
0.0.1
A collection of functions for dealing with native arrays and objects immutably
imma
/
lib
/
object
/
equalsWith.js
12 lines
(11 loc)
•
311 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
'use strict'
const
equalsWith =
module
.
exports
=
(
a, b, fn
) =>
{
const
aKeys =
Object
.
keys
(a)
const
bKeys =
Object
.
keys
(b)
if
(aKeys.
length
!== bKeys.
length
)
return
false
for
(
let
key
of
aKeys) {
if
(!(key
in
b))
return
false
if
(!
fn
(a[key], b[key]))
return
false
}
return
true
}