1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 02:37:25 -04:00
notes/node_modules/is-equal-shallow/index.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

28 lines
596 B
JavaScript

/*!
* is-equal-shallow <https://github.com/jonschlinkert/is-equal-shallow>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var isPrimitive = require('is-primitive');
module.exports = function isEqual(a, b) {
if (!a && !b) { return true; }
if (!a && b || a && !b) { return false; }
var numKeysA = 0, numKeysB = 0, key;
for (key in b) {
numKeysB++;
if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) {
return false;
}
}
for (key in a) {
numKeysA++;
}
return numKeysA === numKeysB;
};