json-as 0.9.21 → 0.9.23

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.
@@ -1,103 +1,153 @@
1
1
  import { dtoa_buffered, itoa_buffered } from "util/number";
2
2
  import { OBJECT, TOTAL_OVERHEAD } from "rt/common";
3
+ // @ts-ignore
3
4
  @inline const MAX_LEN: usize = 65536;
4
5
  const STORE: usize[] = [];
5
6
  let STORE_LEN: usize = 0;
6
7
  const CACHE = memory.data(i32(MAX_LEN));
7
8
  // Configurable amount of referenceable strings
8
9
  let POINTER = changetype<usize>(CACHE);
10
+ // @ts-ignore
9
11
  @inline const MAX_CACHE = CACHE + MAX_LEN;
10
12
 
11
13
  export namespace bs {
14
+ // @ts-ignore
12
15
  @inline export function write_int<T extends number>(num: T): void {
13
16
  POINTER += itoa_buffered(POINTER, num) << 1;
14
17
  if (MAX_CACHE <= POINTER) bs.shrink();
15
18
  }
19
+
20
+ // @ts-ignore
16
21
  @inline export function write_int_u<T extends number>(num: T): void {
17
22
  POINTER += itoa_buffered(POINTER, num) << 1;
18
23
  }
19
24
 
25
+ // @ts-ignore
20
26
  @inline export function write_fl<T extends number>(num: T): void {
21
27
  POINTER += dtoa_buffered(POINTER, num) << 1;
22
28
  if (MAX_CACHE <= POINTER) bs.shrink();
23
29
  }
30
+
31
+ // @ts-ignore
24
32
  @inline export function write_fl_u<T extends number>(num: T): void {
25
33
  POINTER += dtoa_buffered(POINTER, num) << 1;
26
34
  }
27
35
 
36
+ // @ts-ignore
28
37
  @inline export function write_b(buf: usize, bytes: usize = changetype<OBJECT>(buf - TOTAL_OVERHEAD).rtSize): void {
29
38
  memory.copy(POINTER, buf, bytes);
30
39
  POINTER += bytes;
31
40
  if (MAX_CACHE <= POINTER) bs.shrink();
32
41
  }
42
+
43
+ // @ts-ignore
33
44
  @inline export function write_b_u(buf: usize, bytes: usize = changetype<OBJECT>(buf - TOTAL_OVERHEAD).rtSize): void {
34
45
  memory.copy(POINTER, buf, bytes);
35
46
  POINTER += bytes;
36
47
  }
37
48
 
49
+ // @ts-ignore
38
50
  @inline export function write_s(str: string, bytes: usize = changetype<OBJECT>(changetype<usize>(str) - TOTAL_OVERHEAD).rtSize): void {
39
51
  memory.copy(POINTER, changetype<usize>(str), bytes);
40
52
  POINTER += bytes;
41
53
  if (MAX_CACHE <= POINTER) bs.shrink();
42
54
  }
55
+
56
+ // @ts-ignore
43
57
  @inline export function write_s_u(str: string, bytes: usize = changetype<OBJECT>(changetype<usize>(str) - TOTAL_OVERHEAD).rtSize): void {
44
58
  memory.copy(POINTER, changetype<usize>(str), bytes);
45
59
  POINTER += bytes;
46
60
  }
47
61
 
62
+ // @ts-ignore
48
63
  @inline export function write_s_se(str: string, start: usize, end: usize): void {
49
64
  const bytes = end - start;
50
65
  memory.copy(POINTER, changetype<usize>(str) + start, bytes);
51
66
  POINTER += bytes;
52
67
  if (MAX_CACHE <= POINTER) bs.shrink();
53
68
  }
69
+
70
+ // @ts-ignore
54
71
  @inline export function write_s_se_u(str: string, start: usize, end: usize): void {
55
72
  const bytes = end - start;
56
73
  memory.copy(POINTER, changetype<usize>(str) + start, bytes);
57
74
  POINTER += bytes;
58
75
  }
59
76
 
77
+ // @ts-ignore
78
+ @inline export function write_8(char: i32): void {
79
+ store<u8>(POINTER, char);
80
+ POINTER += 2;
81
+ if (MAX_CACHE <= POINTER) bs.shrink();
82
+ }
83
+
84
+ // @ts-ignore
85
+ @inline export function write_8_u(char: i32): void {
86
+ store<u8>(POINTER, char);
87
+ //POINTER += 2;
88
+ }
89
+
90
+ // @ts-ignore
60
91
  @inline export function write_16(char: i32): void {
61
92
  store<u16>(POINTER, char);
62
93
  POINTER += 2;
63
94
  if (MAX_CACHE <= POINTER) bs.shrink();
64
95
  }
96
+
97
+ // @ts-ignore
65
98
  @inline export function write_16_u(char: i32): void {
66
99
  store<u16>(POINTER, char);
67
100
  //POINTER += 2;
68
101
  }
69
102
 
103
+ // @ts-ignore
70
104
  @inline export function write_32(chars: i32): void {
71
105
  store<u32>(POINTER, chars);
72
106
  POINTER += 4;
73
107
  if (MAX_CACHE <= POINTER) bs.shrink();
74
108
  }
109
+
110
+ // @ts-ignore
75
111
  @inline export function write_32_u(chars: i32): void {
76
112
  store<u32>(POINTER, chars);
77
113
  //POINTER += 4;
78
114
  }
79
115
 
116
+ // @ts-ignore
80
117
  @inline export function write_64(chars: i64): void {
81
118
  store<u64>(POINTER, chars);
82
119
  POINTER += 8;
83
120
  if (MAX_CACHE <= POINTER) bs.shrink();
84
121
  }
85
122
 
123
+ // @ts-ignore
86
124
  @inline export function write_64_u(chars: i64): void {
87
125
  store<u64>(POINTER, chars);
88
126
  POINTER += 8;
89
127
  }
90
128
 
129
+ // @ts-ignore
91
130
  @inline export function write_128(chars: v128): void {
92
131
  store<v128>(POINTER, chars);
93
132
  POINTER += 16;
94
133
  if (MAX_CACHE <= POINTER) bs.shrink();
95
134
  }
135
+
136
+ // @ts-ignore
137
+ @inline export function write_128_n(chars: v128, n: usize): void {
138
+ store<v128>(POINTER, chars);
139
+ POINTER += n;
140
+ if (MAX_CACHE <= POINTER) bs.shrink();
141
+ }
142
+
143
+ // @ts-ignore
96
144
  @inline export function write_128_u(chars: v128): void {
97
145
  store<v128>(POINTER, chars);
98
146
  //POINTER += 16;
99
- //if (MAX_CACHE <= POINTER) bs.shrink();
147
+ //if (MAX_CACHE <= POINTER) bs.shrink();
100
148
  }
149
+
150
+ // @ts-ignore
101
151
  @inline export function shrink(): void {
102
152
  const len = POINTER - CACHE;
103
153
  STORE_LEN += len;
@@ -109,6 +159,8 @@ export namespace bs {
109
159
  bs.reset();
110
160
  STORE.push(out);
111
161
  }
162
+
163
+ // @ts-ignore
112
164
  @inline export function out<T>(): T {
113
165
  const len = POINTER - CACHE;
114
166
  let out = __new(
@@ -133,6 +185,7 @@ export namespace bs {
133
185
  return changetype<T>(out);
134
186
  }
135
187
 
188
+ // @ts-ignore
136
189
  @inline export function out_u<T>(): T {
137
190
  const len = POINTER - CACHE;
138
191
  const out = __new(
@@ -146,9 +199,12 @@ export namespace bs {
146
199
  return changetype<T>(out);
147
200
  }
148
201
 
202
+ // @ts-ignore
149
203
  @inline export function _out(out: usize): void {
150
204
  memory.copy(out, CACHE, POINTER - CACHE);
151
205
  }
206
+
207
+ // @ts-ignore
152
208
  @inline export function reset(): void {
153
209
  POINTER = CACHE;
154
210
  }
@@ -16,33 +16,16 @@ export class Sink {
16
16
 
17
17
  static withCapacity(capacity: i32): Sink {
18
18
  const sink = new Sink();
19
- sink.buffer = changetype<ArrayBuffer>(
20
- __new(
21
- max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1),
22
- idof<ArrayBuffer>(),
23
- ),
24
- );
19
+ sink.buffer = changetype<ArrayBuffer>(__new(max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1), idof<ArrayBuffer>()));
25
20
  return sink;
26
21
  }
27
22
 
28
- static fromString(
29
- initial: string = "",
30
- capacity: i32 = MIN_BUFFER_LEN,
31
- ): Sink {
23
+ static fromString(initial: string = "", capacity: i32 = MIN_BUFFER_LEN): Sink {
32
24
  const sink = new Sink();
33
25
  const size = (<u32>initial.length) << 1;
34
- sink.buffer = changetype<ArrayBuffer>(
35
- __new(
36
- max<u32>(size, max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1)),
37
- idof<ArrayBuffer>(),
38
- ),
39
- );
26
+ sink.buffer = changetype<ArrayBuffer>(__new(max<u32>(size, max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1)), idof<ArrayBuffer>()));
40
27
  if (size) {
41
- memory.copy(
42
- changetype<usize>(sink.buffer),
43
- changetype<usize>(initial),
44
- size,
45
- );
28
+ memory.copy(changetype<usize>(sink.buffer), changetype<usize>(initial), size);
46
29
  sink.offset += size;
47
30
  }
48
31
  return sink;
@@ -53,34 +36,18 @@ export class Sink {
53
36
  const size = (<u32>initial.length) << 1;
54
37
  sink.buffer = changetype<ArrayBuffer>(__new(size, idof<ArrayBuffer>()));
55
38
  if (size) {
56
- memory.copy(
57
- changetype<usize>(sink.buffer),
58
- changetype<usize>(initial),
59
- size,
60
- );
39
+ memory.copy(changetype<usize>(sink.buffer), changetype<usize>(initial), size);
61
40
  sink.offset += size;
62
41
  }
63
42
  return sink;
64
43
  }
65
44
 
66
- static fromBuffer(
67
- initial: ArrayBuffer,
68
- capacity: i32 = MIN_BUFFER_LEN,
69
- ): Sink {
45
+ static fromBuffer(initial: ArrayBuffer, capacity: i32 = MIN_BUFFER_LEN): Sink {
70
46
  const sink = new Sink();
71
47
  const size = <u32>initial.byteLength;
72
- sink.buffer = changetype<ArrayBuffer>(
73
- __new(
74
- max<u32>(size, max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1)),
75
- idof<ArrayBuffer>(),
76
- ),
77
- );
48
+ sink.buffer = changetype<ArrayBuffer>(__new(max<u32>(size, max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1)), idof<ArrayBuffer>()));
78
49
  if (size) {
79
- memory.copy(
80
- changetype<usize>(sink.buffer),
81
- changetype<usize>(initial),
82
- size,
83
- );
50
+ memory.copy(changetype<usize>(sink.buffer), changetype<usize>(initial), size);
84
51
  sink.offset = size;
85
52
  }
86
53
  return sink;
@@ -116,11 +83,7 @@ export class Sink {
116
83
  this.ensureCapacity(size);
117
84
  let offset = this.offset;
118
85
 
119
- memory.copy(
120
- changetype<usize>(this.buffer) + offset,
121
- changetype<usize>(src) + ((<usize>start) << 1),
122
- size,
123
- );
86
+ memory.copy(changetype<usize>(this.buffer) + offset, changetype<usize>(src) + ((<usize>start) << 1), size);
124
87
  this.offset = offset + size;
125
88
  return this;
126
89
  }
@@ -140,8 +103,7 @@ export class Sink {
140
103
  this.ensureCapacity(size + 2);
141
104
  let offset = this.offset;
142
105
  let dest = changetype<usize>(this.buffer) + offset;
143
- if (size)
144
- memory.copy(dest, changetype<usize>(src) + ((<usize>start) << 1), size);
106
+ if (size) memory.copy(dest, changetype<usize>(src) + ((<usize>start) << 1), size);
145
107
  store<u16>(dest + size, NEW_LINE_CHAR);
146
108
  this.offset = offset + (size + 2);
147
109
  return this;
@@ -209,12 +171,10 @@ export class Sink {
209
171
  maxCapacity = 21 << 1;
210
172
  }
211
173
  this.ensureCapacity(maxCapacity);
212
- offset +=
213
- itoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
174
+ offset += itoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
214
175
  } else {
215
176
  this.ensureCapacity(32 << 1);
216
- offset +=
217
- dtoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
177
+ offset += dtoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
218
178
  }
219
179
  this.offset = offset;
220
180
  return this;
@@ -222,11 +182,9 @@ export class Sink {
222
182
  writeNumberUnsafe<T extends number>(value: T): Sink {
223
183
  let offset = this.offset;
224
184
  if (isInteger<T>()) {
225
- offset +=
226
- itoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
185
+ offset += itoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
227
186
  } else {
228
- offset +=
229
- dtoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
187
+ offset += dtoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
230
188
  }
231
189
  this.offset = offset;
232
190
  return this;
@@ -234,11 +192,9 @@ export class Sink {
234
192
  writeIntegerUnsafe<T extends number>(value: T): Sink {
235
193
  let offset = this.offset;
236
194
  if (isInteger<T>()) {
237
- offset +=
238
- itoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
195
+ offset += itoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
239
196
  } else {
240
- offset +=
241
- dtoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
197
+ offset += dtoa_buffered(changetype<usize>(this.buffer) + offset, value) << 1;
242
198
  }
243
199
  this.offset = offset;
244
200
  return this;
@@ -246,21 +202,11 @@ export class Sink {
246
202
 
247
203
  reserve(capacity: i32, clear: bool = false): void {
248
204
  if (clear) this.offset = 0;
249
- this.buffer = changetype<ArrayBuffer>(
250
- __renew(
251
- changetype<usize>(this.buffer),
252
- max<u32>(this.offset, max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1)),
253
- ),
254
- );
205
+ this.buffer = changetype<ArrayBuffer>(__renew(changetype<usize>(this.buffer), max<u32>(this.offset, max<u32>(MIN_BUFFER_SIZE, (<u32>capacity) << 1))));
255
206
  }
256
207
 
257
208
  shrink(): void {
258
- this.buffer = changetype<ArrayBuffer>(
259
- __renew(
260
- changetype<usize>(this.buffer),
261
- max<u32>(this.offset, MIN_BUFFER_SIZE),
262
- ),
263
- );
209
+ this.buffer = changetype<ArrayBuffer>(__renew(changetype<usize>(this.buffer), max<u32>(this.offset, MIN_BUFFER_SIZE)));
264
210
  }
265
211
 
266
212
  clear(): void {
@@ -279,9 +225,7 @@ export class Sink {
279
225
  let buffer = this.buffer;
280
226
  let newSize = this.offset + deltaBytes;
281
227
  if (newSize > <u32>buffer.byteLength) {
282
- this.buffer = changetype<ArrayBuffer>(
283
- __renew(changetype<usize>(buffer), nextPowerOf2(newSize)),
284
- );
228
+ this.buffer = changetype<ArrayBuffer>(__renew(changetype<usize>(buffer), nextPowerOf2(newSize)));
285
229
  }
286
230
  }
287
231
  }
@@ -31,11 +31,7 @@ export function deserializeArray<T extends unknown[]>(data: string): T {
31
31
  if (isDefined(type.__DESERIALIZE)) {
32
32
  return deserializeObjectArray<T>(data);
33
33
  }
34
- throw new Error(
35
- "Could not parse array of type " +
36
- nameof<T>() +
37
- "! Make sure to add the @json decorator over classes!",
38
- );
34
+ throw new Error("Could not parse array of type " + nameof<T>() + "! Make sure to add the @json decorator over classes!");
39
35
  } else {
40
36
  throw new Error("Could not parse array of type " + nameof<T>() + "!");
41
37
  }
@@ -1,3 +1,4 @@
1
+ import { bs } from "../custom/bs";
1
2
  import {
2
3
  CHAR_B,
3
4
  BACK_SLASH,
@@ -85,4 +86,73 @@ import { unsafeCharCodeAt } from "../custom/util";
85
86
  result.write(data, last, end);
86
87
  }
87
88
  return result.toString()
88
- }
89
+ }
90
+
91
+ // @ts-ignore: Decorator valid here
92
+ // @inline export function deserializeString_BS(data: string, start: i32 = 0, end: i32 = 0): void {
93
+ // end = end || data.length - 1;
94
+ // let last = start + 1;
95
+ // for (let i = last; i < end; i++) {
96
+ // if (unsafeCharCodeAt(data, i) !== BACK_SLASH) {
97
+ // continue;
98
+ // }
99
+ // const char = unsafeCharCodeAt(data, ++i);
100
+ // bs.write_s_se_u(data, last, i - 1);
101
+ // switch (char) {
102
+ // case QUOTE: {
103
+ // bs.write_8(QUOTE);
104
+ // last = i + 1;
105
+ // break;
106
+ // }
107
+ // case BACK_SLASH: {
108
+ // bs.write_8(BACK_SLASH);
109
+ // last = i + 1;
110
+ // break;
111
+ // }
112
+ // case FWD_SLASH: {
113
+ // bs.write_8(FWD_SLASH);
114
+ // last = i + 1;
115
+ // break;
116
+ // }
117
+ // case CHAR_B: {
118
+ // bs.write_8(BACKSPACE);
119
+ // last = i + 1;
120
+ // break;
121
+ // }
122
+ // case CHAR_F: {
123
+ // bs.write_8(FORM_FEED);
124
+ // last = i + 1;
125
+ // break;
126
+ // }
127
+ // case CHAR_N: {
128
+ // bs.write_8(NEW_LINE);
129
+ // last = i + 1;
130
+ // break;
131
+ // }
132
+ // case CHAR_R: {
133
+ // bs.write_8(CARRIAGE_RETURN);
134
+ // last = i + 1;
135
+ // break;
136
+ // }
137
+ // case CHAR_T: {
138
+ // bs.write_8(TAB);
139
+ // last = i + 1;
140
+ // break;
141
+ // }
142
+ // case CHAR_U: {
143
+
144
+ // const code = u16.parse(data.slice(i + 1, i + 5), 16);
145
+ // bs.w(code);
146
+ // i += 4;
147
+ // last = i + 1;
148
+ // break;
149
+ // }
150
+ // default: {
151
+ // throw new Error(`JSON: Cannot parse "${data}" as string. Invalid escape sequence: \\${data.charAt(i)}`);
152
+ // }
153
+ // }
154
+ // }
155
+ // if (end > last) {
156
+ // result.write(data, last, end);
157
+ // }
158
+ // }
package/assembly/index.ts CHANGED
@@ -3,7 +3,7 @@ import { serializeString } from "./serialize/string";
3
3
  import { serializeBool } from "./serialize/bool";
4
4
  import { serializeInteger } from "./serialize/integer";
5
5
  import { serializeFloat } from "./serialize/float";
6
- import { serializeObject } from "./serialize/object";
6
+ import { serializeObject, serializeObject_Pretty } from "./serialize/object";
7
7
  import { serializeDate } from "./serialize/date";
8
8
  import { serializeArray } from "./serialize/array";
9
9
  import { serializeMap } from "./serialize/map";
@@ -13,11 +13,18 @@ import { deserializeFloat } from "./deserialize/float";
13
13
  import { deserializeObject } from "./deserialize/object";
14
14
  import { deserializeMap } from "./deserialize/map";
15
15
  import { deserializeDate } from "./deserialize/date";
16
- import { BRACKET_LEFT, NULL_WORD } from "./custom/chars";
16
+ import { NULL_WORD } from "./custom/chars";
17
17
  import { deserializeInteger } from "./deserialize/integer";
18
18
  import { deserializeString } from "./deserialize/string";
19
19
  import { Sink } from "./custom/sink";
20
- import { bs } from "./custom/bs";
20
+ import { getArrayDepth } from "./custom/util";
21
+
22
+ // Config
23
+ class SerializeOptions {
24
+ public pretty: bool = false;
25
+ }
26
+
27
+ const DEFAULT_SERIALIZE_OPTIONS = new SerializeOptions();
21
28
 
22
29
  /**
23
30
  * Offset of the 'storage' property in the JSON.Value class.
@@ -156,179 +163,6 @@ export namespace JSON {
156
163
  @inline static from<T>(value: T): Box<T> {
157
164
  return new Box(value);
158
165
  }
159
- @inline
160
- @operator("==")
161
- eq(other: this): bool {
162
- if (isNullable<T>() && changetype<usize>(this) == <usize>0) {
163
- if (changetype<usize>(other) == <usize>0) return true;
164
- }
165
- return this.value == other.value;
166
- }
167
-
168
- @inline
169
- @operator("!=")
170
- notEq(other: this): bool {
171
- if (isNullable<T>() && changetype<usize>(this) == <usize>0) {
172
- if (changetype<usize>(this) == changetype<usize>(other)) return true;
173
- }
174
- return this.value != other.value;
175
- }
176
-
177
- @inline
178
- @operator(">")
179
- gt(other: this): bool {
180
- return this._val > other._val;
181
- }
182
-
183
- @inline
184
- @operator(">=")
185
- ge(other: this): bool {
186
- return this._val >= other._val;
187
- }
188
-
189
- @inline
190
- @operator("<")
191
- lt(other: this): bool {
192
- return this._val < other._val;
193
- }
194
-
195
- @inline
196
- @operator("<=")
197
- le(other: this): bool {
198
- return this._val <= other._val;
199
- }
200
-
201
- @inline
202
- @operator(">>")
203
- shr(other: this): this {
204
- // @ts-ignore
205
- return instantiate<this>(this._val >> other._val);
206
- }
207
-
208
- @inline
209
- @operator(">>>")
210
- shr_u(other: this): this {
211
- // @ts-ignore
212
- return instantiate<this>(this._val >>> other._val);
213
- }
214
-
215
- @inline
216
- @operator("<<")
217
- shl(other: this): this {
218
- // @ts-ignore
219
- return instantiate<this>(this._val << other._val);
220
- }
221
-
222
- @inline
223
- @operator("&")
224
- and(other: this): this {
225
- // @ts-ignore
226
- return instantiate<this>(this._val & other._val);
227
- }
228
-
229
- @inline
230
- @operator("|")
231
- or(other: this): this {
232
- // @ts-ignore
233
- return instantiate<this>(this._val | other._val);
234
- }
235
-
236
- @inline
237
- @operator("^")
238
- xor(other: this): this {
239
- // @ts-ignore
240
- return instantiate<this>(this._val ^ other._val);
241
- }
242
-
243
- @inline
244
- @operator("+")
245
- add(other: this): this {
246
- // @ts-ignore
247
- return instantiate<this>(this._val + other._val);
248
- }
249
-
250
- @inline
251
- @operator("-")
252
- sub(other: this): this {
253
- // @ts-ignore
254
- return instantiate<this>(this._val - other._val);
255
- }
256
-
257
- @inline
258
- @operator("*")
259
- mul(other: this): this {
260
- // @ts-ignore
261
- return instantiate<this>(this._val * other._val);
262
- }
263
-
264
- @inline
265
- @operator("/")
266
- div(other: this): this {
267
- // @ts-ignore
268
- return instantiate<this>(this._val / other._val);
269
- }
270
-
271
- @inline
272
- @operator("**")
273
- pow(other: this): this {
274
- // @ts-ignore
275
- return instantiate<this>((this._val ** other._val) as T);
276
- }
277
-
278
- @inline
279
- @operator("%")
280
- rem(other: this): this {
281
- // @ts-ignore
282
- return instantiate<this>(this._val % other._val);
283
- }
284
-
285
- @inline
286
- @operator.prefix("!")
287
- isEmpty(): bool {
288
- return !this._val;
289
- }
290
-
291
- @inline
292
- @operator.prefix("~")
293
- not(): this {
294
- return instantiate<this>(~this._val);
295
- }
296
-
297
- @inline
298
- @operator.prefix("+")
299
- pos(): this {
300
- return instantiate<this>(+this._val);
301
- }
302
-
303
- @inline
304
- @operator.prefix("-")
305
- neg(): this {
306
- return instantiate<this>(-this._val);
307
- }
308
-
309
- @operator.prefix("++")
310
- preInc(): this {
311
- // @ts-ignore
312
- ++this._val;
313
- return this;
314
- }
315
-
316
- @operator.prefix("--")
317
- preDec(): this {
318
- // @ts-ignore
319
- --this._val;
320
- return this;
321
- }
322
-
323
- @operator.postfix("++")
324
- postInc(): this {
325
- return this.clone().preInc();
326
- }
327
-
328
- @operator.postfix("--")
329
- postDec(): this {
330
- return this.clone().preDec();
331
- }
332
166
  }
333
167
 
334
168
  /**
@@ -340,7 +174,7 @@ export namespace JSON {
340
174
  * @returns string
341
175
  */
342
176
  // @ts-ignore: Decorator
343
- export function stringify<T>(data: T): string {
177
+ export function stringify<T>(data: T/*, options: SerializeOptions = DEFAULT_SERIALIZE_OPTIONS*/): string {
344
178
  if (isBoolean<T>()) {
345
179
  return serializeBool(data as bool);
346
180
  } else if (isInteger<T>()) {
@@ -357,6 +191,10 @@ export namespace JSON {
357
191
  return serializeString(changetype<string>(data));
358
192
  // @ts-ignore: Supplied by transform
359
193
  } else if (isDefined(data.__SERIALIZE)) {
194
+ /*if (options.pretty) {
195
+ // @ts-ignore
196
+ return serializeObject_Pretty(changetype<nonnull<T>>(data));
197
+ }*/
360
198
  // @ts-ignore
361
199
  return serializeObject(changetype<nonnull<T>>(data));
362
200
  } else if (data instanceof Date) {
@@ -402,7 +240,7 @@ export namespace JSON {
402
240
  return deserializeArray<nonnull<T>>(data);
403
241
  }
404
242
  let type: nonnull<T> = changetype<nonnull<T>>(0);
405
- // @ts-ignore: Defined by trasnform
243
+ // @ts-ignore: Defined by transform
406
244
  if (isDefined(type.__DESERIALIZE)) {
407
245
  // @ts-ignore
408
246
  return deserializeObject<nonnull<T>>(data.trimStart());