@nemigo/helpers 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/queue.d.ts +4 -0
- package/dist/queue.js +11 -5
- package/package.json +1 -1
package/dist/queue.d.ts
CHANGED
package/dist/queue.js
CHANGED
|
@@ -27,22 +27,28 @@ export class Queue {
|
|
|
27
27
|
* Запускает обработку очереди с задержкой
|
|
28
28
|
*/
|
|
29
29
|
run() {
|
|
30
|
-
this.
|
|
30
|
+
this.stop();
|
|
31
31
|
this.timeout = setTimeout(() => {
|
|
32
32
|
if (this._queue.length === 0)
|
|
33
|
-
return this.
|
|
33
|
+
return this.stop();
|
|
34
34
|
const item = this._queue.shift();
|
|
35
35
|
this.handle(item);
|
|
36
|
-
this._queue.length > 0 ? this.run() : this.
|
|
36
|
+
this._queue.length > 0 ? this.run() : this.stop();
|
|
37
37
|
}, this._delay);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Сброс
|
|
40
|
+
* Сброс таймера шага
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
stop() {
|
|
43
43
|
if (this.timeout)
|
|
44
44
|
clearTimeout(this.timeout);
|
|
45
45
|
this.timeout = 0;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Сброс очереди
|
|
49
|
+
*/
|
|
50
|
+
reset() {
|
|
51
|
+
this.stop();
|
|
46
52
|
this._queue.length = 0;
|
|
47
53
|
}
|
|
48
54
|
}
|