Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / lang / isEqual.js
1 var baseIsEqual = require('../internal/baseIsEqual'),
2     bindCallback = require('../internal/bindCallback');
3
4 /**
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]).
10  *
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.
16  *
17  * @static
18  * @memberOf _
19  * @alias eq
20  * @category Lang
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`.
26  * @example
27  *
28  * var object = { 'user': 'fred' };
29  * var other = { 'user': 'fred' };
30  *
31  * object == other;
32  * // => false
33  *
34  * _.isEqual(object, other);
35  * // => true
36  *
37  * // using a customizer callback
38  * var array = ['hello', 'goodbye'];
39  * var other = ['hi', 'goodbye'];
40  *
41  * _.isEqual(array, other, function(value, other) {
42  *   if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) {
43  *     return true;
44  *   }
45  * });
46  * // => true
47  */
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;
52 }
53
54 module.exports = isEqual;