@cj-tech-master/excelts 5.1.16 → 5.1.17

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.
@@ -242,15 +242,28 @@ class StreamBuf extends EventEmitter {
242
242
  }
243
243
  else {
244
244
  const chunkBuffer = chunk.toBuffer();
245
- if (!this.paused) {
245
+ // Track whether the data has been delivered to a consumer.
246
+ // When a consumer exists ("data" listeners or a native WritableStream),
247
+ // the data is consumed externally and must NOT also be accumulated in
248
+ // internal buffers — otherwise the buffers grow without bound (memory leak)
249
+ // since no one ever calls read()/toBuffer() to drain them.
250
+ let consumed = false;
251
+ if (!this.paused && this.listenerCount("data") > 0) {
246
252
  this.emit("data", chunkBuffer);
253
+ consumed = true;
247
254
  }
248
255
  // Also write to native WritableStream if connected
249
256
  if (this._writableStreamWriter) {
250
257
  this._asyncWriteQueue = this._asyncWriteQueue.then(() => this._writableStreamWriter.write(chunkBuffer));
258
+ consumed = true;
259
+ }
260
+ // Only buffer internally when no consumer has received the data.
261
+ // This keeps StreamBuf working as a memory buffer (write then read/toBuffer)
262
+ // while preventing unbounded growth when used as an event-driven pass-through.
263
+ if (!consumed) {
264
+ this._writeToBuffers(chunk);
265
+ this.emit("readable");
251
266
  }
252
- this._writeToBuffers(chunk);
253
- this.emit("readable");
254
267
  }
255
268
  return true;
256
269
  }
@@ -245,15 +245,28 @@ class StreamBuf extends _stream_1.EventEmitter {
245
245
  }
246
246
  else {
247
247
  const chunkBuffer = chunk.toBuffer();
248
- if (!this.paused) {
248
+ // Track whether the data has been delivered to a consumer.
249
+ // When a consumer exists ("data" listeners or a native WritableStream),
250
+ // the data is consumed externally and must NOT also be accumulated in
251
+ // internal buffers — otherwise the buffers grow without bound (memory leak)
252
+ // since no one ever calls read()/toBuffer() to drain them.
253
+ let consumed = false;
254
+ if (!this.paused && this.listenerCount("data") > 0) {
249
255
  this.emit("data", chunkBuffer);
256
+ consumed = true;
250
257
  }
251
258
  // Also write to native WritableStream if connected
252
259
  if (this._writableStreamWriter) {
253
260
  this._asyncWriteQueue = this._asyncWriteQueue.then(() => this._writableStreamWriter.write(chunkBuffer));
261
+ consumed = true;
262
+ }
263
+ // Only buffer internally when no consumer has received the data.
264
+ // This keeps StreamBuf working as a memory buffer (write then read/toBuffer)
265
+ // while preventing unbounded growth when used as an event-driven pass-through.
266
+ if (!consumed) {
267
+ this._writeToBuffers(chunk);
268
+ this.emit("readable");
254
269
  }
255
- this._writeToBuffers(chunk);
256
- this.emit("readable");
257
270
  }
258
271
  return true;
259
272
  }
@@ -242,15 +242,28 @@ class StreamBuf extends EventEmitter {
242
242
  }
243
243
  else {
244
244
  const chunkBuffer = chunk.toBuffer();
245
- if (!this.paused) {
245
+ // Track whether the data has been delivered to a consumer.
246
+ // When a consumer exists ("data" listeners or a native WritableStream),
247
+ // the data is consumed externally and must NOT also be accumulated in
248
+ // internal buffers — otherwise the buffers grow without bound (memory leak)
249
+ // since no one ever calls read()/toBuffer() to drain them.
250
+ let consumed = false;
251
+ if (!this.paused && this.listenerCount("data") > 0) {
246
252
  this.emit("data", chunkBuffer);
253
+ consumed = true;
247
254
  }
248
255
  // Also write to native WritableStream if connected
249
256
  if (this._writableStreamWriter) {
250
257
  this._asyncWriteQueue = this._asyncWriteQueue.then(() => this._writableStreamWriter.write(chunkBuffer));
258
+ consumed = true;
259
+ }
260
+ // Only buffer internally when no consumer has received the data.
261
+ // This keeps StreamBuf working as a memory buffer (write then read/toBuffer)
262
+ // while preventing unbounded growth when used as an event-driven pass-through.
263
+ if (!consumed) {
264
+ this._writeToBuffers(chunk);
265
+ this.emit("readable");
251
266
  }
252
- this._writeToBuffers(chunk);
253
- this.emit("readable");
254
267
  }
255
268
  return true;
256
269
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v5.1.16
2
+ * @cj-tech-master/excelts v5.1.17
3
3
  * TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
4
4
  * (c) 2026 cjnoname
5
5
  * Released under the MIT License
@@ -18711,10 +18711,19 @@ var ExcelTS = (function(exports) {
18711
18711
  }
18712
18712
  else {
18713
18713
  const chunkBuffer = chunk.toBuffer();
18714
- if (!this.paused) this.emit("data", chunkBuffer);
18715
- if (this._writableStreamWriter) this._asyncWriteQueue = this._asyncWriteQueue.then(() => this._writableStreamWriter.write(chunkBuffer));
18716
- this._writeToBuffers(chunk);
18717
- this.emit("readable");
18714
+ let consumed = false;
18715
+ if (!this.paused && this.listenerCount("data") > 0) {
18716
+ this.emit("data", chunkBuffer);
18717
+ consumed = true;
18718
+ }
18719
+ if (this._writableStreamWriter) {
18720
+ this._asyncWriteQueue = this._asyncWriteQueue.then(() => this._writableStreamWriter.write(chunkBuffer));
18721
+ consumed = true;
18722
+ }
18723
+ if (!consumed) {
18724
+ this._writeToBuffers(chunk);
18725
+ this.emit("readable");
18726
+ }
18718
18727
  }
18719
18728
  return true;
18720
18729
  }