json-stream-lite 1.0.18 → 1.1.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.
@@ -88,7 +88,7 @@ export declare class ByteBuffer {
88
88
  compact(): void;
89
89
  /**
90
90
  * Override to customize when to compact the buffer
91
- * By default, compacts when more than 1000 items have been consumed
91
+ * By default, compacts when more than maxBufferSize bytes have been consumed
92
92
  *
93
93
  * @returns boolean indicating whether to compact the buffer
94
94
  */
@@ -224,7 +224,7 @@ export class ByteBuffer {
224
224
  }
225
225
  /**
226
226
  * Override to customize when to compact the buffer
227
- * By default, compacts when more than 1000 items have been consumed
227
+ * By default, compacts when more than maxBufferSize bytes have been consumed
228
228
  *
229
229
  * @returns boolean indicating whether to compact the buffer
230
230
  */
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './generators.js';
2
2
  export * from './types.js';
3
3
  export * from './stringify.js';
4
4
  export * from './parser.js';
5
+ export * from './errors.js';
package/dist/index.js CHANGED
@@ -2,3 +2,4 @@ export * from './generators.js';
2
2
  export * from './types.js';
3
3
  export * from './stringify.js';
4
4
  export * from './parser.js';
5
+ export * from './errors.js';
package/dist/parser.js CHANGED
@@ -175,11 +175,11 @@ export class JsonEntity {
175
175
  throw new Error('JSON entity has already been consumed.');
176
176
  }
177
177
  while (!this.buffer.atEof()) {
178
- await this.buffer.readStreamAsync();
179
178
  const res = this.tryParse(() => this.read());
180
179
  if (res !== undefined) {
181
180
  return res;
182
181
  }
182
+ await this.buffer.readStreamAsync();
183
183
  }
184
184
  return this.read();
185
185
  }
@@ -489,7 +489,6 @@ export class JsonObject extends JsonEntity {
489
489
  */
490
490
  async *membersAsync() {
491
491
  while (!this.buffer.atEof()) {
492
- await this.buffer.readStreamAsync();
493
492
  const memberGen = this.members();
494
493
  let currentMember = undefined;
495
494
  while (true) {
@@ -505,6 +504,7 @@ export class JsonObject extends JsonEntity {
505
504
  await currentMember.value.key.consumeAsync();
506
505
  await currentMember.value.value.consumeAsync();
507
506
  }
507
+ await this.buffer.readStreamAsync();
508
508
  }
509
509
  }
510
510
  /**
@@ -580,7 +580,6 @@ export class JsonArray extends JsonEntity {
580
580
  */
581
581
  async *itemsAsync() {
582
582
  while (!this.buffer.atEof()) {
583
- await this.buffer.readStreamAsync();
584
583
  const itemGen = this.items();
585
584
  let currentItem = undefined;
586
585
  while (true) {
@@ -594,6 +593,7 @@ export class JsonArray extends JsonEntity {
594
593
  yield currentItem.value;
595
594
  await currentItem.value.consumeAsync();
596
595
  }
596
+ await this.buffer.readStreamAsync();
597
597
  }
598
598
  }
599
599
  /**
@@ -697,7 +697,6 @@ export class JsonKeyValueParser extends JsonEntity {
697
697
  */
698
698
  async *parseAsync() {
699
699
  while (!this.buffer.atEof()) {
700
- await this.buffer.readStreamAsync();
701
700
  const parserGen = this.parse();
702
701
  let currentPair = undefined;
703
702
  while (true) {
@@ -710,6 +709,7 @@ export class JsonKeyValueParser extends JsonEntity {
710
709
  }
711
710
  yield currentPair.value;
712
711
  }
712
+ await this.buffer.readStreamAsync();
713
713
  }
714
714
  }
715
715
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-stream-lite",
3
- "version": "1.0.18",
3
+ "version": "1.1.0",
4
4
  "description": "A lightweight, memory-efficient, zero-dependency streaming JSON parser and stringifier for JavaScript and TypeScript. It works in both Node.js and browser environments.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",