@nxtedition/lib 23.17.17 → 23.17.18
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 +1 -1
- package/yield.js +15 -10
package/package.json
CHANGED
package/yield.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { FixedQueue } from './fixed-queue.js'
|
|
2
|
-
|
|
3
1
|
const yieldSchedule = globalThis.setImmediate ?? ((fn) => setTimeout(fn, 0))
|
|
2
|
+
const yieldQueue = []
|
|
4
3
|
|
|
5
|
-
let
|
|
4
|
+
let yieldIndex = 0
|
|
6
5
|
let yieldTimeout = 40
|
|
7
6
|
let yieldActive = false
|
|
8
7
|
let yieldScheduled = false
|
|
@@ -62,23 +61,29 @@ function dispatchYield() {
|
|
|
62
61
|
yieldTime = performance.now()
|
|
63
62
|
yieldActive = false
|
|
64
63
|
|
|
65
|
-
const
|
|
66
|
-
yieldQueue = new FixedQueue()
|
|
64
|
+
const maxIndex = yieldQueue.length
|
|
67
65
|
|
|
68
|
-
while (
|
|
69
|
-
const resolve =
|
|
66
|
+
while (yieldIndex < maxIndex) {
|
|
67
|
+
const resolve = yieldQueue[yieldIndex]
|
|
68
|
+
yieldQueue[yieldIndex] = null
|
|
69
|
+
yieldIndex += 1
|
|
70
70
|
|
|
71
71
|
resolve(null)
|
|
72
72
|
|
|
73
73
|
if (shouldYield()) {
|
|
74
|
-
|
|
75
|
-
return
|
|
74
|
+
break
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
if (yieldQueue.
|
|
78
|
+
if (yieldIndex === yieldQueue.length) {
|
|
80
79
|
yieldScheduled = false
|
|
80
|
+
yieldQueue.splice(0)
|
|
81
|
+
yieldIndex = 0
|
|
81
82
|
} else {
|
|
83
|
+
if (yieldIndex > 4096) {
|
|
84
|
+
yieldQueue.splice(0, yieldIndex)
|
|
85
|
+
yieldIndex = 0
|
|
86
|
+
}
|
|
82
87
|
yieldSchedule(dispatchYield)
|
|
83
88
|
}
|
|
84
89
|
}
|