fast-json-stringify
Advanced tools
Comparing version 2.4.2 to 2.5.0
22
index.js
@@ -7,2 +7,4 @@ 'use strict' | ||
const merge = require('deepmerge') | ||
const clone = require('rfdc')({ proto: true }) | ||
const fjsCloned = Symbol('fast-json-stringify.cloned') | ||
@@ -446,2 +448,7 @@ const validate = require('./schema-validator') | ||
` | ||
} else if (type === undefined) { | ||
code += ` | ||
${addComma} | ||
json += $asString(keys[i]) + ':' + $asAny(obj[keys[i]]) | ||
` | ||
} else { | ||
@@ -540,2 +547,7 @@ code += ` | ||
` | ||
} else if (type === undefined) { | ||
code += ` | ||
${addComma} | ||
json += $asString(keys[i]) + ':' + $asAny(obj[keys[i]]) | ||
` | ||
} else { | ||
@@ -1065,2 +1077,8 @@ code += ` | ||
function dereferenceOfRefs (location, type) { | ||
if (!location.schema[fjsCloned]) { | ||
const schemaClone = clone(location.schema) | ||
schemaClone[fjsCloned] = true | ||
location.schema = schemaClone | ||
} | ||
const schema = location.schema | ||
@@ -1190,3 +1208,3 @@ const locations = [] | ||
code += ` | ||
${index === 0 ? 'if' : 'else if'}(ajv.validate(${require('util').inspect(location.schema, { depth: null, maxArrayLength: null })}, obj${accessor})) | ||
${index === 0 ? 'if' : 'else if'}(ajv.validate(${JSON.stringify(location.schema)}, obj${accessor})) | ||
${nestedResult.code} | ||
@@ -1205,3 +1223,3 @@ ` | ||
code += ` | ||
if(ajv.validate(${require('util').inspect(schema, { depth: null })}, obj${accessor})) | ||
if(ajv.validate(${require('util').inspect(schema, { depth: null, showHidden: false })}, obj${accessor})) | ||
json += '${JSON.stringify(schema.const)}' | ||
@@ -1208,0 +1226,0 @@ else |
{ | ||
"name": "fast-json-stringify", | ||
"version": "2.4.2", | ||
"version": "2.5.0", | ||
"description": "Stringify your JSON at max speed", | ||
@@ -9,2 +9,3 @@ "main": "index.js", | ||
"benchmark": "node bench.js", | ||
"lint:fix": "standard --fix", | ||
"test:lint": "standard", | ||
@@ -49,2 +50,3 @@ "test:typescript": "tsc --project ./test/types/tsconfig.json", | ||
"deepmerge": "^4.2.2", | ||
"rfdc": "^1.2.0", | ||
"string-similarity": "^4.0.1" | ||
@@ -51,0 +53,0 @@ }, |
@@ -164,2 +164,27 @@ 'use strict' | ||
test('additionalProperties with empty schema', (t) => { | ||
t.plan(1) | ||
const stringify = build({ | ||
type: 'object', | ||
additionalProperties: {} | ||
}) | ||
const obj = { a: 1, b: true, c: null } | ||
t.equal('{"a":1,"b":true,"c":null}', stringify(obj)) | ||
}) | ||
test('additionalProperties with nested empty schema', (t) => { | ||
t.plan(1) | ||
const stringify = build({ | ||
type: 'object', | ||
properties: { | ||
data: { type: 'object', additionalProperties: {} } | ||
}, | ||
required: ['data'] | ||
}) | ||
const obj = { data: { a: 1, b: true, c: null } } | ||
t.equal('{"data":{"a":1,"b":true,"c":null}}', stringify(obj)) | ||
}) | ||
test('nested additionalProperties', (t) => { | ||
@@ -166,0 +191,0 @@ t.plan(1) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
323919
61
9720
4
+ Addedrfdc@^1.2.0
+ Addedrfdc@1.4.1(transitive)