fast-json-stringify
Advanced tools
Comparing version 1.2.1 to 1.3.0
16
index.js
@@ -673,8 +673,18 @@ 'use strict' | ||
var nestedResult = nested(laterCode, name, key, tempSchema, externalSchema, fullSchema, subKey) | ||
code += ` | ||
${index === 0 ? 'if' : 'else if'}(ajv.validate(${require('util').inspect(tempSchema, {depth: null})}, obj${accessor})) | ||
if (type === 'string') { | ||
code += ` | ||
${index === 0 ? 'if' : 'else if'}(obj${accessor} instanceof Date || ajv.validate(${require('util').inspect(tempSchema, {depth: null})}, obj${accessor})) | ||
${nestedResult.code} | ||
` | ||
} else { | ||
code += ` | ||
${index === 0 ? 'if' : 'else if'}(ajv.validate(${require('util').inspect(tempSchema, {depth: null})}, obj${accessor})) | ||
${nestedResult.code} | ||
` | ||
` | ||
} | ||
laterCode = nestedResult.laterCode | ||
}) | ||
code += ` | ||
else json+= null | ||
` | ||
} else { | ||
@@ -681,0 +691,0 @@ throw new Error(`${type} unsupported`) |
{ | ||
"name": "fast-json-stringify", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Stringify your JSON at max speed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -185,1 +185,20 @@ 'use strict' | ||
}) | ||
test('string type array can handle dates', (t) => { | ||
t.plan(1) | ||
const schema = { | ||
type: 'object', | ||
properties: { | ||
date: { type: ['string'] } | ||
} | ||
} | ||
const stringify = build(schema) | ||
try { | ||
const value = stringify({ | ||
date: new Date('2018-04-20T07:52:31.017Z') | ||
}) | ||
t.is(value, '{"date":"2018-04-20T07:52:31.017Z"}') | ||
} catch (e) { | ||
t.fail() | ||
} | ||
}) |
Sorry, the diff of this file is not supported yet
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
75285
2719