Merge pull request #5073 from chrootsu/lodash-modArgs

lodash: added _.modArgs() method
This commit is contained in:
Masahiro Wakame
2015-07-29 00:07:59 +09:00
2 changed files with 56 additions and 0 deletions
+21
View File
@@ -857,6 +857,27 @@ stooge('curly');
var returnedMemoize = _.throttle(function (a: any) { return a * 5; }, 5);
returnedMemoize(4);
// _.modArgs
function modArgsFn1(n: number): string {return n.toString()}
function modArgsFn2(n: boolean): string {return n.toString()}
interface ModArgsFunc {
(x: string, y: string): string[];
}
interface ModArgsResult {
(x: number, y: boolean): string[]
}
result = <ModArgsResult>_.modArgs<ModArgsFunc, ModArgsResult>((x: string, y: string) => [x, y], modArgsFn1, modArgsFn2);
result = <string[]>result(1, true);
result = <ModArgsResult>_.modArgs<ModArgsFunc, ModArgsResult>((x: string, y: string) => [x, y], [modArgsFn1, modArgsFn2]);
result = <string[]>result(1, true);
result = <ModArgsResult>_<ModArgsFunc>((x: string, y: string) => [x, y]).modArgs<ModArgsResult>(modArgsFn1, modArgsFn2).value();
result = <string[]>result(1, true);
result = <ModArgsResult>_<ModArgsFunc>((x: string, y: string) => [x, y]).modArgs<ModArgsResult>([modArgsFn1, modArgsFn2]).value();
result = <string[]>result(1, true);
var initialize = _.once(function () { });
initialize();
initialize();''
+35
View File
@@ -5386,6 +5386,41 @@ declare module _ {
resolver?: Function): T;
}
//_.modArgs
interface LoDashStatic {
/**
* Creates a function that runs each argument through a corresponding transform function.
* @param func The function to wrap.
* @param transforms The functions to transform arguments, specified as individual functions or arrays
* of functions.
* @return Returns the new function.
*/
modArgs<T extends Function, TResult extends Function>(
func: T,
...transforms: Function[]
): TResult;
/**
* @see _.modArgs
*/
modArgs<T extends Function, TResult extends Function>(
func: T,
transforms: Function[]
): TResult;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.modArgs
*/
modArgs<TResult>(...transforms: Function[]): LoDashObjectWrapper<TResult>;
/**
* @see _.modArgs
*/
modArgs<TResult>(transforms: Function[]): LoDashObjectWrapper<TResult>;
}
//_.once
interface LoDashStatic {
/**