fast-json-stringify 5.4.1 → 5.6.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.
@@ -71,7 +71,7 @@ jobs:
71
71
  pull-requests: write
72
72
  steps:
73
73
  - name: Comment PR
74
- uses: thollander/actions-comment-pull-request@v1
74
+ uses: thollander/actions-comment-pull-request@v2
75
75
  with:
76
76
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77
77
  message: |
package/.taprc CHANGED
@@ -1,9 +1,14 @@
1
1
  ts: false
2
2
  jsx: false
3
+
3
4
  branches: 65
4
5
  functions: 100
5
6
  lines: 89
6
7
  statements: 89
8
+
7
9
  nyc-arg:
8
10
  - "--exclude=.cache/*"
9
11
  - "--exclude=lib/schema-validator.js"
12
+
13
+ files:
14
+ - test/**/*.test.js
package/README.md CHANGED
@@ -548,7 +548,7 @@ By default the library will handle automatically [BigInt](https://developer.mozi
548
548
  <a name="integer"></a>
549
549
  #### Integers
550
550
  The `type: integer` property will be truncated if a floating point is provided.
551
- You can customize this behaviour with the `rounding` option that will accept [`round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round), [`ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) or [`floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor):
551
+ You can customize this behaviour with the `rounding` option that will accept [`round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round), [`ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil), [`floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) or [`trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc). Default is `trunc`:
552
552
 
553
553
  ```js
554
554
  const stringify = fastJson(schema, { rounding: 'ceil' })
@@ -650,12 +650,16 @@ AJV Serialize large array x 58.76 ops/sec ±4.59% (60 runs sampled)
650
650
  Treat the schema definition as application code, it
651
651
  is not safe to use user-provided schemas.
652
652
 
653
- In order to achieve lowest cost/highest performance redaction `fast-json-stringify`
653
+ To achieve low cost and high performance redaction `fast-json-stringify`
654
654
  creates and compiles a function (using the `Function` constructor) on initialization.
655
655
  While the `schema` is currently validated for any developer errors,
656
656
  there is no guarantee that supplying user-generated schema could not
657
657
  expose your application to remote attacks.
658
658
 
659
+ Users are responsible for sending trusted data. `fast-json-stringify` guarantees that you will get
660
+ a valid output only if your input matches the schema or can be coerced to the schema. If your input
661
+ doesn't match the schema, you will get undefined behavior.
662
+
659
663
  <a name="debug"></a>
660
664
  ### Debug Mode
661
665
 
@@ -214,6 +214,27 @@ const benchmarks = [
214
214
  b5: true
215
215
  }
216
216
  },
217
+ {
218
+ name: 'simple object',
219
+ schema: {
220
+ title: 'Example Schema',
221
+ type: 'object',
222
+ properties: {
223
+ firstName: {
224
+ type: 'string'
225
+ },
226
+ lastName: {
227
+ type: ['string', 'null']
228
+ },
229
+ age: {
230
+ description: 'Age in years',
231
+ type: 'integer',
232
+ minimum: 0
233
+ }
234
+ }
235
+ },
236
+ input: { firstName: 'Max', lastName: 'Power', age: 22 }
237
+ },
217
238
  {
218
239
  name: 'object with const string property',
219
240
  schema: {