Merge pull request #5204 from chrootsu/lodash-restParam

lodash: added _.restParam() method
This commit is contained in:
Masahiro Wakame
2015-08-04 22:05:25 +09:00
2 changed files with 36 additions and 0 deletions
+12
View File
@@ -973,6 +973,18 @@ var optionsPartialRight = {
defaultsDeep(optionsPartialRight, _.templateSettings);
//_.restParam
var testRestParamFn = (a: string, b: string, c: number[]) => a + ' ' + b + ' ' + c.join(' ');
interface testRestParamFunc {
(a: string, b: string, c: number[]): string;
}
interface testRestParamResult {
(a: string, b: string, ...c: number[]): string;
}
result = <string>(_.restParam<testRestParamResult, testRestParamFunc>(testRestParamFn, 2))('a', 'b', 1, 2, 3);
result = <string>(_.restParam<testRestParamResult>(testRestParamFn, 2))('a', 'b', 1, 2, 3);
result = <string>(_(testRestParamFn).restParam<testRestParamResult>(2).value())('a', 'b', 1, 2, 3);
var throttled = _.throttle(function () { }, 100);
jQuery(window).on('scroll', throttled);
+24
View File
@@ -5634,6 +5634,30 @@ declare module _ {
...args: any[]): Function;
}
//_.restParam
interface LoDashStatic {
/**
* Creates a function that invokes func with the this binding of the created function and arguments from start
* and beyond provided as an array.
* @param func The function to apply a rest parameter to.
* @param start The start position of the rest parameter.
* @return Returns the new function.
*/
restParam<TResult extends Function>(func: Function, start?: number): TResult;
/**
* @see _.restParam
*/
restParam<TResult extends Function, TFunc extends Function>(func: TFunc, start?: number): TResult;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.restParam
*/
restParam<TResult extends Function>(start?: number): LoDashObjectWrapper<TResult>;
}
//_.throttle
interface LoDashStatic {
/**