@nxtedition/lib 23.15.7 → 23.16.0

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 +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.15.7",
3
+ "version": "23.16.0",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/yield.js CHANGED
@@ -14,16 +14,16 @@ export function setYieldTimeout(timeout) {
14
14
  yieldTimeout = timeout
15
15
  }
16
16
 
17
+ export function shouldYield() {
18
+ return yieldState > 0 || performance.now() - yieldTime >= yieldTimeout
19
+ }
20
+
17
21
  export function maybeYield(callback) {
18
22
  if (callback != null && typeof callback !== 'function') {
19
23
  throw new TypeError('callback must be a function')
20
24
  }
21
25
 
22
- if (performance.now() - yieldTime < yieldTimeout) {
23
- return null
24
- }
25
-
26
- return doYield(callback) ?? true
26
+ return shouldYield() ? (doYield(callback) ?? true) : null
27
27
  }
28
28
 
29
29
  export function doYield(callback) {