Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-json-stringify

Package Overview
Dependencies
Maintainers
2
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-json-stringify - npm Package Compare versions

Comparing version 2.4.2 to 2.5.0

test/side-effect.test.js

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

4

package.json
{
"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)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc