lodash: signatures of the method _.findLastKey have been changed

This commit is contained in:
Ilya Mochalov
2015-10-16 10:05:05 +05:00
parent 3a6e1b8988
commit 5e3a73a24b
2 changed files with 116 additions and 25 deletions
+40 -3
View File
@@ -2676,9 +2676,46 @@ module TestFindKey {
}
}
result = <string>_.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) {
return num % 2 == 1;
});
// _.findLastKey
module TestFindLastKey {
let result: string;
{
let predicateFn: (value: any, key?: string, object?: {}) => boolean;
result = _.findLastKey<{a: string;}>({a: ''});
result = _.findLastKey<{a: string;}>({a: ''}, predicateFn);
result = _.findLastKey<{a: string;}>({a: ''}, predicateFn, any);
result = _.findLastKey<{a: string;}>({a: ''}, '');
result = _.findLastKey<{a: string;}>({a: ''}, '', any);
result = _.findLastKey<{a: number;}, {a: string;}>({a: ''}, {a: 42});
result = _<{a: string;}>({a: ''}).findLastKey();
result = _<{a: string;}>({a: ''}).findLastKey(predicateFn);
result = _<{a: string;}>({a: ''}).findLastKey(predicateFn, any);
result = _<{a: string;}>({a: ''}).findLastKey('');
result = _<{a: string;}>({a: ''}).findLastKey('', any);
result = _<{a: string;}>({a: ''}).findLastKey<{a: number;}>({a: 42});
}
{
let predicateFn: (value: string, key?: string, collection?: _.Dictionary<string>) => boolean;
result = _.findLastKey<string, {a: string;}>({a: ''}, predicateFn);
result = _.findLastKey<string, {a: string;}>({a: ''}, predicateFn, any);
result = _<{a: string;}>({a: ''}).findLastKey<string>(predicateFn);
result = _<{a: string;}>({a: ''}).findLastKey<string>(predicateFn, any);
}
}
result = <Dog>_.forIn(new Dog('Dagny'), function (value, key) {
console.log(key);
+76 -22
View File
@@ -7745,32 +7745,86 @@ declare module _ {
//_.findLastKey
interface LoDashStatic {
/**
* This method is like _.findKey except that it iterates over elements of a collection in the opposite order.
* @param object The object to search.
* @param callback The function called per iteration.
* @param thisArg The this binding of callback.
* @return The key of the found element, else undefined.
**/
findLastKey(
object: any,
callback: (value: any) => boolean,
thisArg?: any): string;
* This method is like _.findKey except that it iterates over elements of a collection in the opposite order.
*
* If a property name is provided for predicate the created _.property style callback returns the property
* value of the given element.
*
* If a value is also provided for thisArg the created _.matchesProperty style callback returns true for
* elements that have a matching property value, else false.
*
* If an object is provided for predicate the created _.matches style callback returns true for elements that
* have the properties of the given object, else false.
*
* @param object The object to search.
* @param predicate The function invoked per iteration.
* @param thisArg The this binding of predicate.
* @return Returns the key of the matched element, else undefined.
*/
findLastKey<TValues, TObject>(
object: TObject,
predicate?: DictionaryIterator<TValues, boolean>,
thisArg?: any
): string;
/**
* @see _.findLastKey
* @param pluckValue _.pluck style callback
**/
findLastKey(
object: any,
pluckValue: string): string;
* @see _.findLastKey
*/
findLastKey<TObject>(
object: TObject,
predicate?: ObjectIterator<any, boolean>,
thisArg?: any
): string;
/**
* @see _.findLastKey
* @param whereValue _.where style callback
**/
findLastKey<W extends Dictionary<any>, T>(
object: T,
whereValue: W): string;
* @see _.findLastKey
*/
findLastKey<TObject>(
object: TObject,
predicate?: string,
thisArg?: any
): string;
/**
* @see _.findLastKey
*/
findLastKey<TWhere extends Dictionary<any>, TObject>(
object: TObject,
predicate?: TWhere
): string;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.findLastKey
*/
findLastKey<TValues>(
predicate?: DictionaryIterator<TValues, boolean>,
thisArg?: any
): string;
/**
* @see _.findLastKey
*/
findLastKey(
predicate?: ObjectIterator<any, boolean>,
thisArg?: any
): string;
/**
* @see _.findLastKey
*/
findLastKey(
predicate?: string,
thisArg?: any
): string;
/**
* @see _.findLastKey
*/
findLastKey<TWhere extends Dictionary<any>>(
predicate?: TWhere
): string;
}
//_.forIn