fast-json-stringify
Advanced tools
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", |
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
331626
10009