added _(...).after definition

This commit is contained in:
Brian Zengel
2013-10-20 22:43:55 -04:00
parent 4769542343
commit 25debf0a84
2 changed files with 17 additions and 1 deletions

View File

@@ -413,8 +413,9 @@ result = <IStoogesCombined[]>_.where(stoogesCombined, { 'quotes': ['Poifect!'] }
*************/
var saves = ['profile', 'settings'];
var asyncSave = (obj) => obj.done();
var done: Function;
var done: Function = _.after(saves.length, function() {
done = _.after(saves.length, function() {
console.log('Done saving!');
});
@@ -422,6 +423,14 @@ _.forEach(saves, function(type) {
asyncSave({ 'type': type, 'complete': done });
});
done = _(function() {
console.log('Done saving!');
}).after(saves.length);
_.forEach(saves, function(type) {
asyncSave({ 'type': type, 'complete': done });
});
var funcBind = function (greeting) { return greeting + ' ' + this.name };
// need a second var otherwise typescript thinks func signature is the above func type,
// instead of the newly returned _bind => func type.

7
lodash/lodash.d.ts vendored
View File

@@ -1880,6 +1880,13 @@ declare module _ {
n: number,
func: Function): Function;
interface LoDashWrapper<T> {
/**
* @see _.after
**/
after(n: number): Function;
}
/**
* Creates a function that, when called, invokes func with the this binding of thisArg
* and prepends any additional bind arguments to those provided to the bound function.