@nxtedition/shared 1.3.0 → 1.4.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/index.js +13 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -103,7 +103,14 @@ export function writer({ sharedState, sharedBuffer }) {
103
103
  return true
104
104
  }
105
105
 
106
- async function flush() {
106
+ function flush() {
107
+ if (queue.length && !flushing) {
108
+ flushing = _flush()
109
+ }
110
+ return flushing
111
+ }
112
+
113
+ async function _flush() {
107
114
  while (queue.length) {
108
115
  const buf = queue[0]
109
116
  while (
@@ -129,7 +136,7 @@ export function writer({ sharedState, sharedBuffer }) {
129
136
 
130
137
  function write(...args) {
131
138
  if (!args.length) {
132
- return true
139
+ return
133
140
  }
134
141
 
135
142
  let len
@@ -173,8 +180,11 @@ export function writer({ sharedState, sharedBuffer }) {
173
180
  const buf = Buffer.allocUnsafe(len)
174
181
  queue.push(buf.subarray(0, fn(0, buf)))
175
182
 
176
- return (flushing ??= flush())
183
+ return flush()
177
184
  }
178
185
 
186
+ write.write = write
187
+ write.flush = flush
188
+
179
189
  return write
180
190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/shared",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Ring Buffer for NodeJS cross Worker communication",
5
5
  "main": "index.js",
6
6
  "repository": {