Merge pull request #5231 from chrootsu/lodash-spread

lodash: added _.spread() method
This commit is contained in:
Masahiro Wakame 2015-08-08 14:29:16 +09:00
commit ca877eaa36
2 changed files with 27 additions and 0 deletions

View File

@ -999,6 +999,14 @@ result = <string>(_.restParam<testRestParamResult, testRestParamFunc>(testRestPa
result = <string>(_.restParam<testRestParamResult>(testRestParamFn, 2))('a', 'b', 1, 2, 3);
result = <string>(_(testRestParamFn).restParam<testRestParamResult>(2).value())('a', 'b', 1, 2, 3);
//_.spread
var testSpreadFn = (who: string, what: string) => who + ' says ' + what;
interface TestSpreadResultFn {
(args: string[]): string;
}
result = <string>(_.spread<TestSpreadResultFn>(testSpreadFn))(['fred', 'hello']);
result = <string>(_(testSpreadFn).spread<TestSpreadResultFn>().value())(['fred', 'hello']);
var throttled = _.throttle(function () { }, 100);
jQuery(window).on('scroll', throttled);

19
lodash/lodash.d.ts vendored
View File

@ -5708,6 +5708,25 @@ declare module _ {
restParam<TResult extends Function>(start?: number): LoDashObjectWrapper<TResult>;
}
//_.spread
interface LoDashStatic {
/**
* Creates a function that invokes func with the this binding of the created function and an array of arguments
* much like Function#apply.
* @param func The function to spread arguments over.
* @return Returns the new function.
*/
spread<TResult extends Function>(func: Function): TResult;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.spread
*/
spread<TResult extends Function>(): LoDashObjectWrapper<TResult>;
}
//_.throttle
interface LoDashStatic {
/**