@leafer/task 1.0.0-beta.11 → 1.0.0-beta.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/task",
3
- "version": "1.0.0-beta.11",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "@leafer/task",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -19,10 +19,10 @@
19
19
  "leaferjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@leafer/math": "1.0.0-beta.11",
23
- "@leafer/debug": "1.0.0-beta.11"
22
+ "@leafer/math": "1.0.0-beta.12",
23
+ "@leafer/debug": "1.0.0-beta.12"
24
24
  },
25
25
  "devDependencies": {
26
- "@leafer/interface": "1.0.0-beta.11"
26
+ "@leafer/interface": "1.0.0-beta.12"
27
27
  }
28
28
  }
@@ -19,11 +19,13 @@ export class TaskProcessor implements ITaskProcessor {
19
19
  protected timer: any
20
20
 
21
21
  public get total(): number {
22
- return this.list.length
22
+ return this.list.length + this.delayNumber
23
23
  }
24
24
 
25
25
  public index = 0
26
26
 
27
+ public delayNumber = 0
28
+
27
29
  public get finishedIndex(): number {
28
30
  return this.isComplete ? 0 : this.index + this.parallelSuccessNumber
29
31
  }
@@ -73,12 +75,19 @@ export class TaskProcessor implements ITaskProcessor {
73
75
 
74
76
  if (time) task.time = time
75
77
  if (parallel === false) task.parallel = false
78
+
76
79
  if (delay === undefined) {
77
80
  this.push(task, start)
78
81
  } else {
79
- setTimeout(() => this.push(task, start), delay)
82
+ this.delayNumber++
83
+ setTimeout(() => {
84
+ this.delayNumber--
85
+ this.push(task, start)
86
+ }, delay)
80
87
  }
81
88
 
89
+ this.isComplete = false
90
+
82
91
  return task
83
92
  }
84
93
 
@@ -268,7 +277,6 @@ export class TaskProcessor implements ITaskProcessor {
268
277
  }
269
278
 
270
279
  public destroy(): void {
271
- this.empty()
272
- this.config = {}
280
+ this.stop()
273
281
  }
274
282
  }