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.7.2 to 2.7.3

78

index.js

@@ -23,4 +23,5 @@ 'use strict'

json += ','
} else {
addComma = true
}
addComma = true
`

@@ -1251,35 +1252,48 @@

sortedTypes.forEach((type, index) => {
const statement = index === 0 ? 'if' : 'else if'
const tempSchema = Object.assign({}, schema, { type })
const nestedResult = nested(laterCode, name, key, mergeLocation(location, { schema: tempSchema }), subKey, isArray)
if (type === 'string') {
code += `
${index === 0 ? 'if' : 'else if'}(obj${accessor} === null || typeof obj${accessor} === "${type}" || obj${accessor} instanceof Date || typeof obj${accessor}.toISOString === "function" || obj${accessor} instanceof RegExp || (typeof obj${accessor} === "object" && Object.hasOwnProperty.call(obj${accessor}, "toString")))
${nestedResult.code}
`
} else if (type === 'null') {
code += `
${index === 0 ? 'if' : 'else if'}(obj${accessor} == null)
${nestedResult.code}
`
} else if (type === 'array') {
code += `
${index === 0 ? 'if' : 'else if'}(Array.isArray(obj${accessor}))
${nestedResult.code}
`
} else if (type === 'integer') {
code += `
${index === 0 ? 'if' : 'else if'}(Number.isInteger(obj${accessor}) || obj${accessor} === null)
${nestedResult.code}
`
} else if (type === 'number') {
code += `
${index === 0 ? 'if' : 'else if'}(isNaN(obj${accessor}) === false)
${nestedResult.code}
`
} else {
code += `
${index === 0 ? 'if' : 'else if'}(typeof obj${accessor} === "${type}")
${nestedResult.code}
`
switch (type) {
case 'string': {
code += `
${statement}(obj${accessor} === null || typeof obj${accessor} === "${type}" || obj${accessor} instanceof Date || typeof obj${accessor}.toISOString === "function" || obj${accessor} instanceof RegExp || (typeof obj${accessor} === "object" && Object.hasOwnProperty.call(obj${accessor}, "toString")))
${nestedResult.code}
`
break
}
case 'null': {
code += `
${statement}(obj${accessor} == null)
${nestedResult.code}
`
break
}
case 'array': {
code += `
${statement}(Array.isArray(obj${accessor}))
${nestedResult.code}
`
break
}
case 'integer': {
code += `
${statement}(Number.isInteger(obj${accessor}) || obj${accessor} === null)
${nestedResult.code}
`
break
}
case 'number': {
code += `
${statement}(isNaN(obj${accessor}) === false)
${nestedResult.code}
`
break
}
default: {
code += `
${statement}(typeof obj${accessor} === "${type}")
${nestedResult.code}
`
break
}
}

@@ -1286,0 +1300,0 @@ laterCode = nestedResult.laterCode

{
"name": "fast-json-stringify",
"version": "2.7.2",
"version": "2.7.3",
"description": "Stringify your JSON at max speed",

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

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