Skip to content

Commit 1d014ca

Browse files
committed
Generics support
1 parent 2e13936 commit 1d014ca

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const nextTick = (() => {
1414
return setTimeout;
1515
})();
1616

17-
class WaitQueue {
17+
class WaitQueue<T> {
1818
[Symbol.iterator]: () => { next: () => { value: any; done: boolean } };
1919

2020
queue = new LinkedList();
@@ -35,17 +35,17 @@ class WaitQueue {
3535
}
3636
this.listeners = new LinkedList();
3737
}
38-
unshift(...items: any[]) {
38+
unshift(...items: T[]) {
3939
this.queue.unshift(...items);
4040
this._flush();
4141
return this.length;
4242
}
43-
push(...items: any[]) {
43+
push(...items: T[]) {
4444
this.queue.push(...items);
4545
this._flush();
4646
return this.length;
4747
}
48-
shift() {
48+
shift(): Promise<T> {
4949
return new Promise((resolve, reject) => {
5050
if (this.queue.length > 0) {
5151
return resolve(this.queue.shift());
@@ -59,7 +59,7 @@ class WaitQueue {
5959
}
6060
});
6161
}
62-
pop() {
62+
pop(): Promise<T> {
6363
return new Promise((resolve, reject) => {
6464
if (this.queue.length > 0) {
6565
return resolve(this.queue.pop());

0 commit comments

Comments
 (0)