Files
30-seconds-of-code/test/matchesWith/matchesWith.js
2018-08-02 13:49:33 +03:00

9 lines
240 B
JavaScript

const matchesWith = (obj, source, fn) =>
Object.keys(source).every(
key =>
obj.hasOwnProperty(key) && fn
? fn(obj[key], source[key], key, obj, source)
: obj[key] == source[key]
);
module.exports = matchesWith;