fast-json-stringify
Advanced tools
Comparing version 2.7.5 to 2.7.6
@@ -257,5 +257,4 @@ 'use strict' | ||
} else { | ||
// if the output is NaN the type is coerced to int 0 | ||
/* eslint no-undef: "off" */ | ||
return $asNumber(parseInteger(i) || 0) | ||
return $asNumber(parseInteger(i)) | ||
} | ||
@@ -262,0 +261,0 @@ } |
{ | ||
"name": "fast-json-stringify", | ||
"version": "2.7.5", | ||
"version": "2.7.6", | ||
"description": "Stringify your JSON at max speed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -79,3 +79,3 @@ 'use strict' | ||
test('render a date in a string when format is time as HH:mm:ss', (t) => { | ||
test('render a date in a string when format is time as kk:mm:ss', (t) => { | ||
t.plan(3) | ||
@@ -82,0 +82,0 @@ |
@@ -9,2 +9,3 @@ 'use strict' | ||
const build = proxyquire('..', { long: null }) | ||
const ROUNDING_TYPES = ['ceil', 'floor', 'round'] | ||
@@ -44,2 +45,6 @@ test('render an integer as JSON', (t) => { | ||
{ input: 5.0, output: '5' }, | ||
{ input: null, output: '0' }, | ||
{ input: 0, output: '0' }, | ||
{ input: 0.0, output: '0' }, | ||
{ input: 42, output: '42' }, | ||
{ input: 1.99999, output: '1' }, | ||
@@ -143,3 +148,3 @@ { input: -45.05, output: '-45' }, | ||
test('should round interger object parameter ', t => { | ||
test('should round integer object parameter', t => { | ||
t.plan(2) | ||
@@ -155,1 +160,27 @@ | ||
}) | ||
test('should not stringify a property if it does not exist', t => { | ||
t.plan(2) | ||
const schema = { title: 'Example Schema', type: 'object', properties: { age: { type: 'integer' } } } | ||
const validate = validator(schema) | ||
const stringify = build(schema) | ||
const output = stringify({}) | ||
t.equal(output, '{}') | ||
t.ok(validate(JSON.parse(output)), 'valid schema') | ||
}) | ||
ROUNDING_TYPES.forEach((rounding) => { | ||
test(`should not stringify a property if it does not exist (rounding: ${rounding})`, t => { | ||
t.plan(2) | ||
const schema = { type: 'object', properties: { magic: { type: 'integer' } } } | ||
const validate = validator(schema) | ||
const stringify = build(schema, { rounding }) | ||
const output = stringify({}) | ||
t.equal(output, '{}') | ||
t.ok(validate(JSON.parse(output)), 'valid schema') | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
334315
10090