initial
This commit is contained in:
30
ts/index.ts
Normal file
30
ts/index.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import 'typings-global'
|
||||
|
||||
export interface IResolve<T> {
|
||||
(value?: T | Promise<T>): void
|
||||
}
|
||||
|
||||
export interface IReject {
|
||||
(reason?: any): void
|
||||
}
|
||||
|
||||
export class Deferred<T> {
|
||||
promise: Promise<T>
|
||||
resolve: IResolve<T>
|
||||
reject: IReject
|
||||
constructor() {
|
||||
this.promise = new Promise<T>((resolve, reject) => {
|
||||
this.resolve = resolve
|
||||
this.reject = reject
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export let defer = <T>() => {
|
||||
return new Deferred<T>()
|
||||
}
|
||||
|
||||
|
||||
export let all = () => {
|
||||
|
||||
}
|
Reference in New Issue
Block a user