@nxtedition/shared 0.0.4 → 1.0.1
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/index.js +6 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -32,7 +32,10 @@ async function* _reader({ sharedState, sharedBuffer }, cb) {
|
|
|
32
32
|
const raw = buffer.slice(readPos + 4, readPos + len)
|
|
33
33
|
readPos += len
|
|
34
34
|
if (cb) {
|
|
35
|
-
cb()
|
|
35
|
+
const thenable = cb(raw)
|
|
36
|
+
if (thenable && typeof thenable.then === 'function') {
|
|
37
|
+
await thenable
|
|
38
|
+
}
|
|
36
39
|
} else {
|
|
37
40
|
yield raw
|
|
38
41
|
}
|
|
@@ -111,14 +114,14 @@ export function writer({ sharedState, sharedBuffer }) {
|
|
|
111
114
|
flushing = null
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
|
|
117
|
+
function write(...raw) {
|
|
115
118
|
if (!queue.length && tryWrite(...raw)) {
|
|
116
119
|
return
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
queue.push(Buffer.concat(raw))
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
return (flushing ??= flush())
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
return write
|