mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #6317 from chrootsu/lodash-findLastKey
lodash: signatures of the method _.findLastKey have been changed
This commit is contained in:
+40
-3
@@ -2739,9 +2739,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);
|
||||
|
||||
Vendored
+76
-22
@@ -7830,32 +7830,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
|
||||
|
||||
Reference in New Issue
Block a user