@ai-sdk-tool/parser 3.2.1 → 3.3.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.
package/dist/rjson.cjs ADDED
@@ -0,0 +1,697 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/rjson/index.ts
21
+ var rjson_exports = {};
22
+ __export(rjson_exports, {
23
+ parse: () => parse,
24
+ stringify: () => stringify,
25
+ transform: () => transform
26
+ });
27
+ module.exports = __toCommonJS(rjson_exports);
28
+ var WHITESPACE_TEST_REGEX = /\s/;
29
+ var WHITESPACE_REGEX = /^\s+/;
30
+ var OBJECT_START_REGEX = /^\{/;
31
+ var OBJECT_END_REGEX = /^\}/;
32
+ var ARRAY_START_REGEX = /^\[/;
33
+ var ARRAY_END_REGEX = /^\]/;
34
+ var COMMA_REGEX = /^,/;
35
+ var COLON_REGEX = /^:/;
36
+ var KEYWORD_REGEX = /^(?:true|false|null)/;
37
+ var NUMBER_REGEX = /^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/;
38
+ var STRING_DOUBLE_REGEX = /^"(?:[^"\\]|\\["bnrtf\\/]|\\u[0-9a-fA-F]{4})*"/;
39
+ var STRING_SINGLE_REGEX = /^'((?:[^'\\]|\\['bnrtf\\/]|\\u[0-9a-fA-F]{4})*)'/;
40
+ var COMMENT_SINGLE_REGEX = /^\/\/.*?(?:\r\n|\r|\n)/;
41
+ var COMMENT_MULTI_REGEX = /^\/\*[\s\S]*?\*\//;
42
+ var IDENTIFIER_REGEX = /^[$a-zA-Z0-9_\-+.*?!|&%^/#\\]+/;
43
+ function some(array, f) {
44
+ let acc = false;
45
+ for (let i = 0; i < array.length; i += 1) {
46
+ const result = f(array[i], i, array);
47
+ acc = result === void 0 ? false : result;
48
+ if (acc) {
49
+ return acc;
50
+ }
51
+ }
52
+ return acc;
53
+ }
54
+ function makeLexer(tokenSpecs) {
55
+ return (contents) => {
56
+ const tokens = [];
57
+ let line = 1;
58
+ let remainingContents = contents;
59
+ function findToken() {
60
+ const result = some(tokenSpecs, (tokenSpec) => {
61
+ const m = tokenSpec.re.exec(remainingContents);
62
+ if (m) {
63
+ const raw = m[0];
64
+ remainingContents = remainingContents.slice(raw.length);
65
+ return {
66
+ raw,
67
+ matched: tokenSpec.f(m)
68
+ // Process the match using the spec's function
69
+ };
70
+ }
71
+ return;
72
+ });
73
+ return result === false ? void 0 : result;
74
+ }
75
+ while (remainingContents !== "") {
76
+ const matched = findToken();
77
+ if (!matched) {
78
+ const err = new SyntaxError(
79
+ `Unexpected character: ${remainingContents[0]}; input: ${remainingContents.substr(
80
+ 0,
81
+ 100
82
+ )}`
83
+ );
84
+ err.line = line;
85
+ throw err;
86
+ }
87
+ const tokenWithLine = matched.matched;
88
+ tokenWithLine.line = line;
89
+ line += matched.raw.replace(/[^\n]/g, "").length;
90
+ tokens.push(tokenWithLine);
91
+ }
92
+ return tokens;
93
+ };
94
+ }
95
+ function fStringSingle(m) {
96
+ const content = m[1].replace(
97
+ /([^'\\]|\\['bnrtf\\]|\\u[0-9a-fA-F]{4})/g,
98
+ (mm) => {
99
+ if (mm === '"') {
100
+ return '\\"';
101
+ }
102
+ if (mm === "\\'") {
103
+ return "'";
104
+ }
105
+ return mm;
106
+ }
107
+ );
108
+ const match = `"${content}"`;
109
+ return {
110
+ type: "string",
111
+ match,
112
+ // The transformed, double-quoted string representation
113
+ // Use JSON.parse on the transformed string to handle escape sequences correctly
114
+ value: JSON.parse(match)
115
+ };
116
+ }
117
+ function fStringDouble(m) {
118
+ return {
119
+ type: "string",
120
+ match: m[0],
121
+ // The raw matched string (including quotes)
122
+ value: JSON.parse(m[0])
123
+ // Use JSON.parse to handle escapes and get the value
124
+ };
125
+ }
126
+ function fIdentifier(m) {
127
+ const value = m[0];
128
+ const match = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + // Escape backslashes and quotes
129
+ '"';
130
+ return {
131
+ type: "string",
132
+ // Treat identifiers as strings
133
+ value,
134
+ // The original identifier name
135
+ match
136
+ // The double-quoted string representation
137
+ };
138
+ }
139
+ function fComment(m) {
140
+ const match = m[0].replace(
141
+ /./g,
142
+ (c) => WHITESPACE_TEST_REGEX.test(c) ? c : " "
143
+ );
144
+ return {
145
+ type: " ",
146
+ // Represent comments as whitespace tokens
147
+ match,
148
+ // String containing original newlines and spaces for other chars
149
+ value: void 0
150
+ // Comments don't have a semantic value
151
+ };
152
+ }
153
+ function fNumber(m) {
154
+ return {
155
+ type: "number",
156
+ match: m[0],
157
+ // The raw matched number string
158
+ value: Number.parseFloat(m[0])
159
+ // Convert string to number
160
+ };
161
+ }
162
+ function fKeyword(m) {
163
+ let value;
164
+ switch (m[0]) {
165
+ case "null":
166
+ value = null;
167
+ break;
168
+ case "true":
169
+ value = true;
170
+ break;
171
+ case "false":
172
+ value = false;
173
+ break;
174
+ default:
175
+ throw new Error(`Unexpected keyword: ${m[0]}`);
176
+ }
177
+ return {
178
+ type: "atom",
179
+ // Use 'atom' type for these literals
180
+ match: m[0],
181
+ // The raw matched keyword
182
+ value
183
+ // The corresponding JavaScript value
184
+ };
185
+ }
186
+ function makeTokenSpecs(relaxed) {
187
+ function f(type) {
188
+ return (m) => {
189
+ return { type, match: m[0], value: void 0 };
190
+ };
191
+ }
192
+ let tokenSpecs = [
193
+ { re: WHITESPACE_REGEX, f: f(" ") },
194
+ // Whitespace
195
+ { re: OBJECT_START_REGEX, f: f("{") },
196
+ // Object start
197
+ { re: OBJECT_END_REGEX, f: f("}") },
198
+ // Object end
199
+ { re: ARRAY_START_REGEX, f: f("[") },
200
+ // Array start
201
+ { re: ARRAY_END_REGEX, f: f("]") },
202
+ // Array end
203
+ { re: COMMA_REGEX, f: f(",") },
204
+ // Comma separator
205
+ { re: COLON_REGEX, f: f(":") },
206
+ // Key-value separator
207
+ { re: KEYWORD_REGEX, f: fKeyword },
208
+ // Keywords
209
+ // Number: optional sign, digits, optional decimal part, optional exponent
210
+ { re: NUMBER_REGEX, f: fNumber },
211
+ // String: double-quoted, handles escapes
212
+ { re: STRING_DOUBLE_REGEX, f: fStringDouble }
213
+ ];
214
+ if (relaxed) {
215
+ tokenSpecs = tokenSpecs.concat([
216
+ // Single-quoted strings
217
+ {
218
+ re: STRING_SINGLE_REGEX,
219
+ f: fStringSingle
220
+ },
221
+ // Single-line comments (// ...)
222
+ { re: COMMENT_SINGLE_REGEX, f: fComment },
223
+ // Multi-line comments (/* ... */)
224
+ { re: COMMENT_MULTI_REGEX, f: fComment },
225
+ // Unquoted identifiers (treated as strings)
226
+ // Allows letters, numbers, _, -, +, ., *, ?, !, |, &, %, ^, /, #, \
227
+ { re: IDENTIFIER_REGEX, f: fIdentifier }
228
+ // Note: The order matters here. Identifiers are checked after keywords/numbers.
229
+ ]);
230
+ }
231
+ return tokenSpecs;
232
+ }
233
+ var lexer = makeLexer(makeTokenSpecs(true));
234
+ var strictLexer = makeLexer(makeTokenSpecs(false));
235
+ function previousNWSToken(tokens, index) {
236
+ let currentIndex = index;
237
+ for (; currentIndex >= 0; currentIndex -= 1) {
238
+ if (tokens[currentIndex].type !== " ") {
239
+ return currentIndex;
240
+ }
241
+ }
242
+ return;
243
+ }
244
+ function stripTrailingComma(tokens) {
245
+ const res = [];
246
+ tokens.forEach((token, index) => {
247
+ if (index > 0 && (token.type === "]" || token.type === "}")) {
248
+ const prevNWSTokenIndex = previousNWSToken(res, res.length - 1);
249
+ if (prevNWSTokenIndex !== void 0 && res[prevNWSTokenIndex].type === ",") {
250
+ const preCommaIndex = previousNWSToken(res, prevNWSTokenIndex - 1);
251
+ if (preCommaIndex !== void 0 && res[preCommaIndex].type !== "[" && res[preCommaIndex].type !== "{") {
252
+ res[prevNWSTokenIndex] = {
253
+ type: " ",
254
+ match: " ",
255
+ // Represent as a single space
256
+ value: void 0,
257
+ // Whitespace has no value
258
+ line: res[prevNWSTokenIndex].line
259
+ // Preserve original line number
260
+ };
261
+ }
262
+ }
263
+ }
264
+ res.push(token);
265
+ });
266
+ return res;
267
+ }
268
+ function transform(text) {
269
+ let tokens = lexer(text);
270
+ tokens = stripTrailingComma(tokens);
271
+ return tokens.reduce((str, token) => str + token.match, "");
272
+ }
273
+ function popToken(tokens, state) {
274
+ var _a, _b;
275
+ const token = tokens[state.pos];
276
+ state.pos += 1;
277
+ if (!token) {
278
+ const lastLine = tokens.length !== 0 ? (_b = (_a = tokens.at(-1)) == null ? void 0 : _a.line) != null ? _b : 1 : 1;
279
+ return { type: "eof", match: "", value: void 0, line: lastLine };
280
+ }
281
+ return token;
282
+ }
283
+ function strToken(token) {
284
+ switch (token.type) {
285
+ case "atom":
286
+ case "string":
287
+ case "number":
288
+ return `${token.type} ${token.match}`;
289
+ case "eof":
290
+ return "end-of-file";
291
+ default:
292
+ return `'${token.type}'`;
293
+ }
294
+ }
295
+ function skipColon(tokens, state) {
296
+ const colon = popToken(tokens, state);
297
+ if (colon.type !== ":") {
298
+ const message = `Unexpected token: ${strToken(colon)}, expected ':'`;
299
+ if (state.tolerant) {
300
+ state.warnings.push({
301
+ message,
302
+ line: colon.line
303
+ });
304
+ state.pos -= 1;
305
+ } else {
306
+ const err = new SyntaxError(message);
307
+ err.line = colon.line;
308
+ throw err;
309
+ }
310
+ }
311
+ }
312
+ function skipPunctuation(tokens, state, valid) {
313
+ const punctuation = [",", ":", "]", "}"];
314
+ let token = popToken(tokens, state);
315
+ while (true) {
316
+ if (valid == null ? void 0 : valid.includes(token.type)) {
317
+ return token;
318
+ }
319
+ if (token.type === "eof") {
320
+ return token;
321
+ }
322
+ if (punctuation.includes(token.type)) {
323
+ const message = `Unexpected token: ${strToken(
324
+ token
325
+ )}, expected '[', '{', number, string or atom`;
326
+ if (state.tolerant) {
327
+ state.warnings.push({
328
+ message,
329
+ line: token.line
330
+ });
331
+ token = popToken(tokens, state);
332
+ } else {
333
+ const err = new SyntaxError(message);
334
+ err.line = token.line;
335
+ throw err;
336
+ }
337
+ } else {
338
+ return token;
339
+ }
340
+ }
341
+ }
342
+ function raiseError(state, token, message) {
343
+ if (state.tolerant) {
344
+ state.warnings.push({
345
+ message,
346
+ line: token.line
347
+ });
348
+ } else {
349
+ const err = new SyntaxError(message);
350
+ err.line = token.line;
351
+ throw err;
352
+ }
353
+ }
354
+ function raiseUnexpected(state, token, expected) {
355
+ raiseError(
356
+ state,
357
+ token,
358
+ `Unexpected token: ${strToken(token)}, expected ${expected}`
359
+ );
360
+ }
361
+ function checkDuplicates(state, obj, token) {
362
+ const key = String(token.value);
363
+ if (!state.duplicate && Object.hasOwn(obj, key)) {
364
+ raiseError(state, token, `Duplicate key: ${key}`);
365
+ }
366
+ }
367
+ function appendPair(state, obj, key, value) {
368
+ const finalValue = state.reviver ? state.reviver(key, value) : value;
369
+ if (finalValue !== void 0) {
370
+ obj[key] = finalValue;
371
+ }
372
+ }
373
+ function parsePair(tokens, state, obj) {
374
+ let token = skipPunctuation(tokens, state, [":", "string", "number", "atom"]);
375
+ let value;
376
+ if (token.type !== "string") {
377
+ raiseUnexpected(state, token, "string key");
378
+ if (state.tolerant) {
379
+ switch (token.type) {
380
+ case ":":
381
+ token = {
382
+ type: "string",
383
+ value: "null",
384
+ match: '"null"',
385
+ line: token.line
386
+ };
387
+ state.pos -= 1;
388
+ break;
389
+ case "number":
390
+ // Use number as string key
391
+ case "atom":
392
+ token = {
393
+ type: "string",
394
+ value: String(token.value),
395
+ match: `"${token.value}"`,
396
+ line: token.line
397
+ };
398
+ break;
399
+ case "[":
400
+ // Assume missing key before an array
401
+ case "{":
402
+ state.pos -= 1;
403
+ value = parseAny(tokens, state);
404
+ checkDuplicates(state, obj, {
405
+ type: "string",
406
+ value: "null",
407
+ match: '"null"',
408
+ line: token.line
409
+ });
410
+ appendPair(state, obj, "null", value);
411
+ return;
412
+ // Finished parsing this "pair"
413
+ case "eof":
414
+ return;
415
+ // Cannot recover
416
+ default:
417
+ return;
418
+ }
419
+ } else {
420
+ return;
421
+ }
422
+ }
423
+ checkDuplicates(state, obj, token);
424
+ const key = String(token.value);
425
+ skipColon(tokens, state);
426
+ value = parseAny(tokens, state);
427
+ appendPair(state, obj, key, value);
428
+ }
429
+ function parseElement(tokens, state, arr) {
430
+ const key = arr.length;
431
+ const value = parseAny(tokens, state);
432
+ arr[key] = state.reviver ? state.reviver(String(key), value) : value;
433
+ }
434
+ function parseObject(tokens, state) {
435
+ const obj = {};
436
+ return parseMany(tokens, state, obj, {
437
+ skip: [":", "}"],
438
+ // Initially skip over colon or closing brace (for empty/tolerant cases)
439
+ elementParser: parsePair,
440
+ // Use parsePair to parse each key-value element
441
+ elementName: "string key",
442
+ // Expected element type for errors
443
+ endSymbol: "}"
444
+ // The closing token for an object
445
+ });
446
+ }
447
+ function parseArray(tokens, state) {
448
+ const arr = [];
449
+ return parseMany(tokens, state, arr, {
450
+ skip: ["]"],
451
+ // Initially skip over closing bracket (for empty/tolerant cases)
452
+ elementParser: parseElement,
453
+ // Use parseElement to parse each array item
454
+ elementName: "json value",
455
+ // Expected element type for errors
456
+ endSymbol: "]"
457
+ // The closing token for an array
458
+ });
459
+ }
460
+ function handleInvalidToken(token, state, opts, result) {
461
+ raiseUnexpected(state, token, `',' or '${opts.endSymbol}'`);
462
+ if (state.tolerant) {
463
+ if (token.type === "eof") {
464
+ return result;
465
+ }
466
+ state.pos -= 1;
467
+ return null;
468
+ }
469
+ return result;
470
+ }
471
+ function handleCommaToken(params) {
472
+ const { token, tokens, state, opts, result } = params;
473
+ const nextToken = tokens[state.pos];
474
+ if (state.tolerant && nextToken && nextToken.type === opts.endSymbol) {
475
+ raiseError(state, token, `Trailing comma before '${opts.endSymbol}'`);
476
+ popToken(tokens, state);
477
+ return result;
478
+ }
479
+ opts.elementParser(tokens, state, result);
480
+ return null;
481
+ }
482
+ function parseManyInitialElement(tokens, state, result, opts) {
483
+ const token = skipPunctuation(tokens, state, opts.skip);
484
+ if (token.type === "eof") {
485
+ raiseUnexpected(state, token, `'${opts.endSymbol}' or ${opts.elementName}`);
486
+ return result;
487
+ }
488
+ if (token.type === opts.endSymbol) {
489
+ return result;
490
+ }
491
+ state.pos -= 1;
492
+ opts.elementParser(tokens, state, result);
493
+ return;
494
+ }
495
+ function parseManyProcessToken(params) {
496
+ const { token, tokens, state, opts, result } = params;
497
+ if (token.type !== opts.endSymbol && token.type !== ",") {
498
+ const handledResult = handleInvalidToken(token, state, opts, result);
499
+ if (handledResult !== null) {
500
+ return handledResult;
501
+ }
502
+ }
503
+ if (token.type === opts.endSymbol) {
504
+ return result;
505
+ }
506
+ if (token.type === ",") {
507
+ const handledResult = handleCommaToken({
508
+ token,
509
+ tokens,
510
+ state,
511
+ opts,
512
+ result
513
+ });
514
+ if (handledResult !== null) {
515
+ return handledResult;
516
+ }
517
+ return;
518
+ }
519
+ opts.elementParser(tokens, state, result);
520
+ return;
521
+ }
522
+ function parseMany(tokens, state, result, opts) {
523
+ const initialResult = parseManyInitialElement(tokens, state, result, opts);
524
+ if (initialResult !== void 0) {
525
+ return initialResult;
526
+ }
527
+ while (true) {
528
+ const token = popToken(tokens, state);
529
+ const processedResult = parseManyProcessToken({
530
+ token,
531
+ tokens,
532
+ state,
533
+ opts,
534
+ result
535
+ });
536
+ if (processedResult !== void 0) {
537
+ return processedResult;
538
+ }
539
+ }
540
+ }
541
+ function endChecks(tokens, state, ret) {
542
+ if (state.pos < tokens.length) {
543
+ if (state.tolerant) {
544
+ skipPunctuation(tokens, state);
545
+ }
546
+ if (state.pos < tokens.length) {
547
+ raiseError(
548
+ state,
549
+ tokens[state.pos],
550
+ `Unexpected token: ${strToken(tokens[state.pos])}, expected end-of-input`
551
+ );
552
+ }
553
+ }
554
+ if (state.tolerant && state.warnings.length > 0) {
555
+ const message = state.warnings.length === 1 ? state.warnings[0].message : `${state.warnings.length} parse warnings`;
556
+ const err = new SyntaxError(message);
557
+ err.line = state.warnings[0].line;
558
+ err.warnings = state.warnings;
559
+ err.obj = ret;
560
+ throw err;
561
+ }
562
+ }
563
+ function parseAny(tokens, state, end = false) {
564
+ const token = skipPunctuation(tokens, state);
565
+ let ret;
566
+ if (token.type === "eof") {
567
+ if (end) {
568
+ raiseUnexpected(state, token, "json value");
569
+ }
570
+ raiseUnexpected(state, token, "json value");
571
+ return;
572
+ }
573
+ switch (token.type) {
574
+ case "{":
575
+ ret = parseObject(tokens, state);
576
+ break;
577
+ case "[":
578
+ ret = parseArray(tokens, state);
579
+ break;
580
+ case "string":
581
+ // String literal
582
+ case "number":
583
+ // Number literal
584
+ case "atom":
585
+ ret = token.value;
586
+ break;
587
+ default:
588
+ raiseUnexpected(state, token, "json value");
589
+ if (state.tolerant) {
590
+ ret = null;
591
+ } else {
592
+ return;
593
+ }
594
+ }
595
+ if (end) {
596
+ ret = state.reviver ? state.reviver("", ret) : ret;
597
+ endChecks(tokens, state, ret);
598
+ }
599
+ return ret;
600
+ }
601
+ function normalizeParseOptions(optsOrReviver) {
602
+ var _a;
603
+ let options = {};
604
+ if (typeof optsOrReviver === "function") {
605
+ options.reviver = optsOrReviver;
606
+ } else if (optsOrReviver !== null && typeof optsOrReviver === "object") {
607
+ options = { ...optsOrReviver };
608
+ } else if (optsOrReviver !== void 0) {
609
+ throw new TypeError(
610
+ "Second argument must be a reviver function or an options object."
611
+ );
612
+ }
613
+ if (options.relaxed === void 0) {
614
+ if (options.warnings === true || options.tolerant === true) {
615
+ options.relaxed = true;
616
+ } else if (options.warnings === false && options.tolerant === false) {
617
+ options.relaxed = false;
618
+ } else {
619
+ options.relaxed = true;
620
+ }
621
+ }
622
+ options.tolerant = options.tolerant || options.warnings;
623
+ options.duplicate = (_a = options.duplicate) != null ? _a : false;
624
+ return options;
625
+ }
626
+ function createParseState(options) {
627
+ var _a, _b;
628
+ return {
629
+ pos: 0,
630
+ reviver: options.reviver,
631
+ tolerant: (_a = options.tolerant) != null ? _a : false,
632
+ duplicate: (_b = options.duplicate) != null ? _b : false,
633
+ warnings: []
634
+ };
635
+ }
636
+ function parseWithCustomParser(text, options) {
637
+ const lexerToUse = options.relaxed ? lexer : strictLexer;
638
+ let tokens = lexerToUse(text);
639
+ if (options.relaxed) {
640
+ tokens = stripTrailingComma(tokens);
641
+ }
642
+ tokens = tokens.filter((token) => token.type !== " ");
643
+ const state = createParseState(options);
644
+ return parseAny(tokens, state, true);
645
+ }
646
+ function parseWithTransform(text, options) {
647
+ let tokens = lexer(text);
648
+ tokens = stripTrailingComma(tokens);
649
+ const newtext = tokens.reduce((str, token) => str + token.match, "");
650
+ return JSON.parse(
651
+ newtext,
652
+ options.reviver
653
+ );
654
+ }
655
+ function parse(text, optsOrReviver) {
656
+ const options = normalizeParseOptions(optsOrReviver);
657
+ if (!(options.relaxed || options.warnings || options.tolerant) && options.duplicate) {
658
+ return JSON.parse(
659
+ text,
660
+ options.reviver
661
+ );
662
+ }
663
+ if (options.warnings || options.tolerant || !options.duplicate) {
664
+ return parseWithCustomParser(text, options);
665
+ }
666
+ return parseWithTransform(text, options);
667
+ }
668
+ function stringifyPair(obj, key) {
669
+ return `${JSON.stringify(key)}:${stringify(obj[key])}`;
670
+ }
671
+ function stringify(obj) {
672
+ const type = typeof obj;
673
+ if (type === "string" || type === "number" || type === "boolean" || obj === null) {
674
+ return JSON.stringify(obj);
675
+ }
676
+ if (type === "undefined") {
677
+ return "null";
678
+ }
679
+ if (Array.isArray(obj)) {
680
+ const elements = obj.map(stringify).join(",");
681
+ return `[${elements}]`;
682
+ }
683
+ if (type === "object") {
684
+ const keys = Object.keys(obj);
685
+ keys.sort();
686
+ const pairs = keys.map((key) => stringifyPair(obj, key)).join(",");
687
+ return `{${pairs}}`;
688
+ }
689
+ return "null";
690
+ }
691
+ // Annotate the CommonJS export names for ESM import in node:
692
+ 0 && (module.exports = {
693
+ parse,
694
+ stringify,
695
+ transform
696
+ });
697
+ //# sourceMappingURL=rjson.cjs.map