lodash: added _.spread() method

This commit is contained in:
Ilya Mochalov
2015-08-07 23:37:46 +05:00
parent a95ee80de0
commit 7d288c8740
2 changed files with 27 additions and 0 deletions
+8
View File
@@ -989,6 +989,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
View File
@@ -5678,6 +5678,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 {
/**