fast-json-stringify 4.2.0 → 5.0.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/ajv.js +1 -1
- package/index.js +146 -274
- package/package.json +4 -8
- package/serializer.js +17 -22
- package/test/allof.test.js +9 -7
- package/test/ref.test.js +610 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-json-stringify",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Stringify your JSON at max speed",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"benchmark": "^2.1.4",
|
|
38
38
|
"chalk": "^4.1.2",
|
|
39
39
|
"compile-json-stringify": "^0.1.2",
|
|
40
|
-
"inquirer": "^
|
|
40
|
+
"inquirer": "^9.0.0",
|
|
41
41
|
"is-my-json-valid": "^2.20.0",
|
|
42
42
|
"luxon": "^2.4.0",
|
|
43
43
|
"pre-commit": "^1.2.2",
|
|
@@ -53,12 +53,8 @@
|
|
|
53
53
|
"ajv": "^8.10.0",
|
|
54
54
|
"ajv-formats": "^2.1.1",
|
|
55
55
|
"deepmerge": "^4.2.2",
|
|
56
|
-
"fast-uri": "^2.
|
|
57
|
-
"rfdc": "^1.2.0"
|
|
58
|
-
"string-similarity": "^4.0.1"
|
|
59
|
-
},
|
|
60
|
-
"engines": {
|
|
61
|
-
"node": ">= 10.0.0"
|
|
56
|
+
"fast-uri": "^2.1.0",
|
|
57
|
+
"rfdc": "^1.2.0"
|
|
62
58
|
},
|
|
63
59
|
"standard": {
|
|
64
60
|
"ignore": [
|
package/serializer.js
CHANGED
|
@@ -67,44 +67,44 @@ module.exports = class Serializer {
|
|
|
67
67
|
return bool === null ? 'null' : this.asBoolean(bool)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
asDatetime (date
|
|
71
|
-
const quotes =
|
|
70
|
+
asDatetime (date) {
|
|
71
|
+
const quotes = '"'
|
|
72
72
|
if (date instanceof Date) {
|
|
73
73
|
return quotes + date.toISOString() + quotes
|
|
74
74
|
}
|
|
75
|
-
return this.asString(date
|
|
75
|
+
return this.asString(date)
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
asDatetimeNullable (date
|
|
79
|
-
return date === null ? 'null' : this.asDatetime(date
|
|
78
|
+
asDatetimeNullable (date) {
|
|
79
|
+
return date === null ? 'null' : this.asDatetime(date)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
asDate (date
|
|
83
|
-
const quotes =
|
|
82
|
+
asDate (date) {
|
|
83
|
+
const quotes = '"'
|
|
84
84
|
if (date instanceof Date) {
|
|
85
85
|
return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(0, 10) + quotes
|
|
86
86
|
}
|
|
87
|
-
return this.asString(date
|
|
87
|
+
return this.asString(date)
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
asDateNullable (date
|
|
91
|
-
return date === null ? 'null' : this.asDate(date
|
|
90
|
+
asDateNullable (date) {
|
|
91
|
+
return date === null ? 'null' : this.asDate(date)
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
asTime (date
|
|
95
|
-
const quotes =
|
|
94
|
+
asTime (date) {
|
|
95
|
+
const quotes = '"'
|
|
96
96
|
if (date instanceof Date) {
|
|
97
97
|
return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(11, 19) + quotes
|
|
98
98
|
}
|
|
99
|
-
return this.asString(date
|
|
99
|
+
return this.asString(date)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
asTimeNullable (date
|
|
103
|
-
return date === null ? 'null' : this.asTime(date
|
|
102
|
+
asTimeNullable (date) {
|
|
103
|
+
return date === null ? 'null' : this.asTime(date)
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
asString (str
|
|
107
|
-
const quotes =
|
|
106
|
+
asString (str) {
|
|
107
|
+
const quotes = '"'
|
|
108
108
|
if (str instanceof Date) {
|
|
109
109
|
return quotes + str.toISOString() + quotes
|
|
110
110
|
} else if (str === null) {
|
|
@@ -114,11 +114,6 @@ module.exports = class Serializer {
|
|
|
114
114
|
} else if (typeof str !== 'string') {
|
|
115
115
|
str = str.toString()
|
|
116
116
|
}
|
|
117
|
-
// If we skipQuotes it means that we are using it as test
|
|
118
|
-
// no need to test the string length for the render
|
|
119
|
-
if (skipQuotes) {
|
|
120
|
-
return str
|
|
121
|
-
}
|
|
122
117
|
|
|
123
118
|
if (str.length < 42) {
|
|
124
119
|
return this.asStringSmall(str)
|
package/test/allof.test.js
CHANGED
|
@@ -402,12 +402,14 @@ test('object with external $refs in allOf', (t) => {
|
|
|
402
402
|
}
|
|
403
403
|
},
|
|
404
404
|
second: {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
405
|
+
definitions: {
|
|
406
|
+
id2: {
|
|
407
|
+
$id: '#id2',
|
|
408
|
+
type: 'object',
|
|
409
|
+
properties: {
|
|
410
|
+
id2: {
|
|
411
|
+
type: 'integer'
|
|
412
|
+
}
|
|
411
413
|
}
|
|
412
414
|
}
|
|
413
415
|
}
|
|
@@ -422,7 +424,7 @@ test('object with external $refs in allOf', (t) => {
|
|
|
422
424
|
$ref: 'first#/definitions/id1'
|
|
423
425
|
},
|
|
424
426
|
{
|
|
425
|
-
$ref: 'second
|
|
427
|
+
$ref: 'second#/definitions/id2'
|
|
426
428
|
}
|
|
427
429
|
]
|
|
428
430
|
}
|