json-stream-lite 1.1.4 → 1.1.5
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.
- package/dist/byte-buffer.js +3 -1
- package/dist/parser.d.ts +11 -0
- package/dist/parser.js +15 -0
- package/package.json +1 -1
package/dist/byte-buffer.js
CHANGED
|
@@ -54,7 +54,9 @@ export class ByteBuffer {
|
|
|
54
54
|
asyncIterable instanceof ReadableStream
|
|
55
55
|
? readableStreamToAsyncIterable(asyncIterable)
|
|
56
56
|
: typeof asyncIterable === 'string'
|
|
57
|
-
?
|
|
57
|
+
? (function* () {
|
|
58
|
+
yield* [asyncIterable];
|
|
59
|
+
})()
|
|
58
60
|
: asyncIterable;
|
|
59
61
|
}
|
|
60
62
|
/**
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ByteBuffer } from './byte-buffer.js';
|
|
2
|
+
import { JsonStreamStringifyOptions } from './stringify.js';
|
|
2
3
|
import { ByteStream, JsonKeyValuePair, StreamInput } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Abstract base class for all JSON entities.
|
|
@@ -88,6 +89,16 @@ export declare abstract class JsonEntity<T> {
|
|
|
88
89
|
* @throws Error if the entity has already been consumed
|
|
89
90
|
*/
|
|
90
91
|
tryParse<T = this>(cb: (entity: this) => T): T | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Serializes a value into a JSON string using json-stream-lite.
|
|
94
|
+
* See `jsonStreamStringify` for more details.
|
|
95
|
+
*/
|
|
96
|
+
static stringify(value: unknown, replacer?: any, indent?: number, options?: JsonStreamStringifyOptions): Generator<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Serializes a value into JSON as Uint8Array byte chunks using json-stream-lite.
|
|
99
|
+
* See `jsonStreamStringifyBytes` for more details.
|
|
100
|
+
*/
|
|
101
|
+
static stringifyBytes(value: unknown, replacer?: any, indent?: number, options?: JsonStreamStringifyOptions): Generator<Uint8Array>;
|
|
91
102
|
}
|
|
92
103
|
/**
|
|
93
104
|
* Represents a JSON string value.
|
package/dist/parser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ByteBuffer } from './byte-buffer.js';
|
|
2
|
+
import { jsonStreamStringify, jsonStreamStringifyBytes, } from './stringify.js';
|
|
2
3
|
import { bytesToNumber, bytesToString } from './utils.js';
|
|
3
4
|
/**
|
|
4
5
|
* Map of character names to their byte values for JSON parsing.
|
|
@@ -224,6 +225,20 @@ export class JsonEntity {
|
|
|
224
225
|
this.buffer.locked = false;
|
|
225
226
|
});
|
|
226
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Serializes a value into a JSON string using json-stream-lite.
|
|
230
|
+
* See `jsonStreamStringify` for more details.
|
|
231
|
+
*/
|
|
232
|
+
static stringify(value, replacer, indent = 0, options) {
|
|
233
|
+
return jsonStreamStringify(value, replacer, indent, options);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Serializes a value into JSON as Uint8Array byte chunks using json-stream-lite.
|
|
237
|
+
* See `jsonStreamStringifyBytes` for more details.
|
|
238
|
+
*/
|
|
239
|
+
static stringifyBytes(value, replacer, indent = 0, options) {
|
|
240
|
+
return jsonStreamStringifyBytes(value, replacer, indent, options);
|
|
241
|
+
}
|
|
227
242
|
}
|
|
228
243
|
/**
|
|
229
244
|
* Represents a JSON string value.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-stream-lite",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
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",
|