@@ -9,15 +9,15 @@ import { Emitter, Event } from 'vs/base/common/event';
99import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
1010import { URI } from 'vs/base/common/uri' ;
1111
12- export function isThenable < T > ( obj : any ) : obj is Thenable < T > {
13- return obj && typeof ( < Thenable < any > > obj ) . then === 'function' ;
12+ export function isThenable < T > ( obj : any ) : obj is Promise < T > {
13+ return obj && typeof ( < Promise < any > > obj ) . then === 'function' ;
1414}
1515
1616export interface CancelablePromise < T > extends Promise < T > {
1717 cancel ( ) : void ;
1818}
1919
20- export function createCancelablePromise < T > ( callback : ( token : CancellationToken ) => Thenable < T > ) : CancelablePromise < T > {
20+ export function createCancelablePromise < T > ( callback : ( token : CancellationToken ) => Promise < T > ) : CancelablePromise < T > {
2121 const source = new CancellationTokenSource ( ) ;
2222
2323 const thenable = callback ( source . token ) ;
@@ -38,10 +38,10 @@ export function createCancelablePromise<T>(callback: (token: CancellationToken)
3838 cancel ( ) {
3939 source . cancel ( ) ;
4040 }
41- then < TResult1 = T , TResult2 = never > ( resolve ?: ( ( value : T ) => TResult1 | Thenable < TResult1 > ) | undefined | null , reject ?: ( ( reason : any ) => TResult2 | Thenable < TResult2 > ) | undefined | null ) : Promise < TResult1 | TResult2 > {
41+ then < TResult1 = T , TResult2 = never > ( resolve ?: ( ( value : T ) => TResult1 | Promise < TResult1 > ) | undefined | null , reject ?: ( ( reason : any ) => TResult2 | Promise < TResult2 > ) | undefined | null ) : Promise < TResult1 | TResult2 > {
4242 return promise . then ( resolve , reject ) ;
4343 }
44- catch < TResult = never > ( reject ?: ( ( reason : any ) => TResult | Thenable < TResult > ) | undefined | null ) : Promise < T | TResult > {
44+ catch < TResult = never > ( reject ?: ( ( reason : any ) => TResult | Promise < TResult > ) | undefined | null ) : Promise < T | TResult > {
4545 return this . then ( undefined , reject ) ;
4646 }
4747 } ;
@@ -90,17 +90,17 @@ export interface ITask<T> {
9090 */
9191export class Throttler {
9292
93- private activePromise : Thenable < any > | null ;
94- private queuedPromise : Thenable < any > | null ;
95- private queuedPromiseFactory : ITask < Thenable < any > > | null ;
93+ private activePromise : Promise < any > | null ;
94+ private queuedPromise : Promise < any > | null ;
95+ private queuedPromiseFactory : ITask < Promise < any > > | null ;
9696
9797 constructor ( ) {
9898 this . activePromise = null ;
9999 this . queuedPromise = null ;
100100 this . queuedPromiseFactory = null ;
101101 }
102102
103- queue < T > ( promiseFactory : ITask < Thenable < T > > ) : Thenable < T > {
103+ queue < T > ( promiseFactory : ITask < Promise < T > > ) : Promise < T > {
104104 if ( this . activePromise ) {
105105 this . queuedPromiseFactory = promiseFactory ;
106106
@@ -142,7 +142,7 @@ export class Sequencer {
142142
143143 private current : Promise < any > = Promise . resolve ( null ) ;
144144
145- queue < T > ( promiseTask : ITask < Thenable < T > > ) : Thenable < T > {
145+ queue < T > ( promiseTask : ITask < Promise < T > > ) : Promise < T > {
146146 return this . current = this . current . then ( ( ) => promiseTask ( ) ) ;
147147 }
148148}
@@ -173,10 +173,10 @@ export class Sequencer {
173173export class Delayer < T > implements IDisposable {
174174
175175 private timeout : any ;
176- private completionPromise : Thenable < any > | null ;
177- private doResolve : ( ( value ?: any | Thenable < any > ) => void ) | null ;
176+ private completionPromise : Promise < any > | null ;
177+ private doResolve : ( ( value ?: any | Promise < any > ) => void ) | null ;
178178 private doReject : ( err : any ) => void ;
179- private task : ITask < T | Thenable < T > > | null ;
179+ private task : ITask < T | Promise < T > > | null ;
180180
181181 constructor ( public defaultDelay : number ) {
182182 this . timeout = null ;
@@ -185,7 +185,7 @@ export class Delayer<T> implements IDisposable {
185185 this . task = null ;
186186 }
187187
188- trigger ( task : ITask < T | Thenable < T > > , delay : number = this . defaultDelay ) : Thenable < T > {
188+ trigger ( task : ITask < T | Promise < T > > , delay : number = this . defaultDelay ) : Promise < T > {
189189 this . task = task ;
190190 this . cancelTimeout ( ) ;
191191
@@ -247,16 +247,16 @@ export class Delayer<T> implements IDisposable {
247247 */
248248export class ThrottledDelayer < T > {
249249
250- private delayer : Delayer < Thenable < T > > ;
250+ private delayer : Delayer < Promise < T > > ;
251251 private throttler : Throttler ;
252252
253253 constructor ( defaultDelay : number ) {
254254 this . delayer = new Delayer ( defaultDelay ) ;
255255 this . throttler = new Throttler ( ) ;
256256 }
257257
258- trigger ( promiseFactory : ITask < Thenable < T > > , delay ?: number ) : Thenable < T > {
259- return this . delayer . trigger ( ( ) => this . throttler . queue ( promiseFactory ) , delay ) as any as Thenable < T > ;
258+ trigger ( promiseFactory : ITask < Promise < T > > , delay ?: number ) : Promise < T > {
259+ return this . delayer . trigger ( ( ) => this . throttler . queue ( promiseFactory ) , delay ) as any as Promise < T > ;
260260 }
261261
262262 isTriggered ( ) : boolean {
@@ -303,8 +303,8 @@ export class Barrier {
303303}
304304
305305export function timeout ( millis : number ) : CancelablePromise < void > ;
306- export function timeout ( millis : number , token : CancellationToken ) : Thenable < void > ;
307- export function timeout ( millis : number , token ?: CancellationToken ) : CancelablePromise < void > | Thenable < void > {
306+ export function timeout ( millis : number , token : CancellationToken ) : Promise < void > ;
307+ export function timeout ( millis : number , token ?: CancellationToken ) : CancelablePromise < void > | Promise < void > {
308308 if ( ! token ) {
309309 return createCancelablePromise ( token => timeout ( millis , token ) ) ;
310310 }
@@ -334,7 +334,7 @@ export function disposableTimeout(handler: Function, timeout = 0): IDisposable {
334334 * @param promise a promise
335335 * @param callback a function that will be call in the success and error case.
336336 */
337- export function always < T > ( promise : Thenable < T > , callback : ( ) => void ) : Promise < T > {
337+ export function always < T > ( promise : Promise < T > , callback : ( ) => void ) : Promise < T > {
338338 function safeCallback ( ) {
339339 try {
340340 callback ( ) ;
@@ -346,7 +346,7 @@ export function always<T>(promise: Thenable<T>, callback: () => void): Promise<T
346346 return Promise . resolve ( promise ) ;
347347}
348348
349- export function ignoreErrors < T > ( promise : Thenable < T > ) : Thenable < T | undefined > {
349+ export function ignoreErrors < T > ( promise : Promise < T > ) : Promise < T | undefined > {
350350 return promise . then ( undefined , _ => undefined ) ;
351351}
352352
@@ -355,16 +355,16 @@ export function ignoreErrors<T>(promise: Thenable<T>): Thenable<T | undefined> {
355355 * promise will complete to an array of results from each promise.
356356 */
357357
358- export function sequence < T > ( promiseFactories : ITask < Thenable < T > > [ ] ) : Promise < T [ ] > {
358+ export function sequence < T > ( promiseFactories : ITask < Promise < T > > [ ] ) : Promise < T [ ] > {
359359 const results : T [ ] = [ ] ;
360360 let index = 0 ;
361361 const len = promiseFactories . length ;
362362
363- function next ( ) : Thenable < T > | null {
363+ function next ( ) : Promise < T > | null {
364364 return index < len ? promiseFactories [ index ++ ] ( ) : null ;
365365 }
366366
367- function thenHandler ( result : any ) : Thenable < any > {
367+ function thenHandler ( result : any ) : Promise < any > {
368368 if ( result !== undefined && result !== null ) {
369369 results . push ( result ) ;
370370 }
@@ -380,7 +380,7 @@ export function sequence<T>(promiseFactories: ITask<Thenable<T>>[]): Promise<T[]
380380 return Promise . resolve ( null ) . then ( thenHandler ) ;
381381}
382382
383- export function first < T > ( promiseFactories : ITask < Thenable < T > > [ ] , shouldStop : ( t : T ) => boolean = t => ! ! t , defaultValue : T | null = null ) : Promise < T | null > {
383+ export function first < T > ( promiseFactories : ITask < Promise < T > > [ ] , shouldStop : ( t : T ) => boolean = t => ! ! t , defaultValue : T | null = null ) : Promise < T | null > {
384384 let index = 0 ;
385385 const len = promiseFactories . length ;
386386
@@ -405,8 +405,8 @@ export function first<T>(promiseFactories: ITask<Thenable<T>>[], shouldStop: (t:
405405}
406406
407407interface ILimitedTaskFactory < T > {
408- factory : ITask < Thenable < T > > ;
409- c : ( value ?: T | Thenable < T > ) => void ;
408+ factory : ITask < Promise < T > > ;
409+ c : ( value ?: T | Promise < T > ) => void ;
410410 e : ( error ?: any ) => void ;
411411}
412412
@@ -438,7 +438,7 @@ export class Limiter<T> {
438438 // return this.runningPromises + this.outstandingPromises.length;
439439 }
440440
441- queue ( factory : ITask < Thenable < T > > ) : Thenable < T > {
441+ queue ( factory : ITask < Promise < T > > ) : Promise < T > {
442442 this . _size ++ ;
443443
444444 return new Promise < T > ( ( c , e ) => {
@@ -685,8 +685,8 @@ export function nfcall(fn: Function, ...args: any[]): any {
685685 return new Promise ( ( c , e ) => fn ( ...args , ( err : any , result : any ) => err ? e ( err ) : c ( result ) ) ) ;
686686}
687687
688- export function ninvoke ( thisArg : any , fn : Function , ...args : any [ ] ) : Thenable < any > ;
689- export function ninvoke < T > ( thisArg : any , fn : Function , ...args : any [ ] ) : Thenable < T > ;
688+ export function ninvoke ( thisArg : any , fn : Function , ...args : any [ ] ) : Promise < any > ;
689+ export function ninvoke < T > ( thisArg : any , fn : Function , ...args : any [ ] ) : Promise < T > ;
690690export function ninvoke ( thisArg : any , fn : Function , ...args : any [ ] ) : any {
691691 return new Promise ( ( resolve , reject ) => fn . call ( thisArg , ...args , ( err : any , result : any ) => err ? reject ( err ) : resolve ( result ) ) ) ;
692692}
0 commit comments