@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.
Files changed (2) hide show
  1. package/index.js +6 -3
  2. 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
- async function write(...raw) {
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
- await (flushing ??= flush())
124
+ return (flushing ??= flush())
122
125
  }
123
126
 
124
127
  return write
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/shared",
3
- "version": "0.0.4",
3
+ "version": "1.0.1",
4
4
  "description": "Ring Buffer for NodeJS cross Worker communication",
5
5
  "main": "index.js",
6
6
  "repository": {