fast-json-stringify 5.0.6 → 5.3.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.
@@ -11,15 +11,15 @@ jobs:
11
11
  permissions:
12
12
  contents: read
13
13
  outputs:
14
- PR-BENCH-12: ${{ steps.benchmark-pr.outputs.BENCH_RESULT12 }}
15
14
  PR-BENCH-14: ${{ steps.benchmark-pr.outputs.BENCH_RESULT14 }}
16
15
  PR-BENCH-16: ${{ steps.benchmark-pr.outputs.BENCH_RESULT16 }}
17
- MAIN-BENCH-12: ${{ steps.benchmark-main.outputs.BENCH_RESULT12 }}
16
+ PR-BENCH-18: ${{ steps.benchmark-pr.outputs.BENCH_RESULT18 }}
18
17
  MAIN-BENCH-14: ${{ steps.benchmark-main.outputs.BENCH_RESULT14 }}
19
18
  MAIN-BENCH-16: ${{ steps.benchmark-main.outputs.BENCH_RESULT16 }}
19
+ MAIN-BENCH-18: ${{ steps.benchmark-main.outputs.BENCH_RESULT18 }}
20
20
  strategy:
21
21
  matrix:
22
- node-version: [12, 14, 16]
22
+ node-version: [14, 16, 18]
23
23
  steps:
24
24
  - uses: actions/checkout@v3
25
25
  with:
@@ -75,38 +75,38 @@ jobs:
75
75
  with:
76
76
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77
77
  message: |
78
- **Node**: 12
78
+ **Node**: 14
79
79
  **PR**:
80
80
  ```
81
- ${{ needs.benchmark.outputs.PR-BENCH-12 }}
81
+ ${{ needs.benchmark.outputs.PR-BENCH-14 }}
82
82
  ```
83
83
  **MAIN**:
84
84
  ```
85
- ${{ needs.benchmark.outputs.MAIN-BENCH-12 }}
85
+ ${{ needs.benchmark.outputs.MAIN-BENCH-14 }}
86
86
  ```
87
87
 
88
88
  ---
89
89
 
90
- **Node**: 14
90
+ **Node**: 16
91
91
  **PR**:
92
92
  ```
93
- ${{ needs.benchmark.outputs.PR-BENCH-14 }}
93
+ ${{ needs.benchmark.outputs.PR-BENCH-16 }}
94
94
  ```
95
95
  **MAIN**:
96
96
  ```
97
- ${{ needs.benchmark.outputs.MAIN-BENCH-14 }}
97
+ ${{ needs.benchmark.outputs.MAIN-BENCH-16 }}
98
98
  ```
99
99
 
100
100
  ---
101
101
 
102
- **Node**: 16
102
+ **Node**: 18
103
103
  **PR**:
104
104
  ```
105
- ${{ needs.benchmark.outputs.PR-BENCH-16 }}
105
+ ${{ needs.benchmark.outputs.PR-BENCH-18 }}
106
106
  ```
107
107
  **MAIN**:
108
108
  ```
109
- ${{ needs.benchmark.outputs.MAIN-BENCH-16 }}
109
+ ${{ needs.benchmark.outputs.MAIN-BENCH-18 }}
110
110
  ```
111
111
 
112
112
  - uses: actions-ecosystem/action-remove-labels@v1
@@ -13,3 +13,5 @@ on:
13
13
  jobs:
14
14
  test:
15
15
  uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
16
+ with:
17
+ license-check: true
@@ -213,6 +213,60 @@ const benchmarks = [
213
213
  n5: 42,
214
214
  b5: true
215
215
  }
216
+ },
217
+ {
218
+ name: 'object with const string property',
219
+ schema: {
220
+ type: 'object',
221
+ properties: {
222
+ a: { const: 'const string' }
223
+ }
224
+ },
225
+ input: { a: 'const string' }
226
+ },
227
+ {
228
+ name: 'object with const number property',
229
+ schema: {
230
+ type: 'object',
231
+ properties: {
232
+ a: { const: 1 }
233
+ }
234
+ },
235
+ input: { a: 1 }
236
+ },
237
+ {
238
+ name: 'object with const bool property',
239
+ schema: {
240
+ type: 'object',
241
+ properties: {
242
+ a: { const: true }
243
+ }
244
+ },
245
+ input: { a: true }
246
+ },
247
+ {
248
+ name: 'object with const object property',
249
+ schema: {
250
+ type: 'object',
251
+ properties: {
252
+ foo: { const: { bar: 'baz' } }
253
+ }
254
+ },
255
+ input: {
256
+ foo: { bar: 'baz' }
257
+ }
258
+ },
259
+ {
260
+ name: 'object with const null property',
261
+ schema: {
262
+ type: 'object',
263
+ properties: {
264
+ foo: { const: null }
265
+ }
266
+ },
267
+ input: {
268
+ foo: null
269
+ }
216
270
  }
