fast-json-stringify
Advanced tools
Comparing version 2.2.7 to 2.2.8
@@ -1196,3 +1196,3 @@ 'use strict' | ||
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) | ||
${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} | ||
@@ -1199,0 +1199,0 @@ ` |
{ | ||
"name": "fast-json-stringify", | ||
"version": "2.2.7", | ||
"version": "2.2.8", | ||
"description": "Stringify your JSON at max speed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -368,1 +368,53 @@ 'use strict' | ||
}) | ||
test('object that is simultaneously a string and a json', (t) => { | ||
t.plan(2) | ||
const schema = { | ||
type: 'object', | ||
properties: { | ||
simultaneously: { | ||
type: ['string', 'object'], | ||
properties: { | ||
foo: { type: 'string' } | ||
} | ||
} | ||
} | ||
} | ||
const likeObjectId = { | ||
toString () { return 'hello' } | ||
} | ||
const stringify = build(schema) | ||
const valueStr = stringify({ simultaneously: likeObjectId }) | ||
t.is(valueStr, '{"simultaneously":"hello"}') | ||
const valueObj = stringify({ simultaneously: { foo: likeObjectId } }) | ||
t.is(valueObj, '{"simultaneously":{"foo":"hello"}}') | ||
}) | ||
test('object that is simultaneously a string and a json switched', (t) => { | ||
t.plan(2) | ||
const schema = { | ||
type: 'object', | ||
properties: { | ||
simultaneously: { | ||
type: ['object', 'string'], | ||
properties: { | ||
foo: { type: 'string' } | ||
} | ||
} | ||
} | ||
} | ||
const likeObjectId = { | ||
toString () { return 'hello' } | ||
} | ||
const stringify = build(schema) | ||
const valueStr = stringify({ simultaneously: likeObjectId }) | ||
t.is(valueStr, '{"simultaneously":{}}') | ||
const valueObj = stringify({ simultaneously: { foo: likeObjectId } }) | ||
t.is(valueObj, '{"simultaneously":{"foo":"hello"}}') | ||
}) |
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
309732
9302