fast-json-stringify 5.11.1 → 5.13.0

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.
package/README.md CHANGED
@@ -630,6 +630,24 @@ integer-like values, such as:
630
630
  - `'2e4'` - _note this will be converted to `2`, not `20000`_
631
631
  - `1.5` - _note this will be converted to `1`_
632
632
 
633
+ <a name="unsafe"></a>
634
+ #### Unsafe string
635
+ By default, the library escapes all strings. With the 'unsafe' format, the string isn't escaped. This has a potentially dangerous security issue. You can use it only if you are sure that your data doesn't need escaping. The advantage is a significant performance improvement.
636
+
637
+ Example:
638
+ ```javascript
639
+ const stringify = fastJson({
640
+ title: 'Example Schema',
641
+ type: 'object',
642
+ properties: {
643
+ 'code': {
644
+ type: 'string',
645
+ format 'unsafe'
646
+ }
647
+ }
648
+ })
649
+ ```
650
+
633
651
  ##### Benchmarks
634
652
 
635
653
  For reference, here goes some benchmarks for comparison over the three
@@ -47,6 +47,14 @@ const benchmarks = [
47
47
  },
48
48
  input: 'hello world'
49
49
  },
50
+ {
51
+ name: 'unsafe short string',
52
+ schema: {
53
+ type: 'string',
54
+ format: 'unsafe'
55
+ },
56
+ input: 'hello world'
57
+ },
50
58
  {
51
59
  name: 'short string with double quote',
52
60
  schema: {
@@ -61,6 +69,14 @@ const benchmarks = [
61
69
  },
62
70
  input: longSimpleString
63
71
  },
72
+ {
73
+ name: 'unsafe long string without double quotes',
74
+ schema: {
75
+ type: 'string',
76
+ format: 'unsafe'
77
+ },
78
+ input: longSimpleString
79
+ },
64
80
  {
65
81
  name: 'long string',
66
82
  schema: {
@@ -68,6 +84,14 @@ const benchmarks = [
68
84
  },
69
85
  input: longString
70
86
  },
87
+ {
88
+ name: 'unsafe long string',
89
+ schema: {
90
+ type: 'string',
91
+ format: 'unsafe'
92
+ },
93
+ input: longString
94
+ },
71
95
  {
72
96
  name: 'number',
73
97
  schema: {