fast-json-stringify 2.7.10 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +4 -0
- package/.github/workflows/benchmark.yml +111 -0
- package/.github/workflows/ci.yml +7 -3
- package/README.md +33 -59
- package/bench.js +44 -0
- package/build-schema-validator.js +14 -9
- package/index.js +101 -62
- package/package.json +3 -4
- package/schema-validator.js +1132 -1748
- package/test/allof.test.js +53 -1
- package/test/bigint.test.js +76 -0
- package/test/debug-mode.test.js +26 -0
- package/test/if-then-else.test.js +16 -1
- package/test/integer.test.js +1 -10
- package/test/nullable.test.js +9 -4
- package/test/recursion.test.js +180 -0
- package/test/side-effect.test.js +39 -0
- package/test/types/tsconfig.json +3 -1
- package/test/typesArray.test.js +2 -2
- package/test/bigint.js +0 -74
- package/test/long.test.js +0 -85
package/test/long.test.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const test = require('tap').test
|
|
4
|
-
const validator = require('is-my-json-valid')
|
|
5
|
-
const Long = require('long')
|
|
6
|
-
const build = require('..')
|
|
7
|
-
|
|
8
|
-
test('render a long as JSON', (t) => {
|
|
9
|
-
t.plan(2)
|
|
10
|
-
|
|
11
|
-
const schema = {
|
|
12
|
-
title: 'long',
|
|
13
|
-
type: 'integer'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const validate = validator(schema)
|
|
17
|
-
const stringify = build(schema)
|
|
18
|
-
const output = stringify(Long.fromString('18446744073709551615', true))
|
|
19
|
-
|
|
20
|
-
t.equal(output, '18446744073709551615')
|
|
21
|
-
t.ok(validate(JSON.parse(output)), 'valid schema')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('render an object with long as JSON', (t) => {
|
|
25
|
-
t.plan(2)
|
|
26
|
-
|
|
27
|
-
const schema = {
|
|
28
|
-
title: 'object with long',
|
|
29
|
-
type: 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
id: {
|
|
32
|
-
type: 'integer'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const validate = validator(schema)
|
|
38
|
-
const stringify = build(schema)
|
|
39
|
-
const output = stringify({
|
|
40
|
-
id: Long.fromString('18446744073709551615', true)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
t.equal(output, '{"id":18446744073709551615}')
|
|
44
|
-
t.ok(validate(JSON.parse(output)), 'valid schema')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('render an array with long as JSON', (t) => {
|
|
48
|
-
t.plan(2)
|
|
49
|
-
|
|
50
|
-
const schema = {
|
|
51
|
-
title: 'array with long',
|
|
52
|
-
type: 'array',
|
|
53
|
-
items: {
|
|
54
|
-
type: 'integer'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const validate = validator(schema)
|
|
59
|
-
const stringify = build(schema)
|
|
60
|
-
const output = stringify([Long.fromString('18446744073709551615', true)])
|
|
61
|
-
|
|
62
|
-
t.equal(output, '[18446744073709551615]')
|
|
63
|
-
t.ok(validate(JSON.parse(output)), 'valid schema')
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test('render an object with a long additionalProperty as JSON', (t) => {
|
|
67
|
-
t.plan(2)
|
|
68
|
-
|
|
69
|
-
const schema = {
|
|
70
|
-
title: 'object with long',
|
|
71
|
-
type: 'object',
|
|
72
|
-
additionalProperties: {
|
|
73
|
-
type: 'integer'
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const validate = validator(schema)
|
|
78
|
-
const stringify = build(schema)
|
|
79
|
-
const output = stringify({
|
|
80
|
-
num: Long.fromString('18446744073709551615', true)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
t.equal(output, '{"num":18446744073709551615}')
|
|
84
|
-
t.ok(validate(JSON.parse(output)), 'valid schema')
|
|
85
|
-
})
|