diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a6..b4678f153 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2271,6 +2271,20 @@ var testCloneDeepCustomizerFn: TestCloneDeepCustomizerFn; result = _({a: {b: 2}}).cloneDeep(testCloneDeepCustomizerFn, any); } +// _.eq +module TestEq { + let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean; + let result: boolean; + + result = _.eq(any, any); + result = _.eq(any, any, customizer); + result = _.eq(any, any, customizer, any); + + result = _(any).eq(any); + result = _(any).eq(any, customizer); + result = _(any).eq(any, customizer, any) +} + // _.gt result = _.gt(1, 2); result = _(1).gt(2); @@ -2321,6 +2335,20 @@ result = _([1, 2, 3]).isEmpty(); result = _({}).isEmpty(); result = _('').isEmpty(); +// _.isEqual +module TestIsEqual { + let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean; + let result: boolean; + + result = _.isEqual(any, any); + result = _.isEqual(any, any, customizer); + result = _.isEqual(any, any, customizer, any); + + result = _(any).isEqual(any); + result = _(any).isEqual(any, customizer); + result = _(any).isEqual(any, customizer, any) +} + // _.isError result = _.isError(any); result = _(1).isError(); @@ -2758,31 +2786,6 @@ result = _({}).has(['', 42, true]); result = _({}).invert(true).value(); } -// _.isEqual (alias: _.eq) -result = _.isEqual(1, 1); -result = _(1).isEqual(1); -result = _.eq(1, 1); -result = _(1).eq(1); - -var testEqObject = { 'user': 'fred' }; -var testEqOtherObject = { 'user': 'fred' }; -result = _.isEqual(testEqObject, testEqOtherObject); -result = _(testEqObject).isEqual(testEqOtherObject); -result = _.eq(testEqObject, testEqOtherObject); -result = _(testEqObject).eq(testEqOtherObject); - -var testEqArray = ['hello', 'goodbye']; -var testEqOtherArray = ['hi', 'goodbye']; -var testEqCustomizerFn = (value: any, other: any): boolean => { - if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { - return true; - } -}; -result = _.isEqual(testEqArray, testEqOtherArray, testEqCustomizerFn); -result = _(testEqArray).isEqual(testEqOtherArray, testEqCustomizerFn); -result = _.eq(testEqArray, testEqOtherArray, testEqCustomizerFn); -result = _(testEqArray).eq(testEqOtherArray, testEqCustomizerFn); - class Stooge { constructor( public name: string, diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc0..a574e10c3 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6636,6 +6636,30 @@ declare module _ { thisArg?: any): T; } + //_.eq + interface LoDashStatic { + /** + * @see _.isEqual + */ + eq( + value: any, + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isEqual + */ + eq( + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + //_.gt interface LoDashStatic { /** @@ -6775,6 +6799,49 @@ declare module _ { isEmpty(): boolean; } + //_.isEqual + interface IsEqualCustomizer { + (value: any, other: any, indexOrKey?: number|string): boolean; + } + + interface LoDashStatic { + /** + * Performs a deep comparison between two values to determine if they are equivalent. If customizer is + * provided it’s invoked to compare values. If customizer returns undefined comparisons are handled by the + * method instead. The customizer is bound to thisArg and invoked with up to three arguments: (value, other + * [, index|key]). + * + * Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, + * and strings. Objects are compared by their own, not inherited, enumerable properties. Functions and DOM + * nodes are not supported. Provide a customizer function to extend support for comparing other values. + * + * @alias _.eq + * + * @param value The value to compare. + * @param other The other value to compare. + * @param customizer The function to customize value comparisons. + * @param thisArg The this binding of customizer. + * @return Returns true if the values are equivalent, else false. + */ + isEqual( + value: any, + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isEqual + */ + isEqual( + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + //_.isError interface LoDashStatic { /** @@ -7998,86 +8065,6 @@ declare module _ { invert(multiValue?: boolean): LoDashObjectWrapper; } - //_.isEqual - interface EqCustomizer { - (value: any, other: any, indexOrKey?: number|string): boolean; - } - - interface LoDashStatic { - /** - * Performs a deep comparison between two values to determine if they are equivalent. If customizer is - * provided it is invoked to compare values. If customizer returns undefined comparisons are handled - * by the method instead. The customizer is bound to thisArg and invoked with three - * arguments: (value, other [, index|key]). - * @param value The value to compare. - * @param other The other value to compare. - * @param callback The function to customize value comparisons. - * @param thisArg The this binding of customizer. - * @return True if the values are equivalent, else false. - */ - isEqual(value?: any, - other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(value?: any, - other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - - interface LoDashWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - } - - interface LoDashArrayWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - - interface LoDashObjectWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - //_.keys interface LoDashStatic { /**