added _.isEqual definition

This commit is contained in:
Brian Zengel
2013-10-20 16:31:25 -04:00
parent 41b56088b2
commit 3b13bf7436
2 changed files with 35 additions and 12 deletions
+17 -4
View File
@@ -601,6 +601,22 @@ result = <boolean>_.isEmpty([1, 2, 3]);
result = <boolean>_.isEmpty({});
result = <boolean>_.isEmpty('');
var moe = { 'name': 'moe', 'age': 40 };
var copy = { 'name': 'moe', 'age': 40 };
result = <boolean>_.isEqual(moe, copy);
var words = ['hello', 'goodbye'];
var otherWords = ['hi', 'goodbye'];
result = <boolean>_.isEqual(words, otherWords, function(a, b) {
var reGreet = /^(?:hello|hi)$/i,
aGreet = _.isString(a) && reGreet.test(a),
bGreet = _.isString(b) && reGreet.test(b);
return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
});
var mergeNames = {
'stooges': [
@@ -671,10 +687,7 @@ _.chain([1, 2, 3, 200])
.map(function (num: number) { return num * num })
.value();
var moe = { name: 'moe', luckyNumbers: [13, 27, 34] };
var clone = { name: 'moe', luckyNumbers: [13, 27, 34] };
moe == clone;
_.isEqual(moe, clone);
+18 -8
View File
@@ -2399,6 +2399,23 @@ declare module _ {
**/
export function isEmpty(value: string): boolean;
/**
* Performs a deep comparison between two values to determine if they are equivalent to each
* other. If a callback is provided it will be executed to compare values. If the callback
* returns undefined comparisons will be handled by the method instead. The callback is bound to
* thisArg and invoked with two arguments; (a, b).
* @param a The value to compare.
* @param b The other value to compare.
* @param callback The function to customize comparing values.
* @param thisArg The this binding of callback.
* @return True if the values are equivalent, else false.
**/
export function isEqual(
a: any,
b: any,
callback?: (a, b) => boolean,
thisArg?: any): boolean;
/**
* Recursively merges own enumerable properties of the source object(s), that don't resolve
* to undefined into the destination object. Subsequent sources will overwrite property
@@ -2612,14 +2629,7 @@ declare module _ {
**/
export function tap<T>(object: T, intercepter: Function): T;
/**
* Performs an optimized deep comparison between the two objects,
* to determine if they should be considered equal.
* @param object Compare to `other`.
* @param other Compare to `object`.
* @return True if `object` is equal to `other`.
**/
export function isEqual(object: any, other: any): boolean;