mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-30 11:14:27 +08:00
added _.times definition
This commit is contained in:
@@ -760,6 +760,15 @@ result = <_.TemplateExecutor>_.template('hello <%= name %>', null, { 'sourceURL'
|
||||
result = <_.TemplateExecutor>_.template('hi <%= data.name %>!', null, { 'variable': 'data' });
|
||||
result = <string>(<_.TemplateExecutor>result).source;
|
||||
|
||||
function Mage() {
|
||||
this.castSpell = (n:number) => n;
|
||||
this.cast = (n: number) => n;
|
||||
};
|
||||
var mage = new Mage();
|
||||
result = <any[]>_.times(3, _.partial(_.random, 1, 6));
|
||||
result = <any[]>_.times(3, function(n: number) { mage.castSpell(n); });
|
||||
result = <any[]>_.times(3, function(n: number) { this.cast(n); }, mage);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var iceCream = { flavor: "chocolate" };
|
||||
|
||||
Vendored
+15
-12
@@ -2825,20 +2825,23 @@ declare module _ {
|
||||
sourceURL?: string,
|
||||
variable?: string): any /* string or TemplateExecutor*/;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Invokes the given iterator function n times.
|
||||
* Each invocation of iterator is called with an index argument
|
||||
* @param n Number of times to invoke `iterator`.
|
||||
* @param iterator Function iterator to invoke `n` times.
|
||||
* @param context `this` object in `iterator`, optional.
|
||||
* Executes the callback n times, returning an array of the results of each callback execution.
|
||||
* The callback is bound to thisArg and invoked with one argument; (index).
|
||||
* @param n The number of times to execute the callback.
|
||||
* @param callback The function called per iteration.
|
||||
* @param thisArg The this binding of callback.
|
||||
**/
|
||||
export function times<TResult>(n: number, iterator: (n: number) => TResult, context?: any): TResult[];
|
||||
export function times<TResult>(
|
||||
n: number,
|
||||
callback: Function,
|
||||
context?: any): TResult[];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate a globally-unique id for client-side models or DOM elements that need one.
|
||||
|
||||
Reference in New Issue
Block a user