jsonc-effect 0.2.1 → 0.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/ast.js +255 -0
- package/equality.js +166 -0
- package/errors.js +218 -0
- package/format.js +453 -0
- package/index.d.ts +1933 -1983
- package/index.js +11 -1454
- package/package.json +50 -56
- package/parse.js +548 -0
- package/scanner.js +350 -0
- package/schema-integration.js +178 -0
- package/schemas.js +325 -0
- package/tsdoc-metadata.json +11 -11
- package/visitor.js +355 -0
package/index.d.ts
CHANGED
|
@@ -1,1983 +1,1933 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* @see {@link
|
|
129
|
-
*
|
|
130
|
-
* @
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* @
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* @
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* @
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* ```
|
|
229
|
-
*
|
|
230
|
-
* @public
|
|
231
|
-
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
*
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* @
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* @
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
* @
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
* @
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* @
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
* @
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* @
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
* @
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
* @
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
* @see {@link
|
|
563
|
-
*
|
|
564
|
-
* @
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
* import {
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
* )
|
|
579
|
-
* ```
|
|
580
|
-
*
|
|
581
|
-
* @
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
* @
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
* )
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
* @
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
* @
|
|
759
|
-
*/
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
* @
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
*
|
|
847
|
-
*
|
|
848
|
-
* @
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
*
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
*
|
|
860
|
-
*
|
|
861
|
-
* )
|
|
862
|
-
*
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
*
|
|
878
|
-
*
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
* @
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
* @
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
*
|
|
924
|
-
*
|
|
925
|
-
*
|
|
926
|
-
*
|
|
927
|
-
*
|
|
928
|
-
*
|
|
929
|
-
*
|
|
930
|
-
*
|
|
931
|
-
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
936
|
-
*
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
944
|
-
*
|
|
945
|
-
*
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
*
|
|
966
|
-
*
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
985
|
-
*
|
|
986
|
-
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
-
*
|
|
999
|
-
*
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
* @
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1034
|
-
* @
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
*
|
|
1081
|
-
*
|
|
1082
|
-
* @
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
*
|
|
1097
|
-
* @
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
* An
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1142
|
-
*
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
* @
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
*
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
*
|
|
1194
|
-
*
|
|
1195
|
-
*
|
|
1196
|
-
* @
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
* @
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
* @
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1230
|
-
*
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
*
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
* @
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
*
|
|
1302
|
-
*
|
|
1303
|
-
*
|
|
1304
|
-
*
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1320
|
-
*
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
*
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1330
|
-
*
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
1336
|
-
*
|
|
1337
|
-
*
|
|
1338
|
-
*
|
|
1339
|
-
*
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
*
|
|
1349
|
-
*
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
1353
|
-
* console.log(
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1356
|
-
*
|
|
1357
|
-
* @
|
|
1358
|
-
* `
|
|
1359
|
-
*
|
|
1360
|
-
*
|
|
1361
|
-
*
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
*
|
|
1402
|
-
*
|
|
1403
|
-
*
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1428
|
-
* @
|
|
1429
|
-
*
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1435
|
-
*
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1438
|
-
*
|
|
1439
|
-
*
|
|
1440
|
-
*
|
|
1441
|
-
*
|
|
1442
|
-
*
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1501
|
-
*
|
|
1502
|
-
* @
|
|
1503
|
-
* The
|
|
1504
|
-
*
|
|
1505
|
-
*
|
|
1506
|
-
*
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1538
|
-
*
|
|
1539
|
-
*
|
|
1540
|
-
*
|
|
1541
|
-
*
|
|
1542
|
-
*
|
|
1543
|
-
*
|
|
1544
|
-
*
|
|
1545
|
-
* @
|
|
1546
|
-
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
*
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1560
|
-
*
|
|
1561
|
-
*
|
|
1562
|
-
*
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
*
|
|
1573
|
-
*
|
|
1574
|
-
*
|
|
1575
|
-
*
|
|
1576
|
-
*
|
|
1577
|
-
*
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
*
|
|
1583
|
-
*
|
|
1584
|
-
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1589
|
-
*
|
|
1590
|
-
* with
|
|
1591
|
-
*
|
|
1592
|
-
*
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
*
|
|
1598
|
-
*
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1602
|
-
*
|
|
1603
|
-
* @
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
*
|
|
1607
|
-
*
|
|
1608
|
-
*
|
|
1609
|
-
*
|
|
1610
|
-
*
|
|
1611
|
-
*
|
|
1612
|
-
*
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1616
|
-
*
|
|
1617
|
-
*
|
|
1618
|
-
*
|
|
1619
|
-
* @
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
*
|
|
1624
|
-
*
|
|
1625
|
-
*
|
|
1626
|
-
*
|
|
1627
|
-
*
|
|
1628
|
-
*
|
|
1629
|
-
*
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
1632
|
-
*
|
|
1633
|
-
*
|
|
1634
|
-
*
|
|
1635
|
-
*
|
|
1636
|
-
*
|
|
1637
|
-
*
|
|
1638
|
-
*
|
|
1639
|
-
*
|
|
1640
|
-
*
|
|
1641
|
-
*
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1651
|
-
*
|
|
1652
|
-
* ```
|
|
1653
|
-
*
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
*
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1664
|
-
*
|
|
1665
|
-
* @
|
|
1666
|
-
*
|
|
1667
|
-
*
|
|
1668
|
-
*
|
|
1669
|
-
*
|
|
1670
|
-
*
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
*
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
1685
|
-
*
|
|
1686
|
-
*
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
1689
|
-
*
|
|
1690
|
-
*
|
|
1691
|
-
*
|
|
1692
|
-
*
|
|
1693
|
-
*
|
|
1694
|
-
*
|
|
1695
|
-
*
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
1698
|
-
* @
|
|
1699
|
-
*
|
|
1700
|
-
*
|
|
1701
|
-
*
|
|
1702
|
-
*
|
|
1703
|
-
*
|
|
1704
|
-
*
|
|
1705
|
-
*
|
|
1706
|
-
*
|
|
1707
|
-
*
|
|
1708
|
-
*
|
|
1709
|
-
*
|
|
1710
|
-
*
|
|
1711
|
-
*
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1716
|
-
*
|
|
1717
|
-
*
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
*
|
|
1730
|
-
*
|
|
1731
|
-
*
|
|
1732
|
-
*
|
|
1733
|
-
*
|
|
1734
|
-
*
|
|
1735
|
-
*
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1739
|
-
*
|
|
1740
|
-
*
|
|
1741
|
-
*
|
|
1742
|
-
*
|
|
1743
|
-
*
|
|
1744
|
-
*
|
|
1745
|
-
*
|
|
1746
|
-
* }
|
|
1747
|
-
*
|
|
1748
|
-
*
|
|
1749
|
-
*
|
|
1750
|
-
*
|
|
1751
|
-
*
|
|
1752
|
-
* @
|
|
1753
|
-
*
|
|
1754
|
-
*
|
|
1755
|
-
*
|
|
1756
|
-
*
|
|
1757
|
-
*
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
*
|
|
1766
|
-
*
|
|
1767
|
-
*
|
|
1768
|
-
*
|
|
1769
|
-
*
|
|
1770
|
-
* @
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
};
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
*
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
*
|
|
1823
|
-
*
|
|
1824
|
-
*
|
|
1825
|
-
*
|
|
1826
|
-
* @
|
|
1827
|
-
*
|
|
1828
|
-
* @
|
|
1829
|
-
*
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1834
|
-
*
|
|
1835
|
-
*
|
|
1836
|
-
* @
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
*
|
|
1840
|
-
*
|
|
1841
|
-
*
|
|
1842
|
-
*
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1845
|
-
*
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
1848
|
-
*
|
|
1849
|
-
*
|
|
1850
|
-
* ```
|
|
1851
|
-
*
|
|
1852
|
-
*
|
|
1853
|
-
*
|
|
1854
|
-
*
|
|
1855
|
-
*
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
1858
|
-
*
|
|
1859
|
-
*
|
|
1860
|
-
*
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1874
|
-
*
|
|
1875
|
-
*
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1879
|
-
*
|
|
1880
|
-
*
|
|
1881
|
-
*
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
1886
|
-
*
|
|
1887
|
-
* @
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
*
|
|
1892
|
-
*
|
|
1893
|
-
*
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
1905
|
-
*
|
|
1906
|
-
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1915
|
-
*
|
|
1916
|
-
*
|
|
1917
|
-
*
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1921
|
-
*
|
|
1922
|
-
*
|
|
1923
|
-
*
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
1927
|
-
*
|
|
1928
|
-
*
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
* preserving laziness. The generator yields events as it encounters
|
|
1935
|
-
* tokens from the scanner.
|
|
1936
|
-
*
|
|
1937
|
-
* @public
|
|
1938
|
-
*/
|
|
1939
|
-
export declare const visit: (text: string, options?: Partial<JsoncParseOptions>) => Stream.Stream<JsoncVisitorEvent>;
|
|
1940
|
-
|
|
1941
|
-
/**
|
|
1942
|
-
* Visit JSONC text and collect all events matching a type-guard predicate.
|
|
1943
|
-
*
|
|
1944
|
-
* This is a convenience that composes {@link visit}, `Stream.filter`, and
|
|
1945
|
-
* `Stream.runCollect` into a single call.
|
|
1946
|
-
*
|
|
1947
|
-
* @param text - The JSONC source text to visit.
|
|
1948
|
-
* @param predicate - A type-guard function that narrows
|
|
1949
|
-
* {@link JsoncVisitorEvent} to the desired subtype `A`.
|
|
1950
|
-
* @param options - Optional partial {@link JsoncParseOptions}.
|
|
1951
|
-
* @returns An `Effect` that succeeds with a read-only array of the
|
|
1952
|
-
* matched events.
|
|
1953
|
-
*
|
|
1954
|
-
* @remarks
|
|
1955
|
-
* Equivalent to:
|
|
1956
|
-
* ```
|
|
1957
|
-
* visit(text, options) |> Stream.filter(predicate) |> Stream.runCollect
|
|
1958
|
-
* ```
|
|
1959
|
-
* Use this when you need all matching events and do not require
|
|
1960
|
-
* intermediate stream transformations.
|
|
1961
|
-
*
|
|
1962
|
-
* @see {@link visit} for full stream-level control.
|
|
1963
|
-
*
|
|
1964
|
-
* @example Collecting literal values
|
|
1965
|
-
* ```ts
|
|
1966
|
-
* import { Effect } from "effect";
|
|
1967
|
-
* import type { JsoncVisitorEvent } from "jsonc-effect";
|
|
1968
|
-
* import { visitCollect } from "jsonc-effect";
|
|
1969
|
-
*
|
|
1970
|
-
* const literals = Effect.runSync(
|
|
1971
|
-
* visitCollect(
|
|
1972
|
-
* '{ "a": 1, "b": true }',
|
|
1973
|
-
* (e): e is Extract<JsoncVisitorEvent, { _tag: "LiteralValue" }> =>
|
|
1974
|
-
* e._tag === "LiteralValue",
|
|
1975
|
-
* ),
|
|
1976
|
-
* );
|
|
1977
|
-
* ```
|
|
1978
|
-
*
|
|
1979
|
-
* @public
|
|
1980
|
-
*/
|
|
1981
|
-
export declare const visitCollect: <A extends JsoncVisitorEvent>(text: string, predicate: (event: JsoncVisitorEvent) => event is A, options?: Partial<JsoncParseOptions>) => Effect.Effect<ReadonlyArray<A>>;
|
|
1982
|
-
|
|
1983
|
-
export { }
|
|
1
|
+
import { Effect, Option, Schema, Stream } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/schemas.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Token types produced by the JSONC scanner.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Uses string literals instead of numeric enums so that token kinds are
|
|
9
|
+
* self-documenting in debug output, log messages, and test assertions.
|
|
10
|
+
* This avoids the "reverse-mapping" confusion of TypeScript numeric enums
|
|
11
|
+
* and makes pattern-matching with `Schema.Literal` straightforward.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link createScanner} — creates a scanner that emits these token types
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
declare const JsoncSyntaxKind: Schema.Literal<["OpenBrace", "CloseBrace", "OpenBracket", "CloseBracket", "Comma", "Colon", "Null", "True", "False", "String", "Number", "LineComment", "BlockComment", "LineBreak", "Trivia", "Unknown", "EOF"]>;
|
|
18
|
+
/**
|
|
19
|
+
* The union of all JSONC token kind string literals.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link (JsoncSyntaxKind:variable)}
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
type JsoncSyntaxKind = Schema.Schema.Type<typeof JsoncSyntaxKind>;
|
|
26
|
+
/**
|
|
27
|
+
* Scanner error codes produced by the JSONC scanner.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* `"None"` indicates a successful scan with no errors. All other values
|
|
31
|
+
* describe a specific lexical error encountered while tokenizing input.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link JsoncScanner} — the scanner interface that reports these errors
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
declare const JsoncScanError: Schema.Literal<["None", "UnexpectedEndOfComment", "UnexpectedEndOfString", "UnexpectedEndOfNumber", "InvalidUnicode", "InvalidEscapeCharacter", "InvalidCharacter", "InvalidSymbol"]>;
|
|
38
|
+
/**
|
|
39
|
+
* The union of all JSONC scan error string literals.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link (JsoncScanError:variable)}
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
type JsoncScanError = Schema.Schema.Type<typeof JsoncScanError>;
|
|
46
|
+
declare const JsoncToken_base: Schema.Class<JsoncToken, {
|
|
47
|
+
kind: Schema.Literal<["OpenBrace", "CloseBrace", "OpenBracket", "CloseBracket", "Comma", "Colon", "Null", "True", "False", "String", "Number", "LineComment", "BlockComment", "LineBreak", "Trivia", "Unknown", "EOF"]>;
|
|
48
|
+
value: typeof Schema.String;
|
|
49
|
+
offset: typeof Schema.Number;
|
|
50
|
+
length: typeof Schema.Number;
|
|
51
|
+
startLine: typeof Schema.Number;
|
|
52
|
+
startCharacter: typeof Schema.Number;
|
|
53
|
+
error: Schema.Literal<["None", "UnexpectedEndOfComment", "UnexpectedEndOfString", "UnexpectedEndOfNumber", "InvalidUnicode", "InvalidEscapeCharacter", "InvalidCharacter", "InvalidSymbol"]>;
|
|
54
|
+
}, Schema.Struct.Encoded<{
|
|
55
|
+
kind: Schema.Literal<["OpenBrace", "CloseBrace", "OpenBracket", "CloseBracket", "Comma", "Colon", "Null", "True", "False", "String", "Number", "LineComment", "BlockComment", "LineBreak", "Trivia", "Unknown", "EOF"]>;
|
|
56
|
+
value: typeof Schema.String;
|
|
57
|
+
offset: typeof Schema.Number;
|
|
58
|
+
length: typeof Schema.Number;
|
|
59
|
+
startLine: typeof Schema.Number;
|
|
60
|
+
startCharacter: typeof Schema.Number;
|
|
61
|
+
error: Schema.Literal<["None", "UnexpectedEndOfComment", "UnexpectedEndOfString", "UnexpectedEndOfNumber", "InvalidUnicode", "InvalidEscapeCharacter", "InvalidCharacter", "InvalidSymbol"]>;
|
|
62
|
+
}>, never, {
|
|
63
|
+
readonly error: "InvalidCharacter" | "InvalidEscapeCharacter" | "InvalidSymbol" | "InvalidUnicode" | "None" | "UnexpectedEndOfComment" | "UnexpectedEndOfNumber" | "UnexpectedEndOfString";
|
|
64
|
+
} & {
|
|
65
|
+
readonly kind: "BlockComment" | "CloseBrace" | "CloseBracket" | "Colon" | "Comma" | "EOF" | "False" | "LineBreak" | "LineComment" | "Null" | "Number" | "OpenBrace" | "OpenBracket" | "String" | "Trivia" | "True" | "Unknown";
|
|
66
|
+
} & {
|
|
67
|
+
readonly length: number;
|
|
68
|
+
} & {
|
|
69
|
+
readonly offset: number;
|
|
70
|
+
} & {
|
|
71
|
+
readonly startCharacter: number;
|
|
72
|
+
} & {
|
|
73
|
+
readonly startLine: number;
|
|
74
|
+
} & {
|
|
75
|
+
readonly value: string;
|
|
76
|
+
}, {}, {}>;
|
|
77
|
+
/**
|
|
78
|
+
* A single token produced by the JSONC scanner, carrying its kind, textual
|
|
79
|
+
* value, position within the source, and any scan error.
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* - `kind` — the {@link (JsoncSyntaxKind:type)} discriminator for this token.
|
|
83
|
+
* - `value` — the raw text slice from the source document.
|
|
84
|
+
* - `offset` — zero-based character offset from the start of the document.
|
|
85
|
+
* - `length` — character length of this token in the source.
|
|
86
|
+
* - `startLine` — zero-based line number where the token begins.
|
|
87
|
+
* - `startCharacter` — zero-based column within `startLine`.
|
|
88
|
+
* - `error` — a {@link (JsoncScanError:type)} code; `"None"` when the token is valid.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link createScanner} — produces a stream of `JsoncToken` instances
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { JsoncToken } from "jsonc-effect";
|
|
95
|
+
*
|
|
96
|
+
* const token = new JsoncToken({
|
|
97
|
+
* kind: "String",
|
|
98
|
+
* value: '"hello"',
|
|
99
|
+
* offset: 0,
|
|
100
|
+
* length: 7,
|
|
101
|
+
* startLine: 0,
|
|
102
|
+
* startCharacter: 0,
|
|
103
|
+
* error: "None",
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* console.log(token.kind); // "String"
|
|
107
|
+
* console.log(token.value); // '"hello"'
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @privateRemarks
|
|
111
|
+
* `Schema.Class` gives `JsoncToken` structural equality via `Data.Class`
|
|
112
|
+
* under the hood, so two tokens with identical fields are considered equal
|
|
113
|
+
* by `Equal.equals`. This is essential for test assertions and Effect's
|
|
114
|
+
* structural comparison semantics.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
declare class JsoncToken extends JsoncToken_base {}
|
|
119
|
+
/**
|
|
120
|
+
* Discriminator values for JSONC AST node types.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* These correspond to the JSON value types (`"string"`, `"number"`,
|
|
124
|
+
* `"boolean"`, `"null"`) plus structural types (`"object"`, `"array"`)
|
|
125
|
+
* and the special `"property"` type representing a key-value pair inside
|
|
126
|
+
* an object.
|
|
127
|
+
*
|
|
128
|
+
* @see {@link JsoncNode} — the AST node that carries this discriminator
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
declare const JsoncNodeType: Schema.Literal<["object", "array", "property", "string", "number", "boolean", "null"]>;
|
|
133
|
+
/**
|
|
134
|
+
* The union of all JSONC AST node type string literals.
|
|
135
|
+
*
|
|
136
|
+
* @see {@link (JsoncNodeType:variable)}
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
type JsoncNodeType = Schema.Schema.Type<typeof JsoncNodeType>;
|
|
141
|
+
declare const JsoncNode_base: Schema.Class<JsoncNode, {
|
|
142
|
+
type: Schema.Literal<["object", "array", "property", "string", "number", "boolean", "null"]>;
|
|
143
|
+
value: Schema.optional<typeof Schema.Unknown>;
|
|
144
|
+
offset: typeof Schema.Number;
|
|
145
|
+
length: typeof Schema.Number;
|
|
146
|
+
colonOffset: Schema.optional<typeof Schema.Number>;
|
|
147
|
+
children: Schema.optional<Schema.Array$<Schema.suspend<JsoncNode, JsoncNode, never>>>;
|
|
148
|
+
}, Schema.Struct.Encoded<{
|
|
149
|
+
type: Schema.Literal<["object", "array", "property", "string", "number", "boolean", "null"]>;
|
|
150
|
+
value: Schema.optional<typeof Schema.Unknown>;
|
|
151
|
+
offset: typeof Schema.Number;
|
|
152
|
+
length: typeof Schema.Number;
|
|
153
|
+
colonOffset: Schema.optional<typeof Schema.Number>;
|
|
154
|
+
children: Schema.optional<Schema.Array$<Schema.suspend<JsoncNode, JsoncNode, never>>>;
|
|
155
|
+
}>, never, {
|
|
156
|
+
readonly children?: readonly JsoncNode[] | undefined;
|
|
157
|
+
} & {
|
|
158
|
+
readonly colonOffset?: number | undefined;
|
|
159
|
+
} & {
|
|
160
|
+
readonly value?: unknown;
|
|
161
|
+
} & {
|
|
162
|
+
readonly length: number;
|
|
163
|
+
} & {
|
|
164
|
+
readonly offset: number;
|
|
165
|
+
} & {
|
|
166
|
+
readonly type: "array" | "boolean" | "null" | "number" | "object" | "property" | "string";
|
|
167
|
+
}, {}, {}>;
|
|
168
|
+
/**
|
|
169
|
+
* AST node representing a parsed JSONC element, produced by {@link parseTree}.
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* The `parent` field present in Microsoft's `jsonc-parser` is intentionally
|
|
173
|
+
* omitted here to avoid circular references, which would break structural
|
|
174
|
+
* equality, serialization, and Effect's `Schema.encode`/`Schema.decode`
|
|
175
|
+
* pipelines. Child relationships are expressed via the `children` array,
|
|
176
|
+
* and the recursive type is handled with `Schema.suspend`.
|
|
177
|
+
*
|
|
178
|
+
* - `type` — the {@link (JsoncNodeType:type)} discriminator.
|
|
179
|
+
* - `value` — the decoded JavaScript value for leaf nodes (`string`,
|
|
180
|
+
* `number`, `boolean`, `null`); `undefined` for structural nodes.
|
|
181
|
+
* - `offset` — zero-based character offset of this node in the source.
|
|
182
|
+
* - `length` — character length of this node in the source.
|
|
183
|
+
* - `colonOffset` — for `"property"` nodes, the offset of the `:` separator.
|
|
184
|
+
* - `children` — child nodes; present for `"object"`, `"array"`, and
|
|
185
|
+
* `"property"` nodes.
|
|
186
|
+
*
|
|
187
|
+
* @see {@link parseTree} — produces the root `JsoncNode`
|
|
188
|
+
* @see {@link findNode} — locates a descendant by path
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* import { Effect } from "effect";
|
|
193
|
+
* import { parseTree } from "jsonc-effect";
|
|
194
|
+
*
|
|
195
|
+
* const program = parseTree('{ "key": [1, 2] }').pipe(
|
|
196
|
+
* Effect.map((root) => {
|
|
197
|
+
* // root.type === "object"
|
|
198
|
+
* const property = root.children?.[0]; // "property" node
|
|
199
|
+
* const array = property?.children?.[1]; // "array" node
|
|
200
|
+
* console.log(array?.children?.length); // 2
|
|
201
|
+
* }),
|
|
202
|
+
* );
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* @privateRemarks
|
|
206
|
+
* Unlike the `*Base` pattern needed for `Data.TaggedError` subclasses,
|
|
207
|
+
* `Schema.Class` works directly for data types — api-extractor can roll up
|
|
208
|
+
* the generated `.d.ts` without issues. The `Schema.suspend` call for
|
|
209
|
+
* `children` is required to break the circular type reference at the schema
|
|
210
|
+
* level while still allowing recursive decode/encode.
|
|
211
|
+
*
|
|
212
|
+
* @public
|
|
213
|
+
*/
|
|
214
|
+
declare class JsoncNode extends JsoncNode_base {}
|
|
215
|
+
/**
|
|
216
|
+
* A single segment of a {@link (JsoncPath:type)}: a `string` for object property
|
|
217
|
+
* keys or a `number` for array indices.
|
|
218
|
+
*
|
|
219
|
+
* @see {@link findNode} — resolves a path to an AST node
|
|
220
|
+
* @see {@link modify} — applies a value change at a path
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* import type { JsoncSegment } from "jsonc-effect";
|
|
225
|
+
*
|
|
226
|
+
* const objectKey: JsoncSegment = "compilerOptions";
|
|
227
|
+
* const arrayIndex: JsoncSegment = 0;
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
declare const JsoncSegment: Schema.Union<[typeof Schema.String, typeof Schema.Number]>;
|
|
233
|
+
/**
|
|
234
|
+
* A single path segment type — `string | number`.
|
|
235
|
+
*
|
|
236
|
+
* @see {@link (JsoncSegment:variable)}
|
|
237
|
+
*
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
type JsoncSegment = Schema.Schema.Type<typeof JsoncSegment>;
|
|
241
|
+
/**
|
|
242
|
+
* An ordered sequence of {@link (JsoncSegment:type)} values describing a location
|
|
243
|
+
* within a JSONC document tree.
|
|
244
|
+
*
|
|
245
|
+
* @see {@link findNode} — resolves a `JsoncPath` to an AST node
|
|
246
|
+
* @see {@link modify} — applies a modification at a `JsoncPath`
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* import type { JsoncPath } from "jsonc-effect";
|
|
251
|
+
*
|
|
252
|
+
* // Path to the "strict" property inside "compilerOptions"
|
|
253
|
+
* const path: JsoncPath = ["compilerOptions", "strict"];
|
|
254
|
+
*
|
|
255
|
+
* // Path to the second element of the "include" array
|
|
256
|
+
* const arrayPath: JsoncPath = ["include", 1];
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @public
|
|
260
|
+
*/
|
|
261
|
+
declare const JsoncPath: Schema.Array$<Schema.Union<[typeof Schema.String, typeof Schema.Number]>>;
|
|
262
|
+
/**
|
|
263
|
+
* An array of path segments — `ReadonlyArray<string | number>`.
|
|
264
|
+
*
|
|
265
|
+
* @see {@link (JsoncPath:variable)}
|
|
266
|
+
*
|
|
267
|
+
* @public
|
|
268
|
+
*/
|
|
269
|
+
type JsoncPath = Schema.Schema.Type<typeof JsoncPath>;
|
|
270
|
+
declare const JsoncEdit_base: Schema.Class<JsoncEdit, {
|
|
271
|
+
offset: typeof Schema.Number;
|
|
272
|
+
length: typeof Schema.Number;
|
|
273
|
+
content: typeof Schema.String;
|
|
274
|
+
}, Schema.Struct.Encoded<{
|
|
275
|
+
offset: typeof Schema.Number;
|
|
276
|
+
length: typeof Schema.Number;
|
|
277
|
+
content: typeof Schema.String;
|
|
278
|
+
}>, never, {
|
|
279
|
+
readonly content: string;
|
|
280
|
+
} & {
|
|
281
|
+
readonly length: number;
|
|
282
|
+
} & {
|
|
283
|
+
readonly offset: number;
|
|
284
|
+
}, {}, {}>;
|
|
285
|
+
/**
|
|
286
|
+
* A non-mutating text edit describing a replacement within a JSONC document.
|
|
287
|
+
*
|
|
288
|
+
* @remarks
|
|
289
|
+
* Edits use zero-based `offset` and `length` to identify the span of text
|
|
290
|
+
* to replace, and `content` for the replacement string. To insert without
|
|
291
|
+
* removing text, set `length` to `0`. To delete without inserting, set
|
|
292
|
+
* `content` to `""`.
|
|
293
|
+
*
|
|
294
|
+
* Edits returned by {@link format} and {@link modify} should be applied
|
|
295
|
+
* via {@link applyEdits}, which processes them in reverse order so that
|
|
296
|
+
* earlier offsets remain valid.
|
|
297
|
+
*
|
|
298
|
+
* @see {@link format} — produces edits for formatting
|
|
299
|
+
* @see {@link modify} — produces edits for value changes
|
|
300
|
+
* @see {@link applyEdits} — applies an array of edits to a source string
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* import { JsoncEdit } from "jsonc-effect";
|
|
305
|
+
*
|
|
306
|
+
* // An edit that inserts ", true" at offset 10
|
|
307
|
+
* const edit = new JsoncEdit({ offset: 10, length: 0, content: ", true" });
|
|
308
|
+
*
|
|
309
|
+
* console.log(edit.offset); // 10
|
|
310
|
+
* console.log(edit.length); // 0
|
|
311
|
+
* console.log(edit.content); // ", true"
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
declare class JsoncEdit extends JsoncEdit_base {}
|
|
317
|
+
declare const JsoncRange_base: Schema.Class<JsoncRange, {
|
|
318
|
+
offset: typeof Schema.Number;
|
|
319
|
+
length: typeof Schema.Number;
|
|
320
|
+
}, Schema.Struct.Encoded<{
|
|
321
|
+
offset: typeof Schema.Number;
|
|
322
|
+
length: typeof Schema.Number;
|
|
323
|
+
}>, never, {
|
|
324
|
+
readonly length: number;
|
|
325
|
+
} & {
|
|
326
|
+
readonly offset: number;
|
|
327
|
+
}, {}, {}>;
|
|
328
|
+
/**
|
|
329
|
+
* A range within a JSONC document, expressed as a zero-based character
|
|
330
|
+
* offset and a length in characters.
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* Both `offset` and `length` are measured in UTF-16 code units (JavaScript
|
|
334
|
+
* string indices). Pass a `JsoncRange` to {@link format} to restrict
|
|
335
|
+
* formatting to a specific region of the document rather than the whole file.
|
|
336
|
+
*
|
|
337
|
+
* @see {@link format} — accepts an optional `JsoncRange` parameter
|
|
338
|
+
*
|
|
339
|
+
* @public
|
|
340
|
+
*/
|
|
341
|
+
declare class JsoncRange extends JsoncRange_base {}
|
|
342
|
+
declare const JsoncParseOptions_base: Schema.Class<JsoncParseOptions, {
|
|
343
|
+
disallowComments: Schema.optionalWith<typeof Schema.Boolean, {
|
|
344
|
+
default: () => false;
|
|
345
|
+
}>;
|
|
346
|
+
allowTrailingComma: Schema.optionalWith<typeof Schema.Boolean, {
|
|
347
|
+
default: () => true;
|
|
348
|
+
}>;
|
|
349
|
+
allowEmptyContent: Schema.optionalWith<typeof Schema.Boolean, {
|
|
350
|
+
default: () => false;
|
|
351
|
+
}>;
|
|
352
|
+
}, Schema.Struct.Encoded<{
|
|
353
|
+
disallowComments: Schema.optionalWith<typeof Schema.Boolean, {
|
|
354
|
+
default: () => false;
|
|
355
|
+
}>;
|
|
356
|
+
allowTrailingComma: Schema.optionalWith<typeof Schema.Boolean, {
|
|
357
|
+
default: () => true;
|
|
358
|
+
}>;
|
|
359
|
+
allowEmptyContent: Schema.optionalWith<typeof Schema.Boolean, {
|
|
360
|
+
default: () => false;
|
|
361
|
+
}>;
|
|
362
|
+
}>, never, {
|
|
363
|
+
readonly allowEmptyContent?: boolean | undefined;
|
|
364
|
+
} & {
|
|
365
|
+
readonly allowTrailingComma?: boolean | undefined;
|
|
366
|
+
} & {
|
|
367
|
+
readonly disallowComments?: boolean | undefined;
|
|
368
|
+
}, {}, {}>;
|
|
369
|
+
/**
|
|
370
|
+
* Options controlling JSONC parse behavior.
|
|
371
|
+
*
|
|
372
|
+
* @remarks
|
|
373
|
+
* - `disallowComments` — when `true`, line and block comments are treated
|
|
374
|
+
* as parse errors. Defaults to `false`.
|
|
375
|
+
* - `allowTrailingComma` — when `true`, trailing commas after the last
|
|
376
|
+
* element in arrays and objects are permitted. Defaults to `true`, which
|
|
377
|
+
* differs from Microsoft's `jsonc-parser` (where the default is `false`).
|
|
378
|
+
* - `allowEmptyContent` — when `true`, an empty string parses as
|
|
379
|
+
* `undefined` rather than producing an error. Defaults to `false`.
|
|
380
|
+
*
|
|
381
|
+
* @see {@link parse} — parses JSONC text into a JavaScript value
|
|
382
|
+
* @see {@link parseTree} — parses JSONC text into an AST
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* import { Effect } from "effect";
|
|
387
|
+
* import { parse, JsoncParseOptions } from "jsonc-effect";
|
|
388
|
+
*
|
|
389
|
+
* const options = new JsoncParseOptions({
|
|
390
|
+
* disallowComments: true,
|
|
391
|
+
* allowTrailingComma: false,
|
|
392
|
+
* });
|
|
393
|
+
*
|
|
394
|
+
* const program = parse('{ "key": "value" }', options).pipe(
|
|
395
|
+
* Effect.map((value) => console.log(value)),
|
|
396
|
+
* );
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @public
|
|
400
|
+
*/
|
|
401
|
+
declare class JsoncParseOptions extends JsoncParseOptions_base {}
|
|
402
|
+
declare const JsoncFormattingOptions_base: Schema.Class<JsoncFormattingOptions, {
|
|
403
|
+
tabSize: Schema.optionalWith<typeof Schema.Number, {
|
|
404
|
+
default: () => number;
|
|
405
|
+
}>;
|
|
406
|
+
insertSpaces: Schema.optionalWith<typeof Schema.Boolean, {
|
|
407
|
+
default: () => true;
|
|
408
|
+
}>;
|
|
409
|
+
eol: Schema.optionalWith<typeof Schema.String, {
|
|
410
|
+
default: () => string;
|
|
411
|
+
}>;
|
|
412
|
+
insertFinalNewline: Schema.optionalWith<typeof Schema.Boolean, {
|
|
413
|
+
default: () => false;
|
|
414
|
+
}>;
|
|
415
|
+
keepLines: Schema.optionalWith<typeof Schema.Boolean, {
|
|
416
|
+
default: () => false;
|
|
417
|
+
}>;
|
|
418
|
+
}, Schema.Struct.Encoded<{
|
|
419
|
+
tabSize: Schema.optionalWith<typeof Schema.Number, {
|
|
420
|
+
default: () => number;
|
|
421
|
+
}>;
|
|
422
|
+
insertSpaces: Schema.optionalWith<typeof Schema.Boolean, {
|
|
423
|
+
default: () => true;
|
|
424
|
+
}>;
|
|
425
|
+
eol: Schema.optionalWith<typeof Schema.String, {
|
|
426
|
+
default: () => string;
|
|
427
|
+
}>;
|
|
428
|
+
insertFinalNewline: Schema.optionalWith<typeof Schema.Boolean, {
|
|
429
|
+
default: () => false;
|
|
430
|
+
}>;
|
|
431
|
+
keepLines: Schema.optionalWith<typeof Schema.Boolean, {
|
|
432
|
+
default: () => false;
|
|
433
|
+
}>;
|
|
434
|
+
}>, never, {
|
|
435
|
+
readonly eol?: string | undefined;
|
|
436
|
+
} & {
|
|
437
|
+
readonly insertFinalNewline?: boolean | undefined;
|
|
438
|
+
} & {
|
|
439
|
+
readonly insertSpaces?: boolean | undefined;
|
|
440
|
+
} & {
|
|
441
|
+
readonly keepLines?: boolean | undefined;
|
|
442
|
+
} & {
|
|
443
|
+
readonly tabSize?: number | undefined;
|
|
444
|
+
}, {}, {}>;
|
|
445
|
+
/**
|
|
446
|
+
* Options controlling JSONC formatting behavior.
|
|
447
|
+
*
|
|
448
|
+
* @remarks
|
|
449
|
+
* - `tabSize` — number of spaces per indentation level. Defaults to `2`.
|
|
450
|
+
* - `insertSpaces` — when `true`, use spaces for indentation; when `false`,
|
|
451
|
+
* use tab characters. Defaults to `true`.
|
|
452
|
+
* - `eol` — the end-of-line sequence. Defaults to `"\n"`.
|
|
453
|
+
* - `insertFinalNewline` — when `true`, ensure the formatted output ends
|
|
454
|
+
* with a newline. Defaults to `false`.
|
|
455
|
+
* - `keepLines` — when `true`, preserve existing line breaks in the source
|
|
456
|
+
* rather than reflowing. Defaults to `false`.
|
|
457
|
+
*
|
|
458
|
+
* @see {@link format} — uses these options to produce formatting edits
|
|
459
|
+
* @see {@link formatAndApply} — formats and applies edits in one step
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```ts
|
|
463
|
+
* import { Effect } from "effect";
|
|
464
|
+
* import { formatAndApply, JsoncFormattingOptions } from "jsonc-effect";
|
|
465
|
+
*
|
|
466
|
+
* const options = new JsoncFormattingOptions({
|
|
467
|
+
* tabSize: 4,
|
|
468
|
+
* insertSpaces: true,
|
|
469
|
+
* insertFinalNewline: true,
|
|
470
|
+
* });
|
|
471
|
+
*
|
|
472
|
+
* const program = formatAndApply('{"key":"value"}', options).pipe(
|
|
473
|
+
* Effect.map((formatted) => console.log(formatted)),
|
|
474
|
+
* );
|
|
475
|
+
* ```
|
|
476
|
+
*
|
|
477
|
+
* @public
|
|
478
|
+
*/
|
|
479
|
+
declare class JsoncFormattingOptions extends JsoncFormattingOptions_base {}
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/ast.d.ts
|
|
482
|
+
/**
|
|
483
|
+
* Find an AST node at a specific JSON path.
|
|
484
|
+
*
|
|
485
|
+
* Supports {@link https://effect.website/docs/effect/function#dual | Function.dual}
|
|
486
|
+
* for both data-first and data-last (pipeline) usage.
|
|
487
|
+
*
|
|
488
|
+
* @param root - The AST root node obtained from {@link parseTree}.
|
|
489
|
+
* @param path - An array of string keys and numeric indices describing the path to traverse.
|
|
490
|
+
*
|
|
491
|
+
* @returns `Effect<Option<JsoncNode>>` — the node at the given path, or `Option.none()` if the
|
|
492
|
+
* path does not exist in the tree.
|
|
493
|
+
*
|
|
494
|
+
* @remarks
|
|
495
|
+
* String segments navigate object properties and number segments navigate array indices.
|
|
496
|
+
* Returns `Option.none()` when any segment along the path cannot be resolved — for example,
|
|
497
|
+
* accessing a property on a non-object node or an out-of-bounds array index.
|
|
498
|
+
*
|
|
499
|
+
* @see {@link parseTree} — produces the AST root this function operates on
|
|
500
|
+
* @see {@link getNodeValue} — reconstructs a JS value from a found node
|
|
501
|
+
* @see {@link JsoncNode} — the AST node type
|
|
502
|
+
* @see {@link (JsoncPath:type)} — the path segment array type
|
|
503
|
+
*
|
|
504
|
+
* @example Data-first usage
|
|
505
|
+
* ```ts
|
|
506
|
+
* import { Effect, Option } from "effect";
|
|
507
|
+
* import type { JsoncNode } from "jsonc-effect";
|
|
508
|
+
* import { parseTree, findNode } from "jsonc-effect";
|
|
509
|
+
*
|
|
510
|
+
* const program = Effect.gen(function* () {
|
|
511
|
+
* const root: Option.Option<JsoncNode> = yield* parseTree('{ "a": { "b": 1 } }');
|
|
512
|
+
* if (Option.isNone(root)) return Option.none();
|
|
513
|
+
* return yield* findNode(root.value, ["a", "b"]);
|
|
514
|
+
* });
|
|
515
|
+
*
|
|
516
|
+
* const result = Effect.runSync(program);
|
|
517
|
+
* // result is Option.some(node) where node.value === 1
|
|
518
|
+
* ```
|
|
519
|
+
*
|
|
520
|
+
* @example Data-last pipeline usage
|
|
521
|
+
* ```ts
|
|
522
|
+
* import { Effect, Option, pipe } from "effect";
|
|
523
|
+
* import type { JsoncNode } from "jsonc-effect";
|
|
524
|
+
* import { parseTree, findNode } from "jsonc-effect";
|
|
525
|
+
*
|
|
526
|
+
* const program = Effect.gen(function* () {
|
|
527
|
+
* const root: Option.Option<JsoncNode> = yield* parseTree('{ "x": [10, 20] }');
|
|
528
|
+
* if (Option.isNone(root)) return Option.none();
|
|
529
|
+
* return yield* pipe(root.value, findNode(["x", 1]));
|
|
530
|
+
* });
|
|
531
|
+
*
|
|
532
|
+
* const result = Effect.runSync(program);
|
|
533
|
+
* // result is Option.some(node) where node.value === 20
|
|
534
|
+
* ```
|
|
535
|
+
*
|
|
536
|
+
* @privateRemarks
|
|
537
|
+
* Wrapped in `Effect.sync`; the underlying traversal is fully synchronous.
|
|
538
|
+
*
|
|
539
|
+
* @public
|
|
540
|
+
*/
|
|
541
|
+
declare const findNode: {
|
|
542
|
+
(path: JsoncPath): (root: JsoncNode) => Effect.Effect<Option.Option<JsoncNode>>;
|
|
543
|
+
(root: JsoncNode, path: JsoncPath): Effect.Effect<Option.Option<JsoncNode>>;
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* Find the innermost AST node covering a character offset.
|
|
547
|
+
*
|
|
548
|
+
* Supports {@link https://effect.website/docs/effect/function#dual | Function.dual}
|
|
549
|
+
* for both data-first and data-last (pipeline) usage.
|
|
550
|
+
*
|
|
551
|
+
* @param root - The AST root node obtained from {@link parseTree}.
|
|
552
|
+
* @param offset - A zero-based character offset into the original JSONC string.
|
|
553
|
+
*
|
|
554
|
+
* @returns `Effect<Option<JsoncNode>>` — the most deeply nested node whose span
|
|
555
|
+
* includes the offset, or `Option.none()` if the offset is outside the tree.
|
|
556
|
+
*
|
|
557
|
+
* @remarks
|
|
558
|
+
* This is useful for editor integrations such as hover information, go-to-definition,
|
|
559
|
+
* and code completions where you need to identify the token under the cursor.
|
|
560
|
+
*
|
|
561
|
+
* @see {@link parseTree} — produces the AST root this function operates on
|
|
562
|
+
* @see {@link getNodePath} — returns the JSON path to the node at an offset
|
|
563
|
+
*
|
|
564
|
+
* @example Finding a node at an offset
|
|
565
|
+
* ```ts
|
|
566
|
+
* import { Effect, Option } from "effect";
|
|
567
|
+
* import type { JsoncNode } from "jsonc-effect";
|
|
568
|
+
* import { parseTree, findNodeAtOffset } from "jsonc-effect";
|
|
569
|
+
*
|
|
570
|
+
* const program = Effect.gen(function* () {
|
|
571
|
+
* const root: Option.Option<JsoncNode> = yield* parseTree('{ "key": "value" }');
|
|
572
|
+
* if (Option.isNone(root)) return Option.none();
|
|
573
|
+
* // Offset 10 is inside the "value" string literal
|
|
574
|
+
* return yield* findNodeAtOffset(root.value, 10);
|
|
575
|
+
* });
|
|
576
|
+
*
|
|
577
|
+
* const result = Effect.runSync(program);
|
|
578
|
+
* // result is Option.some(node) where node.type === "string"
|
|
579
|
+
* ```
|
|
580
|
+
*
|
|
581
|
+
* @privateRemarks
|
|
582
|
+
* Wrapped in `Effect.sync`; the underlying traversal is fully synchronous.
|
|
583
|
+
*
|
|
584
|
+
* @public
|
|
585
|
+
*/
|
|
586
|
+
declare const findNodeAtOffset: {
|
|
587
|
+
(offset: number): (root: JsoncNode) => Effect.Effect<Option.Option<JsoncNode>>;
|
|
588
|
+
(root: JsoncNode, offset: number): Effect.Effect<Option.Option<JsoncNode>>;
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Get the JSON path to the node at a specific character offset.
|
|
592
|
+
*
|
|
593
|
+
* Supports {@link https://effect.website/docs/effect/function#dual | Function.dual}
|
|
594
|
+
* for both data-first and data-last (pipeline) usage.
|
|
595
|
+
*
|
|
596
|
+
* @param root - The AST root node obtained from {@link parseTree}.
|
|
597
|
+
* @param targetOffset - A zero-based character offset into the original JSONC string.
|
|
598
|
+
*
|
|
599
|
+
* @returns `Effect<Option<JsoncPath>>` — an array of path segments (string keys
|
|
600
|
+
* and numeric indices) leading to the innermost node at the offset, or
|
|
601
|
+
* `Option.none()` if the offset is outside the tree.
|
|
602
|
+
*
|
|
603
|
+
* @remarks
|
|
604
|
+
* Returns the path segments leading to the innermost node that spans the given
|
|
605
|
+
* offset. This is the inverse of {@link findNode} — given an offset you get the path,
|
|
606
|
+
* and given a path you get the node.
|
|
607
|
+
*
|
|
608
|
+
* @see {@link findNodeAtOffset} — returns the node itself rather than its path
|
|
609
|
+
* @see {@link (JsoncPath:type)} — the path segment array type
|
|
610
|
+
*
|
|
611
|
+
* @example Getting the path at an offset
|
|
612
|
+
* ```ts
|
|
613
|
+
* import { Effect, Option } from "effect";
|
|
614
|
+
* import type { JsoncNode, JsoncPath } from "jsonc-effect";
|
|
615
|
+
* import { parseTree, getNodePath } from "jsonc-effect";
|
|
616
|
+
*
|
|
617
|
+
* const program = Effect.gen(function* () {
|
|
618
|
+
* const root: Option.Option<JsoncNode> = yield* parseTree('{ "a": { "b": 42 } }');
|
|
619
|
+
* if (Option.isNone(root)) return Option.none();
|
|
620
|
+
* // Offset 15 points inside the value 42
|
|
621
|
+
* return yield* getNodePath(root.value, 15);
|
|
622
|
+
* });
|
|
623
|
+
*
|
|
624
|
+
* const result: Option.Option<JsoncPath> = Effect.runSync(program);
|
|
625
|
+
* // result is Option.some(["a", "b"])
|
|
626
|
+
* ```
|
|
627
|
+
*
|
|
628
|
+
* @public
|
|
629
|
+
*/
|
|
630
|
+
declare const getNodePath: {
|
|
631
|
+
(targetOffset: number): (root: JsoncNode) => Effect.Effect<Option.Option<JsoncPath>>;
|
|
632
|
+
(root: JsoncNode, targetOffset: number): Effect.Effect<Option.Option<JsoncPath>>;
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* Reconstruct a plain JavaScript value from an AST subtree.
|
|
636
|
+
*
|
|
637
|
+
* @param node - The AST node to evaluate, typically obtained via {@link findNode} or
|
|
638
|
+
* as the root from {@link parseTree}.
|
|
639
|
+
*
|
|
640
|
+
* @returns `Effect<unknown>` — the reconstructed JS value (object, array, string,
|
|
641
|
+
* number, boolean, or null).
|
|
642
|
+
*
|
|
643
|
+
* @remarks
|
|
644
|
+
* Recursively evaluates the node tree to produce a plain JavaScript value.
|
|
645
|
+
* This is the inverse of {@link parseTree}: where `parseTree` turns a JSONC string
|
|
646
|
+
* into an AST, `getNodeValue` turns an AST subtree back into a JS value.
|
|
647
|
+
*
|
|
648
|
+
* @see {@link parseTree} — produces the AST that this function evaluates
|
|
649
|
+
* @see {@link findNode} — locates a subtree to pass to this function
|
|
650
|
+
*
|
|
651
|
+
* @example Extracting the value of a found node
|
|
652
|
+
* ```ts
|
|
653
|
+
* import { Effect, Option } from "effect";
|
|
654
|
+
* import type { JsoncNode } from "jsonc-effect";
|
|
655
|
+
* import { parseTree, findNode, getNodeValue } from "jsonc-effect";
|
|
656
|
+
*
|
|
657
|
+
* const program = Effect.gen(function* () {
|
|
658
|
+
* const root: Option.Option<JsoncNode> = yield* parseTree('{ "items": [1, 2, 3] }');
|
|
659
|
+
* if (Option.isNone(root)) return undefined;
|
|
660
|
+
* const node: Option.Option<JsoncNode> = yield* findNode(root.value, ["items"]);
|
|
661
|
+
* if (Option.isNone(node)) return undefined;
|
|
662
|
+
* return yield* getNodeValue(node.value);
|
|
663
|
+
* });
|
|
664
|
+
*
|
|
665
|
+
* const result = Effect.runSync(program);
|
|
666
|
+
* // result is [1, 2, 3]
|
|
667
|
+
* ```
|
|
668
|
+
*
|
|
669
|
+
* @privateRemarks
|
|
670
|
+
* Useful after {@link findNode} to extract a subtree's value without manual
|
|
671
|
+
* AST traversal.
|
|
672
|
+
*
|
|
673
|
+
* @public
|
|
674
|
+
*/
|
|
675
|
+
declare const getNodeValue: (node: JsoncNode) => Effect.Effect<unknown>;
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/errors.d.ts
|
|
678
|
+
/**
|
|
679
|
+
* Error codes representing specific JSONC parse failures.
|
|
680
|
+
*
|
|
681
|
+
* @remarks
|
|
682
|
+
* Each code maps to a distinct syntactic error the parser can encounter,
|
|
683
|
+
* from invalid symbols and number formats to missing delimiters and
|
|
684
|
+
* unexpected end-of-input conditions.
|
|
685
|
+
*
|
|
686
|
+
* @see {@link JsoncParseErrorDetail} — carries one of these codes alongside
|
|
687
|
+
* position information
|
|
688
|
+
*
|
|
689
|
+
* @public
|
|
690
|
+
*/
|
|
691
|
+
declare const JsoncParseErrorCode: Schema.Literal<["InvalidSymbol", "InvalidNumberFormat", "PropertyNameExpected", "ValueExpected", "ColonExpected", "CommaExpected", "CloseBraceExpected", "CloseBracketExpected", "EndOfFileExpected", "InvalidCommentToken", "UnexpectedEndOfComment", "UnexpectedEndOfString", "UnexpectedEndOfNumber", "InvalidUnicode", "InvalidEscapeCharacter", "InvalidCharacter"]>;
|
|
692
|
+
/**
|
|
693
|
+
* The union of all JSONC parse error code string literals.
|
|
694
|
+
*
|
|
695
|
+
* @see {@link (JsoncParseErrorCode:variable)}
|
|
696
|
+
*
|
|
697
|
+
* @public
|
|
698
|
+
*/
|
|
699
|
+
type JsoncParseErrorCode = Schema.Schema.Type<typeof JsoncParseErrorCode>;
|
|
700
|
+
declare const JsoncParseErrorDetail_base: Schema.Class<JsoncParseErrorDetail, {
|
|
701
|
+
code: Schema.Literal<["InvalidSymbol", "InvalidNumberFormat", "PropertyNameExpected", "ValueExpected", "ColonExpected", "CommaExpected", "CloseBraceExpected", "CloseBracketExpected", "EndOfFileExpected", "InvalidCommentToken", "UnexpectedEndOfComment", "UnexpectedEndOfString", "UnexpectedEndOfNumber", "InvalidUnicode", "InvalidEscapeCharacter", "InvalidCharacter"]>;
|
|
702
|
+
message: typeof Schema.String;
|
|
703
|
+
offset: typeof Schema.Number;
|
|
704
|
+
length: typeof Schema.Number;
|
|
705
|
+
startLine: typeof Schema.Number;
|
|
706
|
+
startCharacter: typeof Schema.Number;
|
|
707
|
+
}, Schema.Struct.Encoded<{
|
|
708
|
+
code: Schema.Literal<["InvalidSymbol", "InvalidNumberFormat", "PropertyNameExpected", "ValueExpected", "ColonExpected", "CommaExpected", "CloseBraceExpected", "CloseBracketExpected", "EndOfFileExpected", "InvalidCommentToken", "UnexpectedEndOfComment", "UnexpectedEndOfString", "UnexpectedEndOfNumber", "InvalidUnicode", "InvalidEscapeCharacter", "InvalidCharacter"]>;
|
|
709
|
+
message: typeof Schema.String;
|
|
710
|
+
offset: typeof Schema.Number;
|
|
711
|
+
length: typeof Schema.Number;
|
|
712
|
+
startLine: typeof Schema.Number;
|
|
713
|
+
startCharacter: typeof Schema.Number;
|
|
714
|
+
}>, never, {
|
|
715
|
+
readonly code: "CloseBraceExpected" | "CloseBracketExpected" | "ColonExpected" | "CommaExpected" | "EndOfFileExpected" | "InvalidCharacter" | "InvalidCommentToken" | "InvalidEscapeCharacter" | "InvalidNumberFormat" | "InvalidSymbol" | "InvalidUnicode" | "PropertyNameExpected" | "UnexpectedEndOfComment" | "UnexpectedEndOfNumber" | "UnexpectedEndOfString" | "ValueExpected";
|
|
716
|
+
} & {
|
|
717
|
+
readonly length: number;
|
|
718
|
+
} & {
|
|
719
|
+
readonly message: string;
|
|
720
|
+
} & {
|
|
721
|
+
readonly offset: number;
|
|
722
|
+
} & {
|
|
723
|
+
readonly startCharacter: number;
|
|
724
|
+
} & {
|
|
725
|
+
readonly startLine: number;
|
|
726
|
+
}, {}, {}>;
|
|
727
|
+
/**
|
|
728
|
+
* Detail for a single parse error, including the error code, a human-readable
|
|
729
|
+
* message, and the exact position within the source document.
|
|
730
|
+
*
|
|
731
|
+
* @remarks
|
|
732
|
+
* - `code` — a {@link (JsoncParseErrorCode:type)} identifying the error kind.
|
|
733
|
+
* - `message` — a descriptive message suitable for display.
|
|
734
|
+
* - `offset` — zero-based character offset where the error occurred.
|
|
735
|
+
* - `length` — character length of the problematic span.
|
|
736
|
+
* - `startLine` — zero-based line number of the error.
|
|
737
|
+
* - `startCharacter` — zero-based column within `startLine`.
|
|
738
|
+
*
|
|
739
|
+
* @see {@link JsoncParseError} — aggregates an array of these details
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```ts
|
|
743
|
+
* import { JsoncParseErrorDetail } from "jsonc-effect";
|
|
744
|
+
*
|
|
745
|
+
* const detail = new JsoncParseErrorDetail({
|
|
746
|
+
* code: "ValueExpected",
|
|
747
|
+
* message: "Value expected",
|
|
748
|
+
* offset: 5,
|
|
749
|
+
* length: 1,
|
|
750
|
+
* startLine: 0,
|
|
751
|
+
* startCharacter: 5,
|
|
752
|
+
* });
|
|
753
|
+
*
|
|
754
|
+
* console.log(detail.code); // "ValueExpected"
|
|
755
|
+
* console.log(detail.offset); // 5
|
|
756
|
+
* ```
|
|
757
|
+
*
|
|
758
|
+
* @public
|
|
759
|
+
*/
|
|
760
|
+
declare class JsoncParseErrorDetail extends JsoncParseErrorDetail_base {}
|
|
761
|
+
/**
|
|
762
|
+
* Base class for {@link JsoncParseError}; not intended to be constructed or
|
|
763
|
+
* caught directly — use `JsoncParseError` instead.
|
|
764
|
+
*
|
|
765
|
+
* @privateRemarks
|
|
766
|
+
* The `*Base` pattern is required because `Data.TaggedError` produces complex
|
|
767
|
+
* type signatures involving intersection types and branded generics that
|
|
768
|
+
* api-extractor cannot roll up into a single `.d.ts` bundle. Exporting the
|
|
769
|
+
* base separately lets the public `JsoncParseError` class extend it with
|
|
770
|
+
* concrete fields, giving api-extractor a simple class declaration to work
|
|
771
|
+
* with. It is tagged `@public` (rather than `@internal`) because it appears
|
|
772
|
+
* in `JsoncParseError`'s heritage clause in the public `.d.ts`, and API
|
|
773
|
+
* Extractor requires release tags to be compatible across a signature.
|
|
774
|
+
*
|
|
775
|
+
* @public
|
|
776
|
+
*/
|
|
777
|
+
declare const JsoncParseErrorBase: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
778
|
+
readonly _tag: "JsoncParseError";
|
|
779
|
+
} & Readonly<A>;
|
|
780
|
+
/**
|
|
781
|
+
* Error raised when JSONC parsing encounters one or more syntax errors.
|
|
782
|
+
*
|
|
783
|
+
* @remarks
|
|
784
|
+
* Contains the full source `text`, the `options` used for parsing, and an
|
|
785
|
+
* `errors` array of {@link JsoncParseErrorDetail} instances with precise
|
|
786
|
+
* position information for each problem found.
|
|
787
|
+
*
|
|
788
|
+
* @see {@link parse} — may fail with this error
|
|
789
|
+
* @see {@link parseTree} — may fail with this error
|
|
790
|
+
*
|
|
791
|
+
* @example Catching with `Effect.catchTag`
|
|
792
|
+
* ```ts
|
|
793
|
+
* import { Effect } from "effect";
|
|
794
|
+
* import { parse } from "jsonc-effect";
|
|
795
|
+
*
|
|
796
|
+
* const program = parse("{ invalid }").pipe(
|
|
797
|
+
* Effect.catchTag("JsoncParseError", (e) => {
|
|
798
|
+
* console.error(e.errors); // Array of JsoncParseErrorDetail
|
|
799
|
+
* return Effect.succeed({});
|
|
800
|
+
* }),
|
|
801
|
+
* );
|
|
802
|
+
* ```
|
|
803
|
+
*
|
|
804
|
+
* @example Inspecting error details
|
|
805
|
+
* ```ts
|
|
806
|
+
* import { Effect } from "effect";
|
|
807
|
+
* import { parse } from "jsonc-effect";
|
|
808
|
+
*
|
|
809
|
+
* const program = parse("{ invalid }").pipe(
|
|
810
|
+
* Effect.catchTag("JsoncParseError", (e) => {
|
|
811
|
+
* for (const detail of e.errors) {
|
|
812
|
+
* console.error(
|
|
813
|
+
* `[${detail.code}] ${detail.message} at line ${detail.startLine}:${detail.startCharacter}`,
|
|
814
|
+
* );
|
|
815
|
+
* }
|
|
816
|
+
* return Effect.succeed({});
|
|
817
|
+
* }),
|
|
818
|
+
* );
|
|
819
|
+
* ```
|
|
820
|
+
*
|
|
821
|
+
* @public
|
|
822
|
+
*/
|
|
823
|
+
declare class JsoncParseError extends JsoncParseErrorBase<{
|
|
824
|
+
readonly errors: ReadonlyArray<JsoncParseErrorDetail>;
|
|
825
|
+
readonly text: string;
|
|
826
|
+
readonly options?: Partial<JsoncParseOptions>;
|
|
827
|
+
}> {
|
|
828
|
+
get message(): string;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Base class for {@link JsoncNodeNotFoundError}; not intended to be
|
|
832
|
+
* constructed or caught directly — use `JsoncNodeNotFoundError` instead.
|
|
833
|
+
*
|
|
834
|
+
* @privateRemarks
|
|
835
|
+
* Uses the same `*Base` pattern as {@link JsoncParseErrorBase} to work
|
|
836
|
+
* around api-extractor's inability to roll up the complex type produced
|
|
837
|
+
* by `Data.TaggedError` into a single `.d.ts` declaration. Tagged `@public`
|
|
838
|
+
* for the same heritage-clause-compatibility reason as `JsoncParseErrorBase`.
|
|
839
|
+
*
|
|
840
|
+
* @public
|
|
841
|
+
*/
|
|
842
|
+
declare const JsoncNodeNotFoundErrorBase: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
843
|
+
readonly _tag: "JsoncNodeNotFoundError";
|
|
844
|
+
} & Readonly<A>;
|
|
845
|
+
/**
|
|
846
|
+
* Error raised when AST navigation fails to find a node at the given path.
|
|
847
|
+
*
|
|
848
|
+
* @remarks
|
|
849
|
+
* Contains the `path` that was searched and the `rootNodeType` of the tree
|
|
850
|
+
* that was traversed.
|
|
851
|
+
*
|
|
852
|
+
* @see {@link findNode} — may fail with this error
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* ```ts
|
|
856
|
+
* import { Effect } from "effect";
|
|
857
|
+
* import { parseTree, findNode } from "jsonc-effect";
|
|
858
|
+
*
|
|
859
|
+
* const program = parseTree('{ "a": 1 }').pipe(
|
|
860
|
+
* Effect.flatMap((root) => findNode(root, ["missing", "path"])),
|
|
861
|
+
* Effect.catchTag("JsoncNodeNotFoundError", (e) => {
|
|
862
|
+
* console.error(`Not found: [${e.path.join(", ")}] in ${e.rootNodeType}`);
|
|
863
|
+
* return Effect.succeed(undefined);
|
|
864
|
+
* }),
|
|
865
|
+
* );
|
|
866
|
+
* ```
|
|
867
|
+
*
|
|
868
|
+
* @public
|
|
869
|
+
*/
|
|
870
|
+
declare class JsoncNodeNotFoundError extends JsoncNodeNotFoundErrorBase<{
|
|
871
|
+
readonly path: ReadonlyArray<string | number>;
|
|
872
|
+
readonly rootNodeType: string;
|
|
873
|
+
}> {
|
|
874
|
+
get message(): string;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Base class for {@link JsoncModificationError}; not intended to be
|
|
878
|
+
* constructed or caught directly — use `JsoncModificationError` instead.
|
|
879
|
+
*
|
|
880
|
+
* @privateRemarks
|
|
881
|
+
* Uses the same `*Base` pattern as {@link JsoncParseErrorBase} to work
|
|
882
|
+
* around api-extractor's inability to roll up the complex type produced
|
|
883
|
+
* by `Data.TaggedError` into a single `.d.ts` declaration. Tagged `@public`
|
|
884
|
+
* for the same heritage-clause-compatibility reason as `JsoncParseErrorBase`.
|
|
885
|
+
*
|
|
886
|
+
* @public
|
|
887
|
+
*/
|
|
888
|
+
declare const JsoncModificationErrorBase: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
|
|
889
|
+
readonly _tag: "JsoncModificationError";
|
|
890
|
+
} & Readonly<A>;
|
|
891
|
+
/**
|
|
892
|
+
* Error raised when {@link modify} produces invalid edits or encounters
|
|
893
|
+
* an unsupported modification scenario.
|
|
894
|
+
*
|
|
895
|
+
* @remarks
|
|
896
|
+
* Contains the `path` where modification was attempted and a `reason`
|
|
897
|
+
* string explaining why it failed.
|
|
898
|
+
*
|
|
899
|
+
* @see {@link modify} — may fail with this error
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```ts
|
|
903
|
+
* import { Effect } from "effect";
|
|
904
|
+
* import { modify } from "jsonc-effect";
|
|
905
|
+
*
|
|
906
|
+
* const program = modify("{}", ["deep", "path"], 42).pipe(
|
|
907
|
+
* Effect.catchTag("JsoncModificationError", (e) => {
|
|
908
|
+
* console.error(`Failed at [${e.path.join(", ")}]: ${e.reason}`);
|
|
909
|
+
* return Effect.succeed([]);
|
|
910
|
+
* }),
|
|
911
|
+
* );
|
|
912
|
+
* ```
|
|
913
|
+
*
|
|
914
|
+
* @public
|
|
915
|
+
*/
|
|
916
|
+
declare class JsoncModificationError extends JsoncModificationErrorBase<{
|
|
917
|
+
readonly path: ReadonlyArray<string | number>;
|
|
918
|
+
readonly reason: string;
|
|
919
|
+
}> {
|
|
920
|
+
get message(): string;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Union of all JSONC error types, useful for exhaustive error handling
|
|
924
|
+
* with `Effect.catchTags`.
|
|
925
|
+
*
|
|
926
|
+
* @see {@link JsoncParseError}
|
|
927
|
+
* @see {@link JsoncNodeNotFoundError}
|
|
928
|
+
* @see {@link JsoncModificationError}
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
* ```ts
|
|
932
|
+
* import { Effect } from "effect";
|
|
933
|
+
* import type { JsoncError } from "jsonc-effect";
|
|
934
|
+
* import { parse, parseTree, findNode, modify } from "jsonc-effect";
|
|
935
|
+
*
|
|
936
|
+
* const program = parse("{}").pipe(
|
|
937
|
+
* Effect.catchTags({
|
|
938
|
+
* JsoncParseError: (e) => Effect.succeed("parse failed"),
|
|
939
|
+
* JsoncModificationError: (e) => Effect.succeed("modify failed"),
|
|
940
|
+
* JsoncNodeNotFoundError: (e) => Effect.succeed("node not found"),
|
|
941
|
+
* }),
|
|
942
|
+
* );
|
|
943
|
+
* ```
|
|
944
|
+
*
|
|
945
|
+
* @public
|
|
946
|
+
*/
|
|
947
|
+
type JsoncError = JsoncParseError | JsoncNodeNotFoundError | JsoncModificationError;
|
|
948
|
+
//#endregion
|
|
949
|
+
//#region src/equality.d.ts
|
|
950
|
+
/**
|
|
951
|
+
* Compare two JSONC strings for semantic equality.
|
|
952
|
+
*
|
|
953
|
+
* Supports {@link https://effect.website/docs/effect/function#dual | Function.dual}
|
|
954
|
+
* for both data-first and data-last (pipeline) usage.
|
|
955
|
+
*
|
|
956
|
+
* @param self - The first JSONC string.
|
|
957
|
+
* @param that - The second JSONC string.
|
|
958
|
+
*
|
|
959
|
+
* @returns `Effect<boolean, JsoncParseError>` — `true` when both strings parse to
|
|
960
|
+
* semantically equivalent values, `false` otherwise. Fails with
|
|
961
|
+
* {@link JsoncParseError} if either string is malformed.
|
|
962
|
+
*
|
|
963
|
+
* @remarks
|
|
964
|
+
* Both strings are parsed via {@link parse} and then deep-compared. The comparison
|
|
965
|
+
* ignores comments, whitespace, formatting, and object key ordering. Array order
|
|
966
|
+
* IS significant. Uses `Effect.all` internally, so the effect fails on the first
|
|
967
|
+
* parse error encountered.
|
|
968
|
+
*
|
|
969
|
+
* @see {@link equalsValue} — compare a JSONC string against an existing JS value
|
|
970
|
+
* @see {@link parse} — the underlying parser used for both strings
|
|
971
|
+
*
|
|
972
|
+
* @example Data-first comparison
|
|
973
|
+
* ```ts
|
|
974
|
+
* import { Effect } from "effect";
|
|
975
|
+
* import { equals } from "jsonc-effect";
|
|
976
|
+
*
|
|
977
|
+
* const result = Effect.runSync(
|
|
978
|
+
* equals('{ "a": 1, "b": 2 }', '{"b":2,"a":1}')
|
|
979
|
+
* );
|
|
980
|
+
* // result is true
|
|
981
|
+
* ```
|
|
982
|
+
*
|
|
983
|
+
* @example Key-order independence
|
|
984
|
+
* ```ts
|
|
985
|
+
* import { Effect } from "effect";
|
|
986
|
+
* import { equals } from "jsonc-effect";
|
|
987
|
+
*
|
|
988
|
+
* // Object key order does not matter
|
|
989
|
+
* const sameKeys = Effect.runSync(
|
|
990
|
+
* equals('{"z":1,"a":2}', '{"a":2,"z":1}')
|
|
991
|
+
* );
|
|
992
|
+
* // sameKeys is true
|
|
993
|
+
*
|
|
994
|
+
* // Array order DOES matter
|
|
995
|
+
* const differentOrder = Effect.runSync(
|
|
996
|
+
* equals('[1, 2]', '[2, 1]')
|
|
997
|
+
* );
|
|
998
|
+
* // differentOrder is false
|
|
999
|
+
* ```
|
|
1000
|
+
*
|
|
1001
|
+
* @example Error handling
|
|
1002
|
+
* ```ts
|
|
1003
|
+
* import { Effect, Either } from "effect";
|
|
1004
|
+
* import type { JsoncParseError } from "jsonc-effect";
|
|
1005
|
+
* import { equals } from "jsonc-effect";
|
|
1006
|
+
*
|
|
1007
|
+
* const result: Either.Either<boolean, JsoncParseError> = Effect.runSync(
|
|
1008
|
+
* Effect.either(equals('{ invalid }', '{}'))
|
|
1009
|
+
* );
|
|
1010
|
+
* // result is Either.left(JsoncParseError)
|
|
1011
|
+
* ```
|
|
1012
|
+
*
|
|
1013
|
+
* @privateRemarks
|
|
1014
|
+
* Uses a simple recursive `deepEqual` helper rather than Effect's `Equal` module
|
|
1015
|
+
* because the parsed values are plain JS objects and arrays, not Effect data types.
|
|
1016
|
+
*
|
|
1017
|
+
* @public
|
|
1018
|
+
*/
|
|
1019
|
+
declare const equals: {
|
|
1020
|
+
(that: string): (self: string) => Effect.Effect<boolean, JsoncParseError>;
|
|
1021
|
+
(self: string, that: string): Effect.Effect<boolean, JsoncParseError>;
|
|
1022
|
+
};
|
|
1023
|
+
/**
|
|
1024
|
+
* Compare a JSONC string against a JavaScript value for semantic equality.
|
|
1025
|
+
*
|
|
1026
|
+
* Supports {@link https://effect.website/docs/effect/function#dual | Function.dual}
|
|
1027
|
+
* for both data-first and data-last (pipeline) usage.
|
|
1028
|
+
*
|
|
1029
|
+
* @param self - The JSONC string to parse.
|
|
1030
|
+
* @param value - The JavaScript value to compare against.
|
|
1031
|
+
*
|
|
1032
|
+
* @returns `Effect<boolean, JsoncParseError>` — `true` when the parsed JSONC
|
|
1033
|
+
* is semantically equivalent to the provided value, `false` otherwise.
|
|
1034
|
+
* Fails with {@link JsoncParseError} if the string is malformed.
|
|
1035
|
+
*
|
|
1036
|
+
* @remarks
|
|
1037
|
+
* Only the JSONC string is parsed; the JS value is used as-is. This makes
|
|
1038
|
+
* `equalsValue` useful for assertions and testing where the expected value
|
|
1039
|
+
* is already a JS object. The comparison semantics are the same as
|
|
1040
|
+
* {@link equals}: comments, whitespace, formatting, and object key ordering
|
|
1041
|
+
* are ignored, while array order IS significant.
|
|
1042
|
+
*
|
|
1043
|
+
* @see {@link equals} — compare two JSONC strings against each other
|
|
1044
|
+
* @see {@link parse} — the underlying parser
|
|
1045
|
+
*
|
|
1046
|
+
* @example Basic comparison
|
|
1047
|
+
* ```ts
|
|
1048
|
+
* import { Effect } from "effect";
|
|
1049
|
+
* import { equalsValue } from "jsonc-effect";
|
|
1050
|
+
*
|
|
1051
|
+
* const result = Effect.runSync(
|
|
1052
|
+
* equalsValue('{"port": 3000, "host": "localhost"}', { host: "localhost", port: 3000 })
|
|
1053
|
+
* );
|
|
1054
|
+
* // result is true
|
|
1055
|
+
* ```
|
|
1056
|
+
*
|
|
1057
|
+
* @example Pipeline usage for testing
|
|
1058
|
+
* ```ts
|
|
1059
|
+
* import { Effect, pipe } from "effect";
|
|
1060
|
+
* import { equalsValue } from "jsonc-effect";
|
|
1061
|
+
*
|
|
1062
|
+
* const jsonc = '{ "enabled": true, "count": 5 }';
|
|
1063
|
+
* const expected = { enabled: true, count: 5 };
|
|
1064
|
+
*
|
|
1065
|
+
* const result = Effect.runSync(
|
|
1066
|
+
* pipe(jsonc, equalsValue(expected))
|
|
1067
|
+
* );
|
|
1068
|
+
* // result is true
|
|
1069
|
+
* ```
|
|
1070
|
+
*
|
|
1071
|
+
* @public
|
|
1072
|
+
*/
|
|
1073
|
+
declare const equalsValue: {
|
|
1074
|
+
(value: unknown): (self: string) => Effect.Effect<boolean, JsoncParseError>;
|
|
1075
|
+
(self: string, value: unknown): Effect.Effect<boolean, JsoncParseError>;
|
|
1076
|
+
};
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region src/format.d.ts
|
|
1079
|
+
/**
|
|
1080
|
+
* Compute formatting edits for a JSONC document.
|
|
1081
|
+
*
|
|
1082
|
+
* Returns an array of {@link JsoncEdit} objects describing text replacements
|
|
1083
|
+
* that, when applied, produce a well-formatted document. The input text is
|
|
1084
|
+
* never mutated — apply the returned edits with {@link applyEdits}.
|
|
1085
|
+
*
|
|
1086
|
+
* @param text - The JSONC source text to format.
|
|
1087
|
+
* @param range - Optional sub-range to format. When provided, only edits
|
|
1088
|
+
* within the range are returned.
|
|
1089
|
+
* @param options - Partial {@link JsoncFormattingOptions} controlling indent
|
|
1090
|
+
* size, tabs vs. spaces, EOL style, and final-newline insertion.
|
|
1091
|
+
* @returns An `Effect` that succeeds with a read-only array of
|
|
1092
|
+
* {@link JsoncEdit} objects.
|
|
1093
|
+
*
|
|
1094
|
+
* @remarks
|
|
1095
|
+
* This function is non-mutating by design. It computes a minimal set of
|
|
1096
|
+
* whitespace edits; structural changes (inserting or removing properties)
|
|
1097
|
+
* are handled by {@link modify}. The `range` parameter allows formatting a
|
|
1098
|
+
* subset of the document without touching surrounding text.
|
|
1099
|
+
*
|
|
1100
|
+
* @see {@link applyEdits} to apply the returned edits to the source text.
|
|
1101
|
+
* @see {@link formatAndApply} for a one-step format-and-apply convenience.
|
|
1102
|
+
* @see {@link JsoncFormattingOptions} for available formatting controls.
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* ```ts
|
|
1106
|
+
* import { Effect } from "effect";
|
|
1107
|
+
* import type { JsoncEdit } from "jsonc-effect";
|
|
1108
|
+
* import { format, applyEdits } from "jsonc-effect";
|
|
1109
|
+
*
|
|
1110
|
+
* const input = '{"a":1, "b" :2}';
|
|
1111
|
+
* const edits: ReadonlyArray<JsoncEdit> = Effect.runSync(format(input));
|
|
1112
|
+
* const formatted: string = Effect.runSync(applyEdits(input, edits));
|
|
1113
|
+
* ```
|
|
1114
|
+
*
|
|
1115
|
+
* @privateRemarks
|
|
1116
|
+
* Uses {@link createScanner} internally to tokenize the input and compute
|
|
1117
|
+
* whitespace adjustments between consecutive non-trivia tokens.
|
|
1118
|
+
*
|
|
1119
|
+
* @public
|
|
1120
|
+
*/
|
|
1121
|
+
declare const format: (text: string, range?: JsoncRange, options?: Partial<JsoncFormattingOptions>) => Effect.Effect<ReadonlyArray<JsoncEdit>>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Apply an array of text edits to JSONC source text.
|
|
1124
|
+
*
|
|
1125
|
+
* This is a {@link https://effect.website/docs/function-dual | Function.dual}
|
|
1126
|
+
* that supports both data-first and data-last (pipeline) usage.
|
|
1127
|
+
*
|
|
1128
|
+
* @param text - The original JSONC source text.
|
|
1129
|
+
* @param edits - A read-only array of {@link JsoncEdit} objects, typically
|
|
1130
|
+
* produced by {@link format} or {@link modify}.
|
|
1131
|
+
* @returns An `Effect` that succeeds with the edited string.
|
|
1132
|
+
*
|
|
1133
|
+
* @remarks
|
|
1134
|
+
* Edits are sorted in reverse offset order before application so that
|
|
1135
|
+
* earlier edits do not shift the offsets of later ones. The original `edits`
|
|
1136
|
+
* array is not mutated.
|
|
1137
|
+
*
|
|
1138
|
+
* @see {@link format} to compute formatting edits.
|
|
1139
|
+
* @see {@link modify} to compute structural edits (insert, replace, remove).
|
|
1140
|
+
*
|
|
1141
|
+
* @example Data-first usage
|
|
1142
|
+
* ```ts
|
|
1143
|
+
* import { Effect } from "effect";
|
|
1144
|
+
* import { format, applyEdits } from "jsonc-effect";
|
|
1145
|
+
*
|
|
1146
|
+
* const input = '{"a":1}';
|
|
1147
|
+
* const edits = Effect.runSync(format(input));
|
|
1148
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
1149
|
+
* ```
|
|
1150
|
+
*
|
|
1151
|
+
* @example Pipeline with modify
|
|
1152
|
+
* ```ts
|
|
1153
|
+
* import { Effect, pipe } from "effect";
|
|
1154
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
1155
|
+
*
|
|
1156
|
+
* const input = '{ "a": 1 }';
|
|
1157
|
+
* const result = pipe(
|
|
1158
|
+
* input,
|
|
1159
|
+
* modify(["a"], 42),
|
|
1160
|
+
* Effect.flatMap((edits) => applyEdits(input, edits)),
|
|
1161
|
+
* Effect.runSync,
|
|
1162
|
+
* );
|
|
1163
|
+
* ```
|
|
1164
|
+
*
|
|
1165
|
+
* @public
|
|
1166
|
+
*/
|
|
1167
|
+
declare const applyEdits: {
|
|
1168
|
+
(edits: ReadonlyArray<JsoncEdit>): (text: string) => Effect.Effect<string>;
|
|
1169
|
+
(text: string, edits: ReadonlyArray<JsoncEdit>): Effect.Effect<string>;
|
|
1170
|
+
};
|
|
1171
|
+
/**
|
|
1172
|
+
* Format a JSONC document in one step by computing edits and immediately
|
|
1173
|
+
* applying them.
|
|
1174
|
+
*
|
|
1175
|
+
* This is a convenience that combines {@link format} and {@link applyEdits}
|
|
1176
|
+
* into a single call.
|
|
1177
|
+
*
|
|
1178
|
+
* @param text - The JSONC source text to format.
|
|
1179
|
+
* @param range - Optional sub-range to restrict formatting to.
|
|
1180
|
+
* @param options - Partial {@link JsoncFormattingOptions} controlling indent
|
|
1181
|
+
* size, tabs vs. spaces, EOL style, and final-newline insertion.
|
|
1182
|
+
* @returns An `Effect` that succeeds with the fully formatted string.
|
|
1183
|
+
*
|
|
1184
|
+
* @see {@link format} to obtain the edits without applying them.
|
|
1185
|
+
* @see {@link applyEdits} to apply edits separately.
|
|
1186
|
+
*
|
|
1187
|
+
* @example
|
|
1188
|
+
* ```ts
|
|
1189
|
+
* import { Effect } from "effect";
|
|
1190
|
+
* import { formatAndApply } from "jsonc-effect";
|
|
1191
|
+
*
|
|
1192
|
+
* const input = '{"a":1, "b" :2}';
|
|
1193
|
+
* const formatted: string = Effect.runSync(formatAndApply(input));
|
|
1194
|
+
* ```
|
|
1195
|
+
*
|
|
1196
|
+
* @public
|
|
1197
|
+
*/
|
|
1198
|
+
declare const formatAndApply: (text: string, range?: JsoncRange, options?: Partial<JsoncFormattingOptions>) => Effect.Effect<string>;
|
|
1199
|
+
/**
|
|
1200
|
+
* Compute edits to insert, replace, or remove a value at a JSON path.
|
|
1201
|
+
*
|
|
1202
|
+
* This is a {@link https://effect.website/docs/function-dual | Function.dual}
|
|
1203
|
+
* that supports both data-first and data-last (pipeline) usage.
|
|
1204
|
+
*
|
|
1205
|
+
* @param text - The JSONC source text to modify.
|
|
1206
|
+
* @param path - A {@link (JsoncPath:type)} (array of string keys and numeric indices)
|
|
1207
|
+
* identifying the target location in the JSON structure.
|
|
1208
|
+
* @param value - The value to set. Pass `undefined` to remove the
|
|
1209
|
+
* property or array element at the given path.
|
|
1210
|
+
* @param options - Optional object with `formattingOptions` controlling
|
|
1211
|
+
* indent size, tabs vs. spaces, and EOL style for generated text.
|
|
1212
|
+
* @returns An `Effect` that succeeds with a read-only array of
|
|
1213
|
+
* {@link JsoncEdit} objects, or fails with a
|
|
1214
|
+
* {@link JsoncModificationError} if the path cannot be navigated.
|
|
1215
|
+
*
|
|
1216
|
+
* @remarks
|
|
1217
|
+
* Setting `value` to `undefined` removes the targeted property or element,
|
|
1218
|
+
* including its surrounding comma. When inserting a new property into an
|
|
1219
|
+
* object, it is appended after the last existing property.
|
|
1220
|
+
*
|
|
1221
|
+
* @see {@link applyEdits} to apply the returned edits to the source text.
|
|
1222
|
+
* @see {@link JsoncModificationError} for the error type on navigation failure.
|
|
1223
|
+
*
|
|
1224
|
+
* @example Update an existing property
|
|
1225
|
+
* ```ts
|
|
1226
|
+
* import { Effect } from "effect";
|
|
1227
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
1228
|
+
*
|
|
1229
|
+
* const input = '{ "a": 1 }';
|
|
1230
|
+
* const edits = Effect.runSync(modify(input, ["a"], 2));
|
|
1231
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
1232
|
+
* ```
|
|
1233
|
+
*
|
|
1234
|
+
* @example Insert a new property
|
|
1235
|
+
* ```ts
|
|
1236
|
+
* import { Effect } from "effect";
|
|
1237
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
1238
|
+
*
|
|
1239
|
+
* const input = '{ "a": 1 }';
|
|
1240
|
+
* const edits = Effect.runSync(modify(input, ["b"], "hello"));
|
|
1241
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
1242
|
+
* ```
|
|
1243
|
+
*
|
|
1244
|
+
* @example Remove a property
|
|
1245
|
+
* ```ts
|
|
1246
|
+
* import { Effect } from "effect";
|
|
1247
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
1248
|
+
*
|
|
1249
|
+
* const input = '{ "a": 1, "b": 2 }';
|
|
1250
|
+
* const edits = Effect.runSync(modify(input, ["a"], undefined));
|
|
1251
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
1252
|
+
* ```
|
|
1253
|
+
*
|
|
1254
|
+
* @example Pipeline (data-last) usage
|
|
1255
|
+
* ```ts
|
|
1256
|
+
* import { Effect, pipe } from "effect";
|
|
1257
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
1258
|
+
*
|
|
1259
|
+
* const input = '{ "a": 1 }';
|
|
1260
|
+
* const result = pipe(
|
|
1261
|
+
* input,
|
|
1262
|
+
* modify(["a"], 42),
|
|
1263
|
+
* Effect.flatMap((edits) => applyEdits(input, edits)),
|
|
1264
|
+
* Effect.runSync,
|
|
1265
|
+
* );
|
|
1266
|
+
* ```
|
|
1267
|
+
*
|
|
1268
|
+
* @privateRemarks
|
|
1269
|
+
* Uses its own scanner-based navigation to locate the target path rather
|
|
1270
|
+
* than building a full AST via `parseTree`. This keeps the implementation
|
|
1271
|
+
* lightweight and avoids an intermediate allocation.
|
|
1272
|
+
*
|
|
1273
|
+
* @public
|
|
1274
|
+
*/
|
|
1275
|
+
declare const modify: {
|
|
1276
|
+
(path: JsoncPath, value: unknown, options?: {
|
|
1277
|
+
formattingOptions?: Partial<JsoncFormattingOptions>;
|
|
1278
|
+
}): (text: string) => Effect.Effect<ReadonlyArray<JsoncEdit>, JsoncModificationError>;
|
|
1279
|
+
(text: string, path: JsoncPath, value: unknown, options?: {
|
|
1280
|
+
formattingOptions?: Partial<JsoncFormattingOptions>;
|
|
1281
|
+
}): Effect.Effect<ReadonlyArray<JsoncEdit>, JsoncModificationError>;
|
|
1282
|
+
};
|
|
1283
|
+
//#endregion
|
|
1284
|
+
//#region src/parse.d.ts
|
|
1285
|
+
/**
|
|
1286
|
+
* Parse a JSONC string into a JavaScript value.
|
|
1287
|
+
*
|
|
1288
|
+
* @param text - JSONC string to parse
|
|
1289
|
+
* @param options - Optional {@link JsoncParseOptions} controlling comment and
|
|
1290
|
+
* trailing-comma handling.
|
|
1291
|
+
* @returns `Effect<unknown, JsoncParseError>` — succeeds with the parsed value
|
|
1292
|
+
* or fails with a {@link JsoncParseError} containing every error encountered.
|
|
1293
|
+
*
|
|
1294
|
+
* @remarks
|
|
1295
|
+
* The return type is `unknown` (not `any`) so consumers are forced to narrow
|
|
1296
|
+
* the result, which is safer in Effect pipelines. By default
|
|
1297
|
+
* `allowTrailingComma` is `true`, matching common JSONC conventions used in
|
|
1298
|
+
* VS Code settings and `tsconfig.json`.
|
|
1299
|
+
*
|
|
1300
|
+
* @see {@link parseTree} — parse into an AST instead of a plain value
|
|
1301
|
+
* @see {@link JsoncParseOptions} — available parse options
|
|
1302
|
+
* @see {@link JsoncParseError} — the tagged error type on the failure channel
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* Basic parsing:
|
|
1306
|
+
* ```ts
|
|
1307
|
+
* import { Effect } from "effect";
|
|
1308
|
+
* import { parse } from "jsonc-effect";
|
|
1309
|
+
*
|
|
1310
|
+
* const value = Effect.runSync(parse('{ "key": 42 }'));
|
|
1311
|
+
* console.log(value); // { key: 42 }
|
|
1312
|
+
* ```
|
|
1313
|
+
*
|
|
1314
|
+
* @example
|
|
1315
|
+
* Parsing with options:
|
|
1316
|
+
* ```ts
|
|
1317
|
+
* import { Effect } from "effect";
|
|
1318
|
+
* import { parse } from "jsonc-effect";
|
|
1319
|
+
*
|
|
1320
|
+
* const value = Effect.runSync(
|
|
1321
|
+
* parse('{ "key": 42 }', { disallowComments: true }),
|
|
1322
|
+
* );
|
|
1323
|
+
* ```
|
|
1324
|
+
*
|
|
1325
|
+
* @example
|
|
1326
|
+
* Error handling with `catchTag`:
|
|
1327
|
+
* ```ts
|
|
1328
|
+
* import { Effect } from "effect";
|
|
1329
|
+
* import { parse } from "jsonc-effect";
|
|
1330
|
+
*
|
|
1331
|
+
* const program = parse("{ bad }").pipe(
|
|
1332
|
+
* Effect.catchTag("JsoncParseError", (err) =>
|
|
1333
|
+
* Effect.succeed({ fallback: true, errors: err.errors }),
|
|
1334
|
+
* ),
|
|
1335
|
+
* );
|
|
1336
|
+
*
|
|
1337
|
+
* const result = Effect.runSync(program);
|
|
1338
|
+
* console.log(result);
|
|
1339
|
+
* ```
|
|
1340
|
+
*
|
|
1341
|
+
* @example
|
|
1342
|
+
* Using `Effect.gen`:
|
|
1343
|
+
* ```ts
|
|
1344
|
+
* import { Effect } from "effect";
|
|
1345
|
+
* import { parse } from "jsonc-effect";
|
|
1346
|
+
*
|
|
1347
|
+
* const program = Effect.gen(function* () {
|
|
1348
|
+
* const config = yield* parse('{ "port": 3000 }');
|
|
1349
|
+
* return config;
|
|
1350
|
+
* });
|
|
1351
|
+
*
|
|
1352
|
+
* const result = Effect.runSync(program);
|
|
1353
|
+
* console.log(result); // { port: 3000 }
|
|
1354
|
+
* ```
|
|
1355
|
+
*
|
|
1356
|
+
* @privateRemarks
|
|
1357
|
+
* Uses {@link createScanner} internally with a recursive descent parser.
|
|
1358
|
+
* The scanner is created with `ignoreTrivia = false` so the parser can
|
|
1359
|
+
* report comment-related errors when `disallowComments` is set.
|
|
1360
|
+
*
|
|
1361
|
+
* @public
|
|
1362
|
+
*/
|
|
1363
|
+
declare const parse: {
|
|
1364
|
+
(text: string): Effect.Effect<unknown, JsoncParseError>;
|
|
1365
|
+
(text: string, options: Partial<JsoncParseOptions>): Effect.Effect<unknown, JsoncParseError>;
|
|
1366
|
+
};
|
|
1367
|
+
/**
|
|
1368
|
+
* Parse a JSONC string into an immutable AST.
|
|
1369
|
+
*
|
|
1370
|
+
* @param text - JSONC string to parse
|
|
1371
|
+
* @param options - Optional {@link JsoncParseOptions} controlling comment and
|
|
1372
|
+
* trailing-comma handling.
|
|
1373
|
+
* @returns `Effect<Option<JsoncNode>, JsoncParseError>` — succeeds with
|
|
1374
|
+
* `Option.some(root)` for non-empty documents or `Option.none()` when the
|
|
1375
|
+
* input is empty (and `allowEmptyContent` is set).
|
|
1376
|
+
*
|
|
1377
|
+
* @remarks
|
|
1378
|
+
* The returned AST is immutable and does **not** contain parent pointers, which
|
|
1379
|
+
* keeps nodes safe to share across fibers. Use the AST navigation helpers
|
|
1380
|
+
* ({@link findNode}, {@link getNodeValue}) to traverse and extract values from
|
|
1381
|
+
* the tree.
|
|
1382
|
+
*
|
|
1383
|
+
* `Option.none()` is returned only when the document contains no value tokens
|
|
1384
|
+
* and `allowEmptyContent` is enabled; otherwise an empty document produces a
|
|
1385
|
+
* {@link JsoncParseError}.
|
|
1386
|
+
*
|
|
1387
|
+
* @see {@link parse} — parse into a plain JavaScript value instead of an AST
|
|
1388
|
+
* @see {@link findNode} — locate a node by JSON path segments
|
|
1389
|
+
* @see {@link getNodeValue} — extract the JavaScript value from a subtree
|
|
1390
|
+
* @see {@link JsoncNode} — the AST node type
|
|
1391
|
+
*
|
|
1392
|
+
* @example
|
|
1393
|
+
* Parsing a JSONC string and navigating the tree:
|
|
1394
|
+
* ```ts
|
|
1395
|
+
* import { Effect, Option } from "effect";
|
|
1396
|
+
* import { parseTree } from "jsonc-effect";
|
|
1397
|
+
*
|
|
1398
|
+
* const program = Effect.gen(function* () {
|
|
1399
|
+
* const maybeRoot = yield* parseTree('{ "a": [1, 2, 3] }');
|
|
1400
|
+
* if (Option.isSome(maybeRoot)) {
|
|
1401
|
+
* const root = maybeRoot.value;
|
|
1402
|
+
* console.log(root.type); // "object"
|
|
1403
|
+
* console.log(root.children?.length); // 1
|
|
1404
|
+
* }
|
|
1405
|
+
* });
|
|
1406
|
+
*
|
|
1407
|
+
* Effect.runSync(program);
|
|
1408
|
+
* ```
|
|
1409
|
+
*
|
|
1410
|
+
* @privateRemarks
|
|
1411
|
+
* Internally the parser builds a mutable tree using `MutableJsoncNode` and
|
|
1412
|
+
* casts to the readonly `JsoncNode` on output.
|
|
1413
|
+
*
|
|
1414
|
+
* @public
|
|
1415
|
+
*/
|
|
1416
|
+
declare const parseTree: {
|
|
1417
|
+
(text: string): Effect.Effect<Option.Option<JsoncNode>, JsoncParseError>;
|
|
1418
|
+
(text: string, options: Partial<JsoncParseOptions>): Effect.Effect<Option.Option<JsoncNode>, JsoncParseError>;
|
|
1419
|
+
};
|
|
1420
|
+
/**
|
|
1421
|
+
* Remove all comments from JSONC text, producing valid JSON.
|
|
1422
|
+
*
|
|
1423
|
+
* @param text - JSONC string to strip comments from
|
|
1424
|
+
* @param replaceCh - Optional single character used to replace each character of
|
|
1425
|
+
* every comment. When provided, the output has the **same length** as the
|
|
1426
|
+
* input so that all offsets are preserved (line breaks inside block comments
|
|
1427
|
+
* are kept as-is).
|
|
1428
|
+
* @returns `Effect<string>` — the text with all comments removed (or replaced).
|
|
1429
|
+
*
|
|
1430
|
+
* @remarks
|
|
1431
|
+
* When `replaceCh` is omitted the comment text is simply deleted, which means
|
|
1432
|
+
* character offsets in the output no longer match the original document. Pass a
|
|
1433
|
+
* space (`" "`) as `replaceCh` to keep offsets stable — this is useful when you
|
|
1434
|
+
* need to correlate positions between the original JSONC and the stripped JSON.
|
|
1435
|
+
*
|
|
1436
|
+
* @see {@link parse} — parse JSONC directly without a stripping step
|
|
1437
|
+
*
|
|
1438
|
+
* @example
|
|
1439
|
+
* Basic comment stripping:
|
|
1440
|
+
* ```ts
|
|
1441
|
+
* import { Effect } from "effect";
|
|
1442
|
+
* import { stripComments } from "jsonc-effect";
|
|
1443
|
+
*
|
|
1444
|
+
* const json = Effect.runSync(
|
|
1445
|
+
* stripComments('{ "a": 1 // comment\n}'),
|
|
1446
|
+
* );
|
|
1447
|
+
* console.log(json); // '{ "a": 1 \n}'
|
|
1448
|
+
* ```
|
|
1449
|
+
*
|
|
1450
|
+
* @example
|
|
1451
|
+
* Using a replacement character to preserve offsets:
|
|
1452
|
+
* ```ts
|
|
1453
|
+
* import { Effect } from "effect";
|
|
1454
|
+
* import { stripComments } from "jsonc-effect";
|
|
1455
|
+
*
|
|
1456
|
+
* const json = Effect.runSync(
|
|
1457
|
+
* stripComments('{ "a": 1 // comment\n}', " "),
|
|
1458
|
+
* );
|
|
1459
|
+
* console.log(json.length === '{ "a": 1 // comment\n}'.length); // true
|
|
1460
|
+
* ```
|
|
1461
|
+
*
|
|
1462
|
+
* @public
|
|
1463
|
+
*/
|
|
1464
|
+
declare const stripComments: {
|
|
1465
|
+
(text: string): Effect.Effect<string>;
|
|
1466
|
+
(text: string, replaceCh: string): Effect.Effect<string>;
|
|
1467
|
+
};
|
|
1468
|
+
//#endregion
|
|
1469
|
+
//#region src/scanner.d.ts
|
|
1470
|
+
/**
|
|
1471
|
+
* Stateful cursor over JSONC text that produces tokens on demand.
|
|
1472
|
+
*
|
|
1473
|
+
* @remarks
|
|
1474
|
+
* The scanner is the lowest-level API in jsonc-effect. It exposes an
|
|
1475
|
+
* imperative scan-loop pattern: call {@link JsoncScanner.scan | scan()} in a
|
|
1476
|
+
* loop until it returns `"EOF"`, inspecting the current token with the
|
|
1477
|
+
* getter methods after each call.
|
|
1478
|
+
*
|
|
1479
|
+
* Unlike the rest of the library, the scanner is **mutable** — each call to
|
|
1480
|
+
* `scan()` advances an internal cursor and updates all token-related state.
|
|
1481
|
+
*
|
|
1482
|
+
* @see {@link createScanner} — factory function that produces a `JsoncScanner`
|
|
1483
|
+
* @see {@link (JsoncSyntaxKind:type)} — string literal union of all token types
|
|
1484
|
+
*
|
|
1485
|
+
* @example
|
|
1486
|
+
* Collecting all structural tokens from a JSONC string:
|
|
1487
|
+
* ```ts
|
|
1488
|
+
* import type { JsoncSyntaxKind } from "jsonc-effect";
|
|
1489
|
+
* import { createScanner } from "jsonc-effect";
|
|
1490
|
+
*
|
|
1491
|
+
* const scanner = createScanner('{ "key": 42 }', true);
|
|
1492
|
+
* const tokens: JsoncSyntaxKind[] = [];
|
|
1493
|
+
* let kind: JsoncSyntaxKind;
|
|
1494
|
+
* do {
|
|
1495
|
+
* kind = scanner.scan();
|
|
1496
|
+
* tokens.push(kind);
|
|
1497
|
+
* } while (kind !== "EOF");
|
|
1498
|
+
* console.log(tokens);
|
|
1499
|
+
* // ["OpenBrace", "String", "Colon", "Number", "CloseBrace", "EOF"]
|
|
1500
|
+
* ```
|
|
1501
|
+
*
|
|
1502
|
+
* @privateRemarks
|
|
1503
|
+
* The scanner is the only mutable/stateful part of the library. All other
|
|
1504
|
+
* APIs are pure Effect pipelines built on top of it.
|
|
1505
|
+
*
|
|
1506
|
+
* @public
|
|
1507
|
+
*/
|
|
1508
|
+
interface JsoncScanner {
|
|
1509
|
+
/** Advance the cursor to the next token and return its {@link (JsoncSyntaxKind:type)}. */
|
|
1510
|
+
scan(): JsoncSyntaxKind;
|
|
1511
|
+
/** Return the {@link (JsoncSyntaxKind:type)} of the current token without advancing. */
|
|
1512
|
+
getToken(): JsoncSyntaxKind;
|
|
1513
|
+
/** Return the string value of the current token (e.g. the unescaped content of a string literal). */
|
|
1514
|
+
getTokenValue(): string;
|
|
1515
|
+
/** Return the zero-based character offset where the current token begins. */
|
|
1516
|
+
getTokenOffset(): number;
|
|
1517
|
+
/** Return the character length of the current token. */
|
|
1518
|
+
getTokenLength(): number;
|
|
1519
|
+
/** Return the zero-based line number where the current token starts. */
|
|
1520
|
+
getTokenStartLine(): number;
|
|
1521
|
+
/** Return the zero-based character position within the line where the current token starts. */
|
|
1522
|
+
getTokenStartCharacter(): number;
|
|
1523
|
+
/** Return the {@link (JsoncScanError:type)} for the current token, or `"None"` if no error. */
|
|
1524
|
+
getTokenError(): JsoncScanError;
|
|
1525
|
+
/** Return the current cursor position (byte offset into the source text). */
|
|
1526
|
+
getPosition(): number;
|
|
1527
|
+
/** Set the cursor position, resetting the current token state. */
|
|
1528
|
+
setPosition(pos: number): void;
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Create a stateful {@link JsoncScanner} for the given JSONC string.
|
|
1532
|
+
*
|
|
1533
|
+
* @param text - JSONC string to tokenize
|
|
1534
|
+
* @param ignoreTrivia - If `true`, the scanner automatically skips whitespace,
|
|
1535
|
+
* line-break, and comment tokens so that only structural tokens are returned
|
|
1536
|
+
* (default: `false`).
|
|
1537
|
+
* @returns A stateful {@link JsoncScanner} positioned before the first token.
|
|
1538
|
+
*
|
|
1539
|
+
* @remarks
|
|
1540
|
+
* When `ignoreTrivia` is `true` the scanner is suitable for building parsers
|
|
1541
|
+
* that only care about structural tokens (`OpenBrace`, `String`, `Number`,
|
|
1542
|
+
* etc.). Set it to `false` (the default) when you need to preserve comments
|
|
1543
|
+
* or whitespace — for example in a formatter or a comment-stripping pass.
|
|
1544
|
+
*
|
|
1545
|
+
* @see {@link JsoncScanner} — the interface returned by this factory
|
|
1546
|
+
* @see {@link parse} — higher-level API that uses a scanner internally
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* Tokenizing a JSONC string and printing each token:
|
|
1550
|
+
* ```ts
|
|
1551
|
+
* import type { JsoncSyntaxKind } from "jsonc-effect";
|
|
1552
|
+
* import { createScanner } from "jsonc-effect";
|
|
1553
|
+
*
|
|
1554
|
+
* const scanner = createScanner('{ "name": "jsonc" }', true);
|
|
1555
|
+
* let kind: JsoncSyntaxKind;
|
|
1556
|
+
* do {
|
|
1557
|
+
* kind = scanner.scan();
|
|
1558
|
+
* console.log(kind, scanner.getTokenValue());
|
|
1559
|
+
* } while (kind !== "EOF");
|
|
1560
|
+
* ```
|
|
1561
|
+
*
|
|
1562
|
+
* @privateRemarks
|
|
1563
|
+
* Ported from Microsoft's jsonc-parser (MIT), adapted to use string literal
|
|
1564
|
+
* token types instead of numeric enums.
|
|
1565
|
+
*
|
|
1566
|
+
* @public
|
|
1567
|
+
*/
|
|
1568
|
+
declare const createScanner: (text: string, ignoreTrivia?: boolean) => JsoncScanner;
|
|
1569
|
+
//#endregion
|
|
1570
|
+
//#region src/schema-integration.d.ts
|
|
1571
|
+
/**
|
|
1572
|
+
* Pre-built `Schema<unknown, string>` that decodes a JSONC string into an
|
|
1573
|
+
* unknown JavaScript value using default parse options.
|
|
1574
|
+
*
|
|
1575
|
+
* This is the first stage of a typical parsing pipeline:
|
|
1576
|
+
*
|
|
1577
|
+
* ```
|
|
1578
|
+
* JSONC string --JsoncFromString--> unknown --YourSchema--> A
|
|
1579
|
+
* ```
|
|
1580
|
+
*
|
|
1581
|
+
* @remarks
|
|
1582
|
+
* Default parse options are used (comments allowed, trailing commas
|
|
1583
|
+
* allowed). The encode direction uses `JSON.stringify` with 2-space
|
|
1584
|
+
* indentation, which means comments present in the original JSONC
|
|
1585
|
+
* input are not preserved during a round-trip encode.
|
|
1586
|
+
*
|
|
1587
|
+
* For custom parse options, use {@link makeJsoncFromString} instead.
|
|
1588
|
+
*
|
|
1589
|
+
* @see {@link makeJsoncFromString} to create a schema with custom options.
|
|
1590
|
+
* @see {@link makeJsoncSchema} to compose JSONC parsing with a domain schema
|
|
1591
|
+
* in one step.
|
|
1592
|
+
*
|
|
1593
|
+
* @example Decode a JSONC string
|
|
1594
|
+
* ```ts
|
|
1595
|
+
* import { Schema } from "effect";
|
|
1596
|
+
* import { JsoncFromString } from "jsonc-effect";
|
|
1597
|
+
*
|
|
1598
|
+
* const value: unknown = Schema.decodeUnknownSync(JsoncFromString)(
|
|
1599
|
+
* '{ "key": 42 // comment\n}',
|
|
1600
|
+
* );
|
|
1601
|
+
* ```
|
|
1602
|
+
*
|
|
1603
|
+
* @example Compose with a domain schema
|
|
1604
|
+
* ```ts
|
|
1605
|
+
* import { Schema } from "effect";
|
|
1606
|
+
* import { JsoncFromString } from "jsonc-effect";
|
|
1607
|
+
*
|
|
1608
|
+
* const MyConfig = Schema.Struct({
|
|
1609
|
+
* name: Schema.String,
|
|
1610
|
+
* version: Schema.Number,
|
|
1611
|
+
* });
|
|
1612
|
+
*
|
|
1613
|
+
* const MyConfigFromJsonc = Schema.compose(JsoncFromString, MyConfig);
|
|
1614
|
+
* const config = Schema.decodeUnknownSync(MyConfigFromJsonc)(
|
|
1615
|
+
* '{ "name": "app", "version": 1 }',
|
|
1616
|
+
* );
|
|
1617
|
+
* ```
|
|
1618
|
+
*
|
|
1619
|
+
* @public
|
|
1620
|
+
*/
|
|
1621
|
+
declare const JsoncFromString: Schema.Schema<unknown, string>;
|
|
1622
|
+
/**
|
|
1623
|
+
* Create a `Schema<unknown, string>` that decodes JSONC with custom
|
|
1624
|
+
* parse options.
|
|
1625
|
+
*
|
|
1626
|
+
* @param options - Partial {@link JsoncParseOptions} controlling comment
|
|
1627
|
+
* handling and trailing-comma tolerance.
|
|
1628
|
+
* @returns A `Schema<unknown, string>` configured with the given options.
|
|
1629
|
+
*
|
|
1630
|
+
* @remarks
|
|
1631
|
+
* The encode direction uses `JSON.stringify` with 2-space indentation,
|
|
1632
|
+
* which produces standard JSON. Comments present in the original JSONC
|
|
1633
|
+
* input are not preserved during a round-trip encode.
|
|
1634
|
+
*
|
|
1635
|
+
* @see {@link JsoncFromString} for a zero-config default instance.
|
|
1636
|
+
* @see {@link makeJsoncSchema} to compose JSONC parsing with a domain
|
|
1637
|
+
* schema in one step.
|
|
1638
|
+
*
|
|
1639
|
+
* @example Strict mode (no comments, no trailing commas)
|
|
1640
|
+
* ```ts
|
|
1641
|
+
* import { Schema } from "effect";
|
|
1642
|
+
* import { makeJsoncFromString } from "jsonc-effect";
|
|
1643
|
+
*
|
|
1644
|
+
* const StrictJsoncFromString = makeJsoncFromString({
|
|
1645
|
+
* disallowComments: true,
|
|
1646
|
+
* allowTrailingComma: false,
|
|
1647
|
+
* });
|
|
1648
|
+
*
|
|
1649
|
+
* const value: unknown = Schema.decodeUnknownSync(StrictJsoncFromString)(
|
|
1650
|
+
* '{ "key": 42 }',
|
|
1651
|
+
* );
|
|
1652
|
+
* ```
|
|
1653
|
+
*
|
|
1654
|
+
* @privateRemarks
|
|
1655
|
+
* Internally delegates to `Schema.transformOrFail` to wire up the decode
|
|
1656
|
+
* and encode directions.
|
|
1657
|
+
*
|
|
1658
|
+
* @public
|
|
1659
|
+
*/
|
|
1660
|
+
declare function makeJsoncFromString(options?: Partial<JsoncParseOptions>): Schema.Schema<unknown, string>;
|
|
1661
|
+
/**
|
|
1662
|
+
* Create a composed `Schema<A, string>` that parses a JSONC string and
|
|
1663
|
+
* validates the result against a target domain schema in one step.
|
|
1664
|
+
*
|
|
1665
|
+
* @param targetSchema - The domain schema to validate the parsed value
|
|
1666
|
+
* against. Its input type `I` must be assignable from `unknown`.
|
|
1667
|
+
* @param options - Optional partial {@link JsoncParseOptions} forwarded to
|
|
1668
|
+
* the underlying JSONC parser.
|
|
1669
|
+
* @returns A `Schema<A, string>` that goes directly from a JSONC string
|
|
1670
|
+
* to a fully validated domain value of type `A`.
|
|
1671
|
+
*
|
|
1672
|
+
* @remarks
|
|
1673
|
+
* Internally composes two schema stages:
|
|
1674
|
+
*
|
|
1675
|
+
* 1. JSONC string to `unknown` (via {@link makeJsoncFromString}).
|
|
1676
|
+
* 2. `unknown` to `A` (via the provided `targetSchema`).
|
|
1677
|
+
*
|
|
1678
|
+
* This avoids the need to manually call `Schema.compose`.
|
|
1679
|
+
*
|
|
1680
|
+
* @see {@link makeJsoncFromString} for the first stage of the pipeline.
|
|
1681
|
+
*
|
|
1682
|
+
* @example Typed configuration from JSONC
|
|
1683
|
+
* ```ts
|
|
1684
|
+
* import { Schema } from "effect";
|
|
1685
|
+
* import { makeJsoncSchema } from "jsonc-effect";
|
|
1686
|
+
*
|
|
1687
|
+
* const MyConfig = Schema.Struct({
|
|
1688
|
+
* name: Schema.String,
|
|
1689
|
+
* version: Schema.Number,
|
|
1690
|
+
* });
|
|
1691
|
+
*
|
|
1692
|
+
* const MyConfigFromJsonc = makeJsoncSchema(MyConfig);
|
|
1693
|
+
* const config = Schema.decodeUnknownSync(MyConfigFromJsonc)(
|
|
1694
|
+
* '{ "name": "app", "version": 1 }',
|
|
1695
|
+
* );
|
|
1696
|
+
* ```
|
|
1697
|
+
*
|
|
1698
|
+
* @example With custom parse options
|
|
1699
|
+
* ```ts
|
|
1700
|
+
* import { Schema } from "effect";
|
|
1701
|
+
* import { makeJsoncSchema } from "jsonc-effect";
|
|
1702
|
+
*
|
|
1703
|
+
* const MyConfig = Schema.Struct({ debug: Schema.Boolean });
|
|
1704
|
+
*
|
|
1705
|
+
* const StrictConfig = makeJsoncSchema(MyConfig, {
|
|
1706
|
+
* disallowComments: true,
|
|
1707
|
+
* allowTrailingComma: false,
|
|
1708
|
+
* });
|
|
1709
|
+
*
|
|
1710
|
+
* const config = Schema.decodeUnknownSync(StrictConfig)(
|
|
1711
|
+
* '{ "debug": true }',
|
|
1712
|
+
* );
|
|
1713
|
+
* ```
|
|
1714
|
+
*
|
|
1715
|
+
* @privateRemarks
|
|
1716
|
+
* Uses `Schema.compose` internally to chain the JSONC-from-string schema
|
|
1717
|
+
* with the provided target schema.
|
|
1718
|
+
*
|
|
1719
|
+
* @public
|
|
1720
|
+
*/
|
|
1721
|
+
declare const makeJsoncSchema: <A, I>(targetSchema: Schema.Schema<A, I>, options?: Partial<JsoncParseOptions>) => Schema.Schema<A, string>;
|
|
1722
|
+
//#endregion
|
|
1723
|
+
//#region src/visitor.d.ts
|
|
1724
|
+
/**
|
|
1725
|
+
* Discriminated union of JSONC visitor events.
|
|
1726
|
+
*
|
|
1727
|
+
* Each variant carries an `_tag` discriminant, an `offset`, and a `length`
|
|
1728
|
+
* describing where the event occurred in the source text. Some variants
|
|
1729
|
+
* include additional fields such as `path`, `value`, or `property`.
|
|
1730
|
+
*
|
|
1731
|
+
* @remarks
|
|
1732
|
+
* The nine event types are:
|
|
1733
|
+
*
|
|
1734
|
+
* - **ObjectBegin** — opening `{` of an object, includes `path`.
|
|
1735
|
+
* - **ObjectEnd** — closing `}` of an object.
|
|
1736
|
+
* - **ObjectProperty** — a property key, includes `property` and `path`.
|
|
1737
|
+
* - **ArrayBegin** — opening `[` of an array, includes `path`.
|
|
1738
|
+
* - **ArrayEnd** — closing `]` of an array.
|
|
1739
|
+
* - **LiteralValue** — a string, number, boolean, or null literal,
|
|
1740
|
+
* includes `value` and `path`.
|
|
1741
|
+
* - **Separator** — a `,` or `:` character.
|
|
1742
|
+
* - **Comment** — a line or block comment.
|
|
1743
|
+
* - **Error** — a parse error, includes a {@link (JsoncParseErrorCode:type)} `code`.
|
|
1744
|
+
*
|
|
1745
|
+
* Use the `_tag` field to discriminate between variants in `switch`
|
|
1746
|
+
* statements or {@link https://effect.website/docs/stream/operations | Stream}
|
|
1747
|
+
* filter predicates.
|
|
1748
|
+
*
|
|
1749
|
+
* @see {@link visit} to produce a stream of these events.
|
|
1750
|
+
* @see {@link visitCollect} to collect matching events in one step.
|
|
1751
|
+
*
|
|
1752
|
+
* @example Filtering events by tag
|
|
1753
|
+
* ```ts
|
|
1754
|
+
* import { Chunk, Effect, Stream } from "effect";
|
|
1755
|
+
* import type { JsoncVisitorEvent } from "jsonc-effect";
|
|
1756
|
+
* import { visit } from "jsonc-effect";
|
|
1757
|
+
*
|
|
1758
|
+
* const literals = Effect.runSync(
|
|
1759
|
+
* visit('{ "a": 1 }').pipe(
|
|
1760
|
+
* Stream.filter(
|
|
1761
|
+
* (e): e is Extract<JsoncVisitorEvent, { _tag: "LiteralValue" }> =>
|
|
1762
|
+
* e._tag === "LiteralValue",
|
|
1763
|
+
* ),
|
|
1764
|
+
* Stream.runCollect,
|
|
1765
|
+
* Effect.map(Chunk.toReadonlyArray),
|
|
1766
|
+
* ),
|
|
1767
|
+
* );
|
|
1768
|
+
* ```
|
|
1769
|
+
*
|
|
1770
|
+
* @public
|
|
1771
|
+
*/
|
|
1772
|
+
type JsoncVisitorEvent = {
|
|
1773
|
+
readonly _tag: "ObjectBegin";
|
|
1774
|
+
readonly offset: number;
|
|
1775
|
+
readonly length: number;
|
|
1776
|
+
readonly path: ReadonlyArray<string | number>;
|
|
1777
|
+
} | {
|
|
1778
|
+
readonly _tag: "ObjectEnd";
|
|
1779
|
+
readonly offset: number;
|
|
1780
|
+
readonly length: number;
|
|
1781
|
+
} | {
|
|
1782
|
+
readonly _tag: "ObjectProperty";
|
|
1783
|
+
readonly property: string;
|
|
1784
|
+
readonly offset: number;
|
|
1785
|
+
readonly length: number;
|
|
1786
|
+
readonly path: ReadonlyArray<string | number>;
|
|
1787
|
+
} | {
|
|
1788
|
+
readonly _tag: "ArrayBegin";
|
|
1789
|
+
readonly offset: number;
|
|
1790
|
+
readonly length: number;
|
|
1791
|
+
readonly path: ReadonlyArray<string | number>;
|
|
1792
|
+
} | {
|
|
1793
|
+
readonly _tag: "ArrayEnd";
|
|
1794
|
+
readonly offset: number;
|
|
1795
|
+
readonly length: number;
|
|
1796
|
+
} | {
|
|
1797
|
+
readonly _tag: "LiteralValue";
|
|
1798
|
+
readonly value: unknown;
|
|
1799
|
+
readonly offset: number;
|
|
1800
|
+
readonly length: number;
|
|
1801
|
+
readonly path: ReadonlyArray<string | number>;
|
|
1802
|
+
} | {
|
|
1803
|
+
readonly _tag: "Separator";
|
|
1804
|
+
readonly character: string;
|
|
1805
|
+
readonly offset: number;
|
|
1806
|
+
readonly length: number;
|
|
1807
|
+
} | {
|
|
1808
|
+
readonly _tag: "Comment";
|
|
1809
|
+
readonly offset: number;
|
|
1810
|
+
readonly length: number;
|
|
1811
|
+
} | {
|
|
1812
|
+
readonly _tag: "Error";
|
|
1813
|
+
readonly code: JsoncParseErrorCode;
|
|
1814
|
+
readonly offset: number;
|
|
1815
|
+
readonly length: number;
|
|
1816
|
+
};
|
|
1817
|
+
/**
|
|
1818
|
+
* Create a lazy `Stream` of {@link JsoncVisitorEvent} from JSONC text.
|
|
1819
|
+
*
|
|
1820
|
+
* Events are produced on demand as the stream is consumed, not
|
|
1821
|
+
* pre-collected into memory. This makes `visit` suitable for large
|
|
1822
|
+
* documents and supports early termination via `Stream.take` or
|
|
1823
|
+
* `Stream.takeWhile` without scanning the entire input.
|
|
1824
|
+
*
|
|
1825
|
+
* @param text - The JSONC source text to visit.
|
|
1826
|
+
* @param options - Optional partial {@link JsoncParseOptions} controlling
|
|
1827
|
+
* comment handling and trailing-comma tolerance.
|
|
1828
|
+
* @returns A `Stream` of {@link JsoncVisitorEvent} objects.
|
|
1829
|
+
*
|
|
1830
|
+
* @remarks
|
|
1831
|
+
* The stream is backed by a lazy generator — no work is performed until
|
|
1832
|
+
* the stream is consumed. Because evaluation is demand-driven, combining
|
|
1833
|
+
* `visit` with `Stream.take` allows efficient partial scans of large
|
|
1834
|
+
* documents without allocating a full AST.
|
|
1835
|
+
*
|
|
1836
|
+
* @see {@link visitCollect} for a one-step filter-and-collect convenience.
|
|
1837
|
+
* @see {@link JsoncVisitorEvent} for the event type definitions.
|
|
1838
|
+
*
|
|
1839
|
+
* @example Collect all events
|
|
1840
|
+
* ```ts
|
|
1841
|
+
* import { Chunk, Effect, Stream } from "effect";
|
|
1842
|
+
* import { visit } from "jsonc-effect";
|
|
1843
|
+
*
|
|
1844
|
+
* const all = Effect.runSync(
|
|
1845
|
+
* visit('{ "a": 1 }').pipe(
|
|
1846
|
+
* Stream.runCollect,
|
|
1847
|
+
* Effect.map(Chunk.toReadonlyArray),
|
|
1848
|
+
* ),
|
|
1849
|
+
* );
|
|
1850
|
+
* ```
|
|
1851
|
+
*
|
|
1852
|
+
* @example Filter and take the first match
|
|
1853
|
+
* ```ts
|
|
1854
|
+
* import { Chunk, Effect, Stream } from "effect";
|
|
1855
|
+
* import { visit } from "jsonc-effect";
|
|
1856
|
+
*
|
|
1857
|
+
* const firstLiteral = Effect.runSync(
|
|
1858
|
+
* visit('{ "a": 1, "b": 2 }').pipe(
|
|
1859
|
+
* Stream.filter((e) => e._tag === "LiteralValue"),
|
|
1860
|
+
* Stream.take(1),
|
|
1861
|
+
* Stream.runCollect,
|
|
1862
|
+
* Effect.map(Chunk.toReadonlyArray),
|
|
1863
|
+
* ),
|
|
1864
|
+
* );
|
|
1865
|
+
* ```
|
|
1866
|
+
*
|
|
1867
|
+
* @example Extract property names
|
|
1868
|
+
* ```ts
|
|
1869
|
+
* import { Chunk, Effect, Stream } from "effect";
|
|
1870
|
+
* import { visit } from "jsonc-effect";
|
|
1871
|
+
*
|
|
1872
|
+
* const propertyNames = Effect.runSync(
|
|
1873
|
+
* visit('{ "name": "Alice", "age": 30 }').pipe(
|
|
1874
|
+
* Stream.filter((e) => e._tag === "ObjectProperty"),
|
|
1875
|
+
* Stream.map((e) => (e as { property: string }).property),
|
|
1876
|
+
* Stream.runCollect,
|
|
1877
|
+
* Effect.map(Chunk.toReadonlyArray),
|
|
1878
|
+
* ),
|
|
1879
|
+
* );
|
|
1880
|
+
* ```
|
|
1881
|
+
*
|
|
1882
|
+
* @privateRemarks
|
|
1883
|
+
* Internally wraps a generator function with `Stream.fromIterable`,
|
|
1884
|
+
* preserving laziness. The generator yields events as it encounters
|
|
1885
|
+
* tokens from the scanner.
|
|
1886
|
+
*
|
|
1887
|
+
* @public
|
|
1888
|
+
*/
|
|
1889
|
+
declare const visit: (text: string, options?: Partial<JsoncParseOptions>) => Stream.Stream<JsoncVisitorEvent>;
|
|
1890
|
+
/**
|
|
1891
|
+
* Visit JSONC text and collect all events matching a type-guard predicate.
|
|
1892
|
+
*
|
|
1893
|
+
* This is a convenience that composes {@link visit}, `Stream.filter`, and
|
|
1894
|
+
* `Stream.runCollect` into a single call.
|
|
1895
|
+
*
|
|
1896
|
+
* @param text - The JSONC source text to visit.
|
|
1897
|
+
* @param predicate - A type-guard function that narrows
|
|
1898
|
+
* {@link JsoncVisitorEvent} to the desired subtype `A`.
|
|
1899
|
+
* @param options - Optional partial {@link JsoncParseOptions}.
|
|
1900
|
+
* @returns An `Effect` that succeeds with a read-only array of the
|
|
1901
|
+
* matched events.
|
|
1902
|
+
*
|
|
1903
|
+
* @remarks
|
|
1904
|
+
* Equivalent to:
|
|
1905
|
+
* ```
|
|
1906
|
+
* visit(text, options) |> Stream.filter(predicate) |> Stream.runCollect
|
|
1907
|
+
* ```
|
|
1908
|
+
* Use this when you need all matching events and do not require
|
|
1909
|
+
* intermediate stream transformations.
|
|
1910
|
+
*
|
|
1911
|
+
* @see {@link visit} for full stream-level control.
|
|
1912
|
+
*
|
|
1913
|
+
* @example Collecting literal values
|
|
1914
|
+
* ```ts
|
|
1915
|
+
* import { Effect } from "effect";
|
|
1916
|
+
* import type { JsoncVisitorEvent } from "jsonc-effect";
|
|
1917
|
+
* import { visitCollect } from "jsonc-effect";
|
|
1918
|
+
*
|
|
1919
|
+
* const literals = Effect.runSync(
|
|
1920
|
+
* visitCollect(
|
|
1921
|
+
* '{ "a": 1, "b": true }',
|
|
1922
|
+
* (e): e is Extract<JsoncVisitorEvent, { _tag: "LiteralValue" }> =>
|
|
1923
|
+
* e._tag === "LiteralValue",
|
|
1924
|
+
* ),
|
|
1925
|
+
* );
|
|
1926
|
+
* ```
|
|
1927
|
+
*
|
|
1928
|
+
* @public
|
|
1929
|
+
*/
|
|
1930
|
+
declare const visitCollect: <A extends JsoncVisitorEvent>(text: string, predicate: (event: JsoncVisitorEvent) => event is A, options?: Partial<JsoncParseOptions>) => Effect.Effect<ReadonlyArray<A>>;
|
|
1931
|
+
//#endregion
|
|
1932
|
+
export { JsoncEdit, type JsoncError, JsoncFormattingOptions, JsoncFromString, JsoncModificationError, JsoncModificationErrorBase, JsoncNode, JsoncNodeNotFoundError, JsoncNodeNotFoundErrorBase, type JsoncNodeType, JsoncParseError, JsoncParseErrorBase, type JsoncParseErrorCode, JsoncParseErrorDetail, JsoncParseOptions, type JsoncPath, JsoncRange, type JsoncScanError, type JsoncScanner, type JsoncSegment, type JsoncSyntaxKind, JsoncToken, type JsoncVisitorEvent, applyEdits, createScanner, equals, equalsValue, findNode, findNodeAtOffset, format, formatAndApply, getNodePath, getNodeValue, makeJsoncFromString, makeJsoncSchema, modify, parse, parseTree, stripComments, visit, visitCollect };
|
|
1933
|
+
//# sourceMappingURL=index.d.ts.map
|