1 | /**
|
2 | * A type alias for a JSON primitive.
|
3 | */
|
4 | export declare type JSONPrimitive = boolean | number | string | null;
|
5 | /**
|
6 | * A type alias for a JSON value.
|
7 | */
|
8 | export declare type JSONValue = JSONPrimitive | JSONObject | JSONArray;
|
9 | /**
|
10 | * A type definition for a JSON object.
|
11 | */
|
12 | export interface JSONObject {
|
13 | [key: string]: JSONValue;
|
14 | }
|
15 | /**
|
16 | * A type definition for a JSON array.
|
17 | */
|
18 | export interface JSONArray extends Array<JSONValue> {
|
19 | }
|
20 | /**
|
21 | * A type definition for a readonly JSON object.
|
22 | */
|
23 | export interface ReadonlyJSONObject {
|
24 | readonly [key: string]: ReadonlyJSONValue;
|
25 | }
|
26 | /**
|
27 | * A type definition for a readonly JSON array.
|
28 | */
|
29 | export interface ReadonlyJSONArray extends ReadonlyArray<ReadonlyJSONValue> {
|
30 | }
|
31 | /**
|
32 | * A type alias for a readonly JSON value.
|
33 | */
|
34 | export declare type ReadonlyJSONValue = JSONPrimitive | ReadonlyJSONObject | ReadonlyJSONArray;
|
35 | /**
|
36 | * The namespace for JSON-specific functions.
|
37 | */
|
38 | export declare namespace JSONExt {
|
39 | /**
|
40 | * A shared frozen empty JSONObject
|
41 | */
|
42 | const emptyObject: ReadonlyJSONObject;
|
43 | /**
|
44 | * A shared frozen empty JSONArray
|
45 | */
|
46 | const emptyArray: ReadonlyJSONArray;
|
47 | /**
|
48 | * Test whether a JSON value is a primitive.
|
49 | *
|
50 | * @param value - The JSON value of interest.
|
51 | *
|
52 | * @returns `true` if the value is a primitive,`false` otherwise.
|
53 | */
|
54 | function isPrimitive(value: ReadonlyJSONValue): value is JSONPrimitive;
|
55 | /**
|
56 | * Test whether a JSON value is an array.
|
57 | *
|
58 | * @param value - The JSON value of interest.
|
59 | *
|
60 | * @returns `true` if the value is a an array, `false` otherwise.
|
61 | */
|
62 | function isArray(value: JSONValue): value is JSONArray;
|
63 | function isArray(value: ReadonlyJSONValue): value is ReadonlyJSONArray;
|
64 | /**
|
65 | * Test whether a JSON value is an object.
|
66 | *
|
67 | * @param value - The JSON value of interest.
|
68 | *
|
69 | * @returns `true` if the value is a an object, `false` otherwise.
|
70 | */
|
71 | function isObject(value: JSONValue): value is JSONObject;
|
72 | function isObject(value: ReadonlyJSONValue): value is ReadonlyJSONObject;
|
73 | /**
|
74 | * Compare two JSON values for deep equality.
|
75 | *
|
76 | * @param first - The first JSON value of interest.
|
77 | *
|
78 | * @param second - The second JSON value of interest.
|
79 | *
|
80 | * @returns `true` if the values are equivalent, `false` otherwise.
|
81 | */
|
82 | function deepEqual(first: ReadonlyJSONValue, second: ReadonlyJSONValue): boolean;
|
83 | /**
|
84 | * Create a deep copy of a JSON value.
|
85 | *
|
86 | * @param value - The JSON value to copy.
|
87 | *
|
88 | * @returns A deep copy of the given JSON value.
|
89 | */
|
90 | function deepCopy<T extends ReadonlyJSONValue>(value: T): T;
|
91 | }
|