-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
177 lines (150 loc) · 7.43 KB
/
index.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
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
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
declare module 'data-context' {
/** Creates a new data context. */
export function CreateDataContext(
/** The value to wrap. */
value: any,
/** The name of the property that this data context represents. */
propertyName: string,
/** The parent data context. */
parent: DataContext
): DataContext;
export interface createDataContext {
/** If true, the metadata is ignored. */
IgnoreMetadata: boolean;
}
/**
* The parse() static method parses a JSON string,
* constructing the JavaScript value or object described by the string.
* An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.
*/
export function Parse(
/** The string to parse as JSON. See the JSON object for a description of JSON syntax. */
text: string,
/** If a function, this prescribes how each value originally produced by parsing is transformed before being returned.
* Non-callable values are ignored. */
reviver: object | { (key: string, value: any): any }
): any;
/** Parse a string to an object, asynchronously. */
export function ParsePromise(
/** The string to parse as JSON. See the JSON object for a description of JSON syntax. */
text: string,
/** If a function, this prescribes how each value originally produced by parsing is transformed before being returned.
* Non-callable values are ignored. */
reviver: object | { (key: string, value: any): any }
): Promise<any>;
/**
* The method converts a JavaScript value to a JSON string,
* optionally replacing values if a replacer function is specified or optionally
* including only the specified properties if a replacer array is specified.
*/
export function Stringify(
/** The value to convert to a JSON string. */
value: any,
/** A function that alters the behavior of the stringification process,
* or an array of strings and numbers that specifies properties of value to be included in the output.
* If replacer is an array, all elements in this array that are not strings or numbers (either primitives or wrapper objects),
* including Symbol values, are completely ignored.
* If replacer is anything other than a function or an array (e.g. null or not provided),
* all string-keyed properties of the object are included in the resulting JSON string. */
replacer: object | { (key: string, value: any): any },
/** A string or number that's used to insert white space (including indentation, line break characters, etc.)
* into the output JSON string for readability purposes.
*
* If this is a number, it indicates the number of space characters to be used as indentation,
* clamped to 10 (that is, any number greater than 10 is treated as if it were 10).
* Values less than 1 indicate that no space should be used. */
space: string | number
): string;
export interface DataContext {
/** The value of the data context. (self-use) */
_isDataContext: boolean;
/** The value is modified. (self-use) */
_isModified: boolean;
/** The modified properties. (self-use) */
_modified: Array<string>;
/** The value property name. (self-use) */
_propertyName: string;
/** The parent data context. (self-use) */
_parent: DataContext;
/** The Events object. (self-use) */
_events: object;
once(
/** The event name. */
/** Data context events: 'new', 'set', 'delete', 'change', 'reposition'. */
eventName: string,
/** The event handler. */
handler: { (event: EventObject): boolean }
): DataContext;
/** Add data to the context listener */
on(
/** The event name. */
/** Data context events: 'new', 'set', 'delete', 'change', 'reposition'. */
eventName: string,
/** The event handler.
* Returning true means that the listening function is alive and will not be deleted. */
handler: { (event: EventObject | any): boolean }
): DataContext;
/** Emits the event. Return true means that the listening is handled. */
emit(
/** The event name. */
/** Data context events: 'new', 'set', 'delete', 'change', 'reposition'. */
eventName: string,
/** The event object. */
event: EventObject | any
): boolean;
/** Emits the event to parent. Return true means that the listening is handled. */
emitToParent(
/** The event name. */
/** Data context events: 'new', 'set', 'delete', 'change', 'reposition'. */
eventName: string,
/** The event object. */
event: EventObject | any
): boolean;
/** The value to stringify. */
toString(): string;
/** The overwriting data */
overwritingData(
/** The string to parse as JSON. See the JSON object for a description of JSON syntax. */
text: string,
/** If a function, this prescribes how each value originally produced by parsing is transformed before being returned.
* Non-callable values are ignored. */
reviver: object | { (key: string, value: any): any }
): void;
stringifyChanges(
/** A function that alters the behavior of the stringification process,
* or an array of strings and numbers that specifies properties of value to be included in the output.
* If replacer is an array, all elements in this array that are not strings or numbers (either primitives or wrapper objects),
* including Symbol values, are completely ignored.
* If replacer is anything other than a function or an array (e.g. null or not provided),
* all string-keyed properties of the object are included in the resulting JSON string. */
replacer: object | { (key: string, value: any): any },
/** A string or number that's used to insert white space (including indentation, line break characters, etc.)
* into the output JSON string for readability purposes.
*
* If this is a number, it indicates the number of space characters to be used as indentation,
* clamped to 10 (that is, any number greater than 10 is treated as if it were 10).
* Values less than 1 indicate that no space should be used. */
space: string | number,
/** If true, get the modified data. Default is true. */
modifiedData: boolean,
/** If true, set the modified data to unmodified. Default is true. */
setUnmodified: boolean
): string
}
export interface EventObject {
/** The event name. */
eventName: string; // 'new' | 'set' | 'delete' | 'change' | 'reposition'
/** The event target. */
target: DataContext;
/** The property path. */
propertyPath: string[];
/** The parent data context. */
parent: DataContext;
/** The old value. */
oldValue: any;
/** The new value. */
newValue: any;
}
export default CreateDataContext;
}