@nxtedition/yield 1.0.8 → 1.0.10

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/README.md CHANGED
@@ -21,9 +21,8 @@ import { maybeYield } from '@nxtedition/yield'
21
21
  import { DatabaseSync } from 'node:sqlite'
22
22
 
23
23
  const db = new DatabaseSync('data.db')
24
- const rows = db.prepare('SELECT * FROM large_table').all()
25
24
 
26
- for (const row of rows) {
25
+ for (const row of db.prepare('SELECT * FROM large_table').iterate()) {
27
26
  processRow(row)
28
27
  const yielded = maybeYield()
29
28
  if (yielded) {
@@ -66,12 +65,12 @@ doYield((opaque) => {
66
65
  ### Checking without yielding
67
66
 
68
67
  ```js
69
- import { shouldYield } from '@nxtedition/yield'
68
+ import { shouldYield, doYield } from '@nxtedition/yield'
70
69
 
71
70
  while (hasWork()) {
72
71
  doWork()
73
72
  if (shouldYield()) {
74
- scheduleMoreWork()
73
+ doMoreWork()
75
74
  break
76
75
  }
77
76
  }
package/lib/index.js CHANGED
@@ -70,10 +70,7 @@ export function maybeYield (
70
70
  return null
71
71
  }
72
72
 
73
-
74
-
75
-
76
-
73
+
77
74
 
78
75
  export function doYield (
79
76
  callback ,
@@ -112,7 +109,14 @@ function dispatchYield() {
112
109
  yieldQueue[yieldIndex] = null
113
110
  yieldIndex += 1
114
111
 
115
- resolve(opaque)
112
+ try {
113
+ resolve(opaque)
114
+ } catch (err) {
115
+ queueMicrotask(() => {
116
+ // Crash the process on unhandled exceptions to avoid leaving it in an inconsistent state.
117
+ throw err
118
+ })
119
+ }
116
120
 
117
121
  if (shouldYield()) {
118
122
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/yield",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -26,5 +26,6 @@
26
26
  "oxlint-tsgolint": "^0.12.2",
27
27
  "rimraf": "^6.1.2",
28
28
  "typescript": "^5.9.3"
29
- }
29
+ },
30
+ "gitHead": "f385fe31237669bf5f9ac1fb5154e5a353710d01"
30
31
  }