lodash: signatures of a method _.isEqual (and of an alias _.eq) have been changed

This commit is contained in:
Ilya Mochalov
2015-10-16 09:43:59 +05:00
parent 3a6e1b8988
commit cbe4869fda
2 changed files with 95 additions and 105 deletions
+28 -25
View File
@@ -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 = <boolean>_.gt(1, 2);
result = <boolean>_(1).gt(2);
@@ -2321,6 +2335,20 @@ result = <boolean>_([1, 2, 3]).isEmpty();
result = <boolean>_({}).isEmpty();
result = <boolean>_('').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 = <boolean>_.isError(any);
result = <boolean>_(1).isError();
@@ -2758,31 +2786,6 @@ result = <boolean>_({}).has(['', 42, true]);
result = _({}).invert<TResult>(true).value();
}
// _.isEqual (alias: _.eq)
result = <boolean>_.isEqual(1, 1);
result = <boolean>_(1).isEqual(1);
result = <boolean>_.eq(1, 1);
result = <boolean>_(1).eq(1);
var testEqObject = { 'user': 'fred' };
var testEqOtherObject = { 'user': 'fred' };
result = <boolean>_.isEqual(testEqObject, testEqOtherObject);
result = <boolean>_(testEqObject).isEqual(testEqOtherObject);
result = <boolean>_.eq(testEqObject, testEqOtherObject);
result = <boolean>_(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 = <boolean>_.isEqual(testEqArray, testEqOtherArray, testEqCustomizerFn);
result = <boolean>_(testEqArray).isEqual(testEqOtherArray, testEqCustomizerFn);
result = <boolean>_.eq(testEqArray, testEqOtherArray, testEqCustomizerFn);
result = <boolean>_(testEqArray).eq(testEqOtherArray, testEqCustomizerFn);
class Stooge {
constructor(
public name: string,
+67 -80
View File
@@ -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<T, TWrapper> {
/**
* @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 its 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<T, TWrapper> {
/**
* @see _.isEqual
*/
isEqual(
other: any,
customizer?: IsEqualCustomizer,
thisArg?: any
): boolean;
}
//_.isError
interface LoDashStatic {
/**
@@ -7998,86 +8065,6 @@ declare module _ {
invert<TResult extends {}>(multiValue?: boolean): LoDashObjectWrapper<TResult>;
}
//_.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<T> {
/**
* @see _.isEqual
*/
isEqual(other?: any,
callback?: EqCustomizer,
thisArg?: any): boolean;
/**
* @see _.isEqual
*/
eq(other?: any,
callback?: EqCustomizer,
thisArg?: any): boolean;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.isEqual
*/
isEqual(other?: any,
callback?: EqCustomizer,
thisArg?: any): boolean;
/**
* @see _.isEqual
*/
eq(other?: any,
callback?: EqCustomizer,
thisArg?: any): boolean;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.isEqual
*/
isEqual(other?: any,
callback?: EqCustomizer,
thisArg?: any): boolean;
/**
* @see _.isEqual
*/
eq(other?: any,
callback?: EqCustomizer,
thisArg?: any): boolean;
}
//_.keys
interface LoDashStatic {
/**