1 var baseIsEqual = require('../internal/baseIsEqual'),
2 bindCallback = require('../internal/bindCallback');
5 * Performs a deep comparison between two values to determine if they are
6 * equivalent. If `customizer` is provided it's invoked to compare values.
7 * If `customizer` returns `undefined` comparisons are handled by the method
8 * instead. The `customizer` is bound to `thisArg` and invoked with up to
9 * three arguments: (value, other [, index|key]).
11 * **Note:** This method supports comparing arrays, booleans, `Date` objects,
12 * numbers, `Object` objects, regexes, and strings. Objects are compared by
13 * their own, not inherited, enumerable properties. Functions and DOM nodes
14 * are **not** supported. Provide a customizer function to extend support
15 * for comparing other values.
21 * @param {*} value The value to compare.
22 * @param {*} other The other value to compare.
23 * @param {Function} [customizer] The function to customize value comparisons.
24 * @param {*} [thisArg] The `this` binding of `customizer`.
25 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
28 * var object = { 'user': 'fred' };
29 * var other = { 'user': 'fred' };
34 * _.isEqual(object, other);
37 * // using a customizer callback
38 * var array = ['hello', 'goodbye'];
39 * var other = ['hi', 'goodbye'];
41 * _.isEqual(array, other, function(value, other) {
42 * if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) {
48 function isEqual(value, other, customizer, thisArg) {
49 customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;
50 var result = customizer ? customizer(value, other) : undefined;
51 return result === undefined ? baseIsEqual(value, other, customizer) : !!result;
54 module.exports = isEqual;