@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/yield.js +15 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.17.17",
3
+ "version": "23.17.18",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
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 yieldQueue = new FixedQueue()
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 queue = yieldQueue
66
- yieldQueue = new FixedQueue()
64
+ const maxIndex = yieldQueue.length
67
65
 
68
- while (!queue.isEmpty()) {
69
- const resolve = queue.shift()
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
- yieldSchedule(dispatchYield)
75
- return
74
+ break
76
75
  }
77
76
  }
78
77
 
79
- if (yieldQueue.isEmpty()) {
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
  }