Merge pull request #5102 from chrootsu/lodash-method

lodash: added _.method() method
This commit is contained in:
Masahiro Wakame
2015-08-02 23:17:23 +09:00
2 changed files with 53 additions and 0 deletions
+12
View File
@@ -1385,6 +1385,18 @@ result = <() => boolean>_(true).constant<boolean>();
result = <() => any[]>_(['a']).constant<any[]>();
result = <() => {}>_({}).constant<{}>();
// _.method
class TestMethod {
a = {
b: (a1: number, a2: number) => a1 + a2
}
}
var TestMethodObject = new TestMethod();
result = <number>(_.method<number>('a.b', 1, 2))(TestMethodObject);
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);
result = <string>_.VERSION;
result = <_.Support>_.support;
result = <_.TemplateSettings>_.templateSettings;
+41
View File
@@ -6826,6 +6826,47 @@ declare module _ {
identity<T>(value?: T): T;
}
//_.method
interface LoDashStatic {
/**
* Creates a function that invokes the method at path on a given object. Any additional arguments are provided
* to the invoked method.
* @param path The path of the method to invoke.
* @param args The arguments to invoke the method with.
* @return Returns the new function.
*/
method<TResult>(path: string, ...args: any[]): (object: any) => TResult;
/**
* @see _.method
*/
method<TResult>(path: any[], ...args: any[]): (object: any) => TResult;
}
interface LoDashWrapper<T> {
/**
* @see _.method
*/
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
/**
* @see _.method
*/
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.method
*/
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
/**
* @see _.method
*/
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
}
//_.mixin
interface LoDashStatic {
/**