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.6.0 to 2.7.0

14

index.js

@@ -983,5 +983,5 @@ 'use strict'

let result = { code: '', laterCode: '' }
const accessor = '[i]'
if (Array.isArray(schema.items)) {
result = schema.items.reduce((res, item, i) => {
const accessor = '[i]'
const tmpRes = nested(laterCode, name, accessor, mergeLocation(location, { schema: item }), i, true)

@@ -998,2 +998,12 @@ const condition = `i === ${i} && ${buildArrayTypeCondition(item.type, accessor)}`

}, result)
if (schema.additionalItems) {
const tmpRes = nested(laterCode, name, accessor, mergeLocation(location, { schema: schema.items }), undefined, true)
result.code += `
else if (i >= ${schema.items.length}) {
${tmpRes.code}
}
`
}
result.code += `

@@ -1005,3 +1015,3 @@ else {

} else {
result = nested(laterCode, name, '[i]', mergeLocation(location, { schema: schema.items }), undefined, true)
result = nested(laterCode, name, accessor, mergeLocation(location, { schema: schema.items }), undefined, true)
}

@@ -1008,0 +1018,0 @@

2

package.json
{
"name": "fast-json-stringify",
"version": "2.6.0",
"version": "2.7.0",
"description": "Stringify your JSON at max speed",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -213,2 +213,65 @@ 'use strict'

test('array items is a list of schema and additionalItems is true, just the described item is validated', (t) => {
t.plan(1)
const schema = {
type: 'object',
properties: {
foo: {
type: 'array',
items: [
{
type: 'string'
}
],
additionalItems: true
}
}
}
const stringify = build(schema)
const result = stringify({
foo: [
'foo',
'bar',
1
]
})
t.equal(result, '{"foo":["foo","bar",1]}')
})
test('array items is a list of schema and additionalItems is false', (t) => {
t.plan(1)
const schema = {
type: 'object',
properties: {
foo: {
type: 'array',
items: [
{
type: 'string'
}
],
additionalItems: false
}
}
}
const stringify = build(schema)
try {
stringify({
foo: [
'foo',
'bar'
]
})
t.fail()
} catch (error) {
t.ok(/does not match schema definition./.test(error.message))
}
})
// https://github.com/fastify/fast-json-stringify/issues/279

@@ -215,0 +278,0 @@ test('object array with anyOf and symbol', (t) => {

Sorry, the diff of this file is not supported yet

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