@php-wasm/progress
Advanced tools
Comparing version 0.1.30 to 0.1.31
21
index.js
@@ -106,8 +106,8 @@ class f extends EventTarget { | ||
try { | ||
const { done: l, value: d } = await n.read(); | ||
if (d && (a += d.byteLength), l) { | ||
const { done: l, value: h } = await n.read(); | ||
if (h && (a += h.byteLength), l) { | ||
i(a, a), r.close(); | ||
break; | ||
} else | ||
i(a, s), r.enqueue(d); | ||
i(a, s), r.enqueue(h); | ||
} catch (l) { | ||
@@ -161,3 +161,3 @@ console.error({ e: l }), r.error(l); | ||
} | ||
const h = 1e-5; | ||
const d = 1e-5; | ||
class c extends EventTarget { | ||
@@ -207,3 +207,3 @@ constructor({ | ||
stage(e, t = "") { | ||
if (e || (e = this._selfWeight), this._selfWeight - e < -h) | ||
if (e || (e = this._selfWeight), this._selfWeight - e < -d) | ||
throw new Error( | ||
@@ -250,3 +250,3 @@ `Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.` | ||
set(e) { | ||
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + h >= 100 && this.finish(); | ||
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + d >= 100 && this.finish(); | ||
} | ||
@@ -269,9 +269,10 @@ finish() { | ||
get done() { | ||
return this.progress + h >= 100; | ||
return this.progress + d >= 100; | ||
} | ||
get progress() { | ||
return this._subTrackers.reduce( | ||
(e, t) => e + t.progress * t.weight, | ||
const e = this._subTrackers.reduce( | ||
(t, s) => t + s.progress * s.weight, | ||
this._selfProgress * this._selfWeight | ||
) + h; | ||
); | ||
return Math.round(e * 1e4) / 1e4; | ||
} | ||
@@ -278,0 +279,0 @@ get weight() { |
{ | ||
"name": "@php-wasm/progress", | ||
"version": "0.1.30", | ||
"version": "0.1.31", | ||
"description": "PHP.wasm – loading progress monitoring", | ||
@@ -32,4 +32,4 @@ "repository": { | ||
"types": "index.d.ts", | ||
"gitHead": "df3e9bff1de33d53d026c35a6ba5534aeff21a78", | ||
"gitHead": "04b86f80526a6fa630226ba2416163ffeed6b43d", | ||
"dependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
24339
598