mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-20 00:59:29 +08:00
lodash: added _.methodOf() method
This commit is contained in:
@@ -1435,6 +1435,18 @@ result = <number>(_.method<number>(['a', 'b'], 1, 2))(TestMethodObject);
|
||||
result = <number>(_('a.b').method<number>(1, 2).value())(TestMethodObject);
|
||||
result = <number>(_(['a', 'b']).method<number>(1, 2).value())(TestMethodObject);
|
||||
|
||||
// _.methodOf
|
||||
class TestMethodOf {
|
||||
a = [
|
||||
(a1: number, a2: number) => a1 + a2
|
||||
];
|
||||
}
|
||||
var TestMethodOfObject = new TestMethodOf();
|
||||
result = <number>(_.methodOf<number>(TestMethodOfObject, 1, 2))('a[0]');
|
||||
result = <number>(_.methodOf<number>(TestMethodOfObject, 1, 2))(['a', '0']);
|
||||
result = <number>(_(TestMethodOfObject).methodOf<number>(1, 2).value())('a[0]');
|
||||
result = <number>(_(TestMethodOfObject).methodOf<number>(1, 2).value())(['a', '0']);
|
||||
|
||||
result = <string>_.VERSION;
|
||||
result = <_.Support>_.support;
|
||||
result = <_.TemplateSettings>_.templateSettings;
|
||||
|
||||
19
lodash/lodash.d.ts
vendored
19
lodash/lodash.d.ts
vendored
@@ -6987,6 +6987,25 @@ declare module _ {
|
||||
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
|
||||
}
|
||||
|
||||
//_.methodOf
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* The opposite of _.method; this method creates a function that invokes the method at a given path on object.
|
||||
* Any additional arguments are provided to the invoked method.
|
||||
* @param object The object to query.
|
||||
* @param args The arguments to invoke the method with.
|
||||
* @return Returns the new function.
|
||||
*/
|
||||
methodOf<TResult>(object: Object, ...args: any[]): (path: string | any[]) => TResult;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.methodOf
|
||||
*/
|
||||
methodOf<TResult>(...args: any[]): LoDashObjectWrapper<(path: string | any[]) => TResult>;
|
||||
}
|
||||
|
||||
//_.mixin
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user