diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 28c148e75..3d3eef68d 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -601,6 +601,22 @@ result = _.isEmpty([1, 2, 3]); result = _.isEmpty({}); result = _.isEmpty(''); +var moe = { 'name': 'moe', 'age': 40 }; +var copy = { 'name': 'moe', 'age': 40 }; + +result = _.isEqual(moe, copy); + +var words = ['hello', 'goodbye']; +var otherWords = ['hi', 'goodbye']; + +result = _.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); + diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 3b3471415..e29003783 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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(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; +