1- import type { Decoder } from '~/core' ;
1+ import type { ReadonlyDecoder } from '~/core' ;
22
33import { array } from './arrays' ;
4- import { null_ } from './basics' ;
54import { boolean } from './booleans' ;
6- import { record } from './collections ' ;
7- import { lazy } from './misc ' ;
5+ import { either } from './unions ' ;
6+ import { null_ } from './basics ' ;
87import { number } from './numbers' ;
8+ import { lazy } from './misc' ;
9+ import { record } from './collections' ;
910import { string } from './strings' ;
10- import { either } from './unions' ;
1111
1212export type JSONValue = null | string | number | boolean | JSONObject | JSONArray ;
1313export type JSONObject = { [ key : string ] : JSONValue | undefined } ;
@@ -16,12 +16,16 @@ export type JSONArray = JSONValue[];
1616/**
1717 * Accepts objects that contain only valid JSON values.
1818 */
19- export const jsonObject : Decoder < JSONObject > = lazy ( ( ) => record ( json ) ) ;
19+ export const jsonObject : ReadonlyDecoder < JSONObject > = lazy ( ( ) => record ( json ) , {
20+ readonly : true ,
21+ } ) ;
2022
2123/**
2224 * Accepts arrays that contain only valid JSON values.
2325 */
24- export const jsonArray : Decoder < JSONArray > = lazy ( ( ) => array ( json ) ) ;
26+ export const jsonArray : ReadonlyDecoder < JSONArray > = lazy ( ( ) => array ( json ) , {
27+ readonly : true ,
28+ } ) ;
2529
2630/**
2731 * Accepts any value that's a valid JSON value.
@@ -39,7 +43,7 @@ export const jsonArray: Decoder<JSONArray> = lazy(() => array(json));
3943 * | JSONValue[]
4044 * ```
4145 */
42- export const json : Decoder < JSONValue > = either (
46+ export const json : ReadonlyDecoder < JSONValue > = either (
4347 null_ ,
4448 string ,
4549 number ,
0 commit comments