fast-json-stringify 3.0.2 → 3.0.3

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,16 +1,13 @@
1
1
  version: 2
2
2
  updates:
3
- - package-ecosystem: github-actions
4
- directory: '/'
5
- ignore:
6
- - dependency-name: "actions/*"
7
- update-types:
8
- ["version-update:semver-minor", "version-update:semver-patch"]
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
9
5
  schedule:
10
- interval: daily
6
+ interval: "monthly"
11
7
  open-pull-requests-limit: 10
12
- - package-ecosystem: npm
13
- directory: '/'
8
+
9
+ - package-ecosystem: "npm"
10
+ directory: "/"
14
11
  schedule:
15
- interval: daily
12
+ interval: "weekly"
16
13
  open-pull-requests-limit: 10
package/index.js CHANGED
@@ -849,7 +849,7 @@ function addIfThenElse (location, name) {
849
849
  ajvInstance.addSchema(i, schemaKey)
850
850
 
851
851
  code += `
852
- valid = ajv.validate(${JSON.stringify(schemaKey)}, obj)
852
+ valid = ajv.validate("${schemaKey}", obj)
853
853
  if (valid) {
854
854
  `
855
855
  if (merged.if && merged.then) {
@@ -909,7 +909,7 @@ function buildObject (location, code, name) {
909
909
  `
910
910
  }
911
911
 
912
- if (objectReferenceSerializersMap.has(schema)) {
912
+ if (objectReferenceSerializersMap.has(schema) && objectReferenceSerializersMap.get(schema) !== name) {
913
913
  code += `
914
914
  return ${objectReferenceSerializersMap.get(schema)}(input)
915
915
  }
@@ -1203,7 +1203,7 @@ function nested (laterCode, name, key, location, subKey, isArray) {
1203
1203
  ajvInstance.addSchema(location.schema, schemaKey)
1204
1204
 
1205
1205
  code += `
1206
- ${index === 0 ? 'if' : 'else if'}(ajv.validate(${JSON.stringify(schemaKey)}, ${testValue}))
1206
+ ${index === 0 ? 'if' : 'else if'}(ajv.validate("${schemaKey}", ${testValue}))
1207
1207
  ${nestedResult.code}
1208
1208
  `
1209
1209
  laterCode = nestedResult.laterCode
@@ -1224,7 +1224,7 @@ function nested (laterCode, name, key, location, subKey, isArray) {
1224
1224
  ajvInstance.addSchema(location.schema, schemaKey)
1225
1225
 
1226
1226
  code += `
1227
- ${index === 0 ? 'if' : 'else if'}(ajv.validate(${JSON.stringify(schemaKey)}, ${testValue}))
1227
+ ${index === 0 ? 'if' : 'else if'}(ajv.validate("${schemaKey}", ${testValue}))
1228
1228
  ${nestedResult.code}
1229
1229
  `
1230
1230
  laterCode = nestedResult.laterCode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-json-stringify",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Stringify your JSON at max speed",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "homepage": "https://github.com/fastify/fast-json-stringify#readme",
32
32
  "devDependencies": {
33
+ "@sinclair/typebox": "^0.23.3",
33
34
  "benchmark": "^2.1.4",
34
35
  "compile-json-stringify": "^0.1.2",
35
36
  "is-my-json-valid": "^2.20.0",
@@ -0,0 +1,36 @@
1
+ 'use strict'
2
+
3
+ const test = require('tap').test
4
+ const build = require('..')
5
+
6
+ test('nested object in pattern properties for typebox', (t) => {
7
+ const { Type } = require('@sinclair/typebox')
8
+
9
+ t.plan(1)
10
+
11
+ const nestedSchema = Type.Object({
12
+ nestedKey1: Type.String()
13
+ })
14
+
15
+ const RootSchema = Type.Object({
16
+ key1: Type.Record(Type.String(), nestedSchema),
17
+ key2: Type.Record(Type.String(), nestedSchema)
18
+ })
19
+
20
+ const schema = RootSchema
21
+ const stringify = build(schema)
22
+
23
+ const value = stringify({
24
+ key1: {
25
+ nestedKey: {
26
+ nestedKey1: 'value1'
27
+ }
28
+ },
29
+ key2: {
30
+ nestedKey: {
31
+ nestedKey1: 'value2'
32
+ }
33
+ }
34
+ })
35
+ t.equal(value, '{"key1":{"nestedKey":{"nestedKey1":"value1"}},"key2":{"nestedKey":{"nestedKey1":"value2"}}}')
36
+ })