@@ -7,14 +7,18 @@ advantages reduces on large payloads.
7
7
Benchmarks:
8
8
9
9
```
10
- JSON.stringify array x 3,679 ops/sec ±1.01% (85 runs sampled)
11
- fast-json-stringify array x 4,618 ops/sec ±1.64% (87 runs sampled)
12
- JSON.stringify long string x 13,303 ops/sec ±1.01% (89 runs sampled)
13
- fast-json-stringify long string x 13,489 ops/sec ±0.88% (90 runs sampled)
14
- JSON.stringify short string x 4,974,749 ops/sec ±1.14% (86 runs sampled)
15
- fast-json-stringify short string x 11,030,700 ops/sec ±0.82% (89 runs sampled)
16
- JSON.stringify obj x 1,774,593 ops/sec ±1.07% (90 runs sampled)
17
- fast-json-stringify obj x 4,976,369 ops/sec ±1.00% (89 runs sampled)
10
+ JSON.stringify array x 3,288 ops/sec ±5.18% (82 runs sampled)
11
+ fast-json-stringify array x 1,813 ops/sec ±10.21% (71 runs sampled)
12
+ fast-json-stringify-uglified array x 2,106 ops/sec ±3.23% (83 runs sampled)
13
+ JSON.stringify long string x 12,933 ops/sec ±1.27% (87 runs sampled)
14
+ fast-json-stringify long string x 12,221 ops/sec ±3.31% (84 runs sampled)
15
+ fast-json-stringify-uglified long string x 13,256 ops/sec ±0.95% (92 runs sampled)
16
+ JSON.stringify short string x 4,878,641 ops/sec ±1.14% (90 runs sampled)
17
+ fast-json-stringify short string x 11,649,100 ops/sec ±0.98% (91 runs sampled)
18
+ fast-json-stringify-uglified short string x 11,877,661 ops/sec ±0.91% (90 runs sampled)
19
+ JSON.stringify obj x 1,705,377 ops/sec ±2.61% (87 runs sampled)
20
+ fast-json-stringify obj x 2,268,915 ops/sec ±1.39% (90 runs sampled)
21
+ fast-json-stringify-uglified obj x 2,243,341 ops/sec ±1.11% (89 runs sampled)
18
22
```
19
23
20
24
#### Table of contents:
@@ -28,6 +32,7 @@ fast-json-stringify obj x 4,976,369 ops/sec ±1.00% (89 runs sampled)
28
32
- <a href =" #additionalProperties " >` Additional Properties ` </a >
29
33
- <a href =" #ref " >` Reuse - $ref ` </a >
30
34
- <a href =" #long " >` Long integers ` </a >
35
+ - <a href =" #uglify " >` Uglify ` </a >
31
36
- <a href =" #acknowledgements " >` Acknowledgements ` </a >
32
37
- <a href =" #license " >` License ` </a >
33
38
@@ -319,6 +324,27 @@ const obj = {
319
324
console .log (stringify (obj)) // '{"id":18446744073709551615}'
320
325
```
321
326
327
+ <a name =" uglify " ></a >
328
+ #### Uglify
329
+ If you want to squeeze a little bit more performance out of the serialisation, at the cost of readability in the generated code, you can pass ` uglify: true ` as an option.
330
+ Note that you have to manually install ` uglify-es ` in order for it to work. Only version 3 is supported.
331
+ Example:
332
+ ``` javascript
333
+
334
+ const stringify = fastJson ({
335
+ title: ' Example Schema' ,
336
+ type: ' object' ,
337
+ properties: {
338
+ id: {
339
+ type: ' integer'
340
+ }
341
+ }
342
+ }, { uglify: true })
343
+
344
+ // stringify is now minified code
345
+ console .log (stringify ({ some: ' object' })) // '{"some":"object"}'
346
+ ```
347
+
322
348
<a name =" acknowledgements " ></a >
323
349
## Acknowledgements
324
350
0 commit comments