217
271
  ]
218
272
 
@@ -23,4 +23,4 @@ const validationCode = standaloneCode(ajv, validate)
23
23
 
24
24
  const moduleCode = `/* CODE GENERATED BY '${path.basename(__filename)}' DO NOT EDIT! */\n${validationCode}`
25
25
 
26
- fs.writeFileSync(path.join(__dirname, 'schema-validator.js'), moduleCode)
26
+ fs.writeFileSync(path.join(__dirname, '../lib/schema-validator.js'), moduleCode)
@@ -1,4 +1,4 @@
1
- const fastJson = require('.')
1
+ const fastJson = require('..')
2
2
  const stringify = fastJson({
3
3
  title: 'Example Schema',
4
4
  type: 'object',
@@ -2,7 +2,7 @@
2
2
 
3
3
  const http = require('http')
4
4
 
5
- const stringify = require('.')({
5
+ const stringify = require('fast-json-stringify')({
6
6
  type: 'object',
7
7
  properties: {
8
8
  hello: {
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import Ajv, { Options as AjvOptions } from "ajv"
2
+
2
3
  declare namespace build {
3
4
  interface BaseSchema {
4
5
  /**
@@ -189,13 +190,13 @@ interface StandaloneOption extends build.Options {
189
190
  declare function build(schema: build.AnySchema, options: DebugOption): { code: string, ajv: Ajv };
190
191
  declare function build(schema: build.AnySchema, options: DeprecateDebugOption): { code: string, ajv: Ajv };
191
192
  declare function build(schema: build.AnySchema, options: StandaloneOption): string;
192
- declare function build(schema: build.AnySchema, options?: build.Options): (doc: any) => any;
193
- declare function build(schema: build.StringSchema, options?: build.Options): (doc: string) => string;
194
- declare function build(schema: build.IntegerSchema | build.NumberSchema, options?: build.Options): (doc: number) => string;
195
- declare function build(schema: build.NullSchema, options?: build.Options): (doc: null) => "null";
196
- declare function build(schema: build.BooleanSchema, options?: build.Options): (doc: boolean) => string;
197
- declare function build(schema: build.ArraySchema | build.TupleSchema, options?: build.Options): (doc: any[]) => string;
198
- declare function build(schema: build.ObjectSchema, options?: build.Options): (doc: object) => string;
199
- declare function build(schema: build.Schema, options?: build.Options): (doc: object | any[] | string | number | boolean | null) => string;
193
+ declare function build(schema: build.AnySchema, options?: build.Options): <TDoc = any>(doc: TDoc) => any;
194
+ declare function build(schema: build.StringSchema, options?: build.Options): <TDoc extends string = string>(doc: TDoc) => string;
195
+ declare function build(schema: build.IntegerSchema | build.NumberSchema, options?: build.Options): <TDoc extends number = number>(doc: TDoc) => string;
196
+ declare function build(schema: build.NullSchema, options?: build.Options): <TDoc extends null = null>(doc: TDoc) => "null";
197
+ declare function build(schema: build.BooleanSchema, options?: build.Options): <TDoc extends boolean = boolean>(doc: TDoc) => string;
198
+ declare function build(schema: build.ArraySchema | build.TupleSchema, options?: build.Options): <TDoc extends any[]= any[]>(doc: TDoc) => string;
199
+ declare function build(schema: build.ObjectSchema, options?: build.Options): <TDoc extends object = object>(doc: TDoc) => string;
200
+ declare function build(schema: build.Schema, options?: build.Options): <TDoc = object | any[] | string | number | boolean | null> (doc: TDoc) => string;
200
201
 
201
202
  export = build;