@nxtedition/nxt-undici 1.0.11 → 1.0.12

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/lib/index.js +16 -11
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -102,18 +102,23 @@ class Readable extends stream.Readable {
102
102
  return Buffer.concat(buffers)
103
103
  }
104
104
 
105
- async dump() {
106
- let n = 0
107
- try {
108
- for await (const chunk of this) {
109
- n += chunk.length
110
- if (n > 128 * 1024) {
111
- break
112
- }
105
+ dump() {
106
+ return new Promise((resolve) => {
107
+ if (this.closed) {
108
+ resolve(null)
109
+ } else {
110
+ let n = 0
111
+ this.on('close', () => resolve(null))
112
+ .on('error', () => {})
113
+ .on('data', (chunk) => {
114
+ n += chunk.length
115
+ if (n > 128 * 1024) {
116
+ this.destroy()
117
+ }
118
+ })
119
+ .resume()
113
120
  }
114
- } catch {
115
- // Do nothing...
116
- }
121
+ })
117
122
  }
118
123
  }
119
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",