@live-change/task-service 0.9.45 → 0.9.46

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/task.ts +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/task-service",
3
- "version": "0.9.45",
3
+ "version": "0.9.46",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.9.45",
26
- "@live-change/relations-plugin": "^0.9.45"
25
+ "@live-change/framework": "^0.9.46",
26
+ "@live-change/relations-plugin": "^0.9.46"
27
27
  },
28
- "gitHead": "cc49c034ca5538efdb5c43d87041367d39a3d63f"
28
+ "gitHead": "9d2fe9cbfb28f6cd389c8cbc5cf051f583f58e9e"
29
29
  }
package/task.ts CHANGED
@@ -224,15 +224,15 @@ export default function task(definition:TaskDefinition, serviceDefinition) {
224
224
  }
225
225
 
226
226
  let selfProgress = { current: 0, total: 0, action: undefined }
227
- const subtasksProgress = []
227
+ const subtasksProgress: { current: number, total: number, factor: number }[] = []
228
228
  let progressUpdateTimer, lastProgressUpdate = 0
229
229
  const progressThrottleTime = 400
230
230
  function updateProgress() {
231
231
  if(progressUpdateTimer) clearTimeout(progressUpdateTimer)
232
232
  const current = selfProgress.current + subtasksProgress.reduce(
233
- (sum, progress) => sum + progress.current * (progress.factor ?? 1), 0)
233
+ (sum, progress: { current: number, total: number, factor: number }) => sum + progress.current * (progress.factor ?? 1), 0)
234
234
  const total = selfProgress.total + subtasksProgress.reduce(
235
- (sum, progress) => sum + progress.total * (progress.factor ?? 1), 0)
235
+ (sum, progress: { current: number, total: number, factor: number }) => sum + progress.total * (progress.factor ?? 1), 0)
236
236
  reportProgress(current, total, selfProgress.action)
237
237
 
238
238
  if(lastProgressUpdate + progressThrottleTime > Date.now()) { // ignore this update, do it later