UNPKG

596 BJavaScriptView Raw
1/*!
2 * is-equal-shallow <https://github.com/jonschlinkert/is-equal-shallow>
3 *
4 * Copyright (c) 2015, Jon Schlinkert.
5 * Licensed under the MIT License.
6 */
7
8'use strict';
9
10var isPrimitive = require('is-primitive');
11
12module.exports = function isEqual(a, b) {
13 if (!a && !b) { return true; }
14 if (!a && b || a && !b) { return false; }
15
16 var numKeysA = 0, numKeysB = 0, key;
17 for (key in b) {
18 numKeysB++;
19 if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) {
20 return false;
21 }
22 }
23 for (key in a) {
24 numKeysA++;
25 }
26 return numKeysA === numKeysB;
27};