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 0.13.1 to 0.14.0

46

index.js
'use strict'
var fastSafeStringify = require('fast-safe-stringify')
var Ajv = require('ajv')

@@ -90,6 +91,15 @@ var uglify = null

var dependencies = []
var dependenciesName = []
if (hasAdditionalPropertiesTrue(schema)) {
return (new Function('fastSafeStringify', code))(fastSafeStringify)
dependencies.push(fastSafeStringify)
dependenciesName.push('fastSafeStringify')
}
return (new Function(code))()
if (hasAnyOf(schema)) {
dependencies.push(new Ajv())
dependenciesName.push('ajv')
}
dependenciesName.push(code)
return (Function.apply(null, dependenciesName).apply(null, dependencies))
}

@@ -111,2 +121,16 @@

function hasAnyOf (schema) {
if ('anyOf' in schema) { return true }
var objectKeys = Object.keys(schema)
for (var i = 0; i < objectKeys.length; i++) {
var value = schema[objectKeys[i]]
if (typeof value === 'object') {
if (hasAnyOf(value)) { return true }
}
}
return false
}
function $asNull () {

@@ -522,5 +546,19 @@ return 'null'

code += `
json += ${funcName}(obj${accessor})
`
json += ${funcName}(obj${accessor})
`
break
case undefined:
if ('anyOf' in schema) {
schema.anyOf.forEach((s, index) => {
code += `
${index === 0 ? 'if' : 'else if'}(ajv.validate(${require('util').inspect(s, {depth: null})}, obj${accessor}))
${nested(laterCode, name, key, s, externalSchema, fullSchema, subKey).code}
`
})
code += `
else json+= null
`
} else throw new Error(`${schema} unsupported`)
break
default:

@@ -527,0 +565,0 @@ throw new Error(`${type} unsupported`)

4

package.json
{
"name": "fast-json-stringify",
"version": "0.13.1",
"version": "0.14.0",
"description": "Stringify your JSON at max speed",
"main": "index.js",
"scripts": {
"benchmark": "node bench.js",
"test": "standard && tap test/*.test.js"

@@ -36,4 +37,5 @@ },

"dependencies": {
"ajv": "^5.2.3",
"fast-safe-stringify": "^1.2.0"
}
}
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