-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJSONSon.d.ts
39 lines (32 loc) · 1.38 KB
/
JSONSon.d.ts
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
30
31
32
33
34
35
36
37
38
39
type Class<T = Object> = new (...args: any[]) => T;
type PrimitiveTypes = 'string' | 'number' | 'boolean' | 'bigint';
type PrimitiveObjectiveTypes = typeof String | typeof Number | typeof Boolean | typeof BigInt;
type AllTypes = PrimitiveTypes | PrimitiveObjectiveTypes | Class | JSONSonMix | TypeObject | TypeArray;
type TypeObject = { [key: string]: AllTypes };
type TypeArray = AllTypes[];
type PrimitiveValues = string | number | boolean | bigint;
type PrimitiveObjectiveValues = String | Number | Boolean | BigInt;
type AnyValue = PrimitiveValues | PrimitiveObjectiveValues | AnyObject | AnyArray;
type AnyObject = { [key: string]: AnyValue };
type AnyArray = AnyValue[];
type JSONString = string;
export default class JSONSon {
constructor(type: AllTypes);
make(data: AnyObject): AnyValue;
parse(json: JSONString): AnyValue;
static make(type: AllTypes, data: AnyObject): AnyValue;
static parse(type: AllTypes, json: JSONString): AnyValue;
static mix(constructor: Class, propsObject: TypeObject): JSONSonMix;
static enum(...values: PrimitiveValues[]): JSONSonEnum;
}
interface JSONSonMix {
underlyingConstructor: Class;
propsObject: AnyObject;
new(underlyingConstructor: Class, propsObject: TypeObject);
make(data: AnyObject): AnyObject;
}
interface JSONSonEnum {
supportedValues: Set<PrimitiveValues>;
new(...values: PrimitiveValues[]);
make(data: PrimitiveValues): PrimitiveValues;
}