fast-json-stringify 2.5.4 → 2.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.
@@ -1,27 +1,43 @@
1
- name: CI workflow
2
- on: [push, pull_request]
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ paths-ignore:
6
+ - 'docs/**'
7
+ - '*.md'
8
+ pull_request:
9
+ paths-ignore:
10
+ - 'docs/**'
11
+ - '*.md'
12
+
3
13
  jobs:
4
14
  test:
5
- runs-on: ubuntu-latest
15
+ runs-on: ${{ matrix.os }}
6
16
  strategy:
7
17
  matrix:
8
18
  node-version: [10.x, 12.x, 13.x, 14.x]
19
+ os: [macos-latest, ubuntu-latest, windows-latest]
20
+
9
21
  steps:
10
- - uses: actions/checkout@v2
11
- - name: Use Node.js ${{ matrix.node-version }}
12
- uses: actions/setup-node@v2.1.5
13
- with:
14
- node-version: ${{ matrix.node-version }}
15
- - name: Install Dependencies
16
- run: npm install --ignore-scripts
17
- - name: Test
18
- run: npm run test
22
+ - uses: actions/checkout@v2
23
+
24
+ - name: Use Node.js
25
+ uses: actions/setup-node@v2.1.5
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+
29
+ - name: Install Dependencies
30
+ run: |
31
+ npm install --ignore-scripts
32
+
33
+ - name: Run Tests
34
+ run: |
35
+ npm run test
19
36
 
20
37
  automerge:
21
38
  needs: test
22
39
  runs-on: ubuntu-latest
23
40
  steps:
24
41
  - uses: fastify/github-action-merge-dependabot@v2.0.0
25
- if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
26
42
  with:
27
- github-token: ${{secrets.github_token}}
43
+ github-token: ${{ secrets.GITHUB_TOKEN }}
package/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # fast-json-stringify
2
2
 
3
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
4
- ![Ci Workflow](https://github.com/fastify/fast-json-stringify/workflows/CI%20workflow/badge.svg)
3
+ ![CI](https://github.com/fastify/fast-json-stringify/workflows/CI/badge.svg)
4
+ [![NPM version](https://img.shields.io/npm/v/fast-json-stringify.svg?style=flat)](https://www.npmjs.com/package/fast-json-stringify)
5
+ [![Known Vulnerabilities](https://snyk.io/test/github/fastify/fast-json-stringify/badge.svg)](https://snyk.io/test/github/fastify/fast-json-stringify)
6
+ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
5
7
  [![NPM downloads](https://img.shields.io/npm/dm/fast-json-stringify.svg?style=flat)](https://www.npmjs.com/package/fast-json-stringify)
6
8
 
7
9
 
@@ -106,7 +108,7 @@ const stringify = fastJson(mySchema, {
106
108
  <a name="fastJsonStringify"></a>
107
109
  ### fastJsonStringify(schema)
108
110
 
109
- Build a `stringify()` function based on [jsonschema](http://json-schema.org/).
111
+ Build a `stringify()` function based on [jsonschema](https://json-schema.org/).
110
112
 
111
113
  Supported types:
112
114
 
@@ -399,7 +401,7 @@ console.log(stringify({
399
401
  })) // {"kind":"foobar","foo":"FOO","bar":42}
400
402
  ```
401
403
 
402
- **NB:** don't declare the properties twice or you'll print them twice!
404
+ **NB** Do not declare the properties twice or you will print them twice!
403
405
 
404
406
  <a name="ref"></a>
405
407
  #### Reuse - $ref
@@ -514,7 +516,7 @@ const stringify = fastJson(schema, { schema: externalSchema })
514
516
 
515
517
  <a name="long"></a>
516
518
  #### Long integers
517
- By default the library will handle automatically [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) from Node.js v10.3 and above.
519
+ By default the library will automatically handle [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) from Node.js v10.3 and above.
518
520
  If you can't use BigInts in your environment, long integers (64-bit) are also supported using the [long](https://github.com/dcodeIO/long.js) module.
519
521
  Example:
520
522
  ```javascript
@@ -641,7 +643,7 @@ console.log(stringify({ firstName: 'Foo', surname: 'bar' })) // '{"firstName":"F
641
643
  <a name="acknowledgements"></a>
642
644
  ## Acknowledgements
643
645
 
644
- This project was kindly sponsored by [nearForm](http://nearform.com).
646
+ This project was kindly sponsored by [nearForm](https://nearform.com).
645
647
 
646
648
  <a name="license"></a>
647
649
  ## License
package/example.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict'
2
-
3
1
  const moment = require('moment')
4
- const fastJson = require('.')
2
+ const fastJson = require('fast-json-stringify')
5
3
  const stringify = fastJson({
6
4
  title: 'Example Schema',
7
5
  type: 'object',
package/index.js CHANGED
@@ -146,13 +146,8 @@ function build (schema, options) {
146
146
  return ${main}
147
147
  `
148
148
 
149
- const dependencies = []
150
- const dependenciesName = []
151
- if (dependsOnAjv(schema)) {
152
- dependencies.push(new Ajv(options.ajv))
153
- dependenciesName.push('ajv')
154
- }
155
-
149
+ const dependencies = [new Ajv(options.ajv)]
150
+ const dependenciesName = ['ajv']
156
151
  dependenciesName.push(code)
157
152
 
158
153
  if (options.debugMode) {
@@ -223,23 +218,6 @@ function inferTypeByKeyword (schema) {
223
218
  return schema.type
224
219
  }
225
220
 
226
- function dependsOnAjv (schema) {
227
- const str = JSON.stringify(schema)
228
- switch (true) {
229
- case /"if":{.*"then":{/.test(str):
230
- case /"(anyOf|oneOf)":\[/.test(str):
231
- case /"const"/.test(str):
232
- case /"\$ref"/.test(str):
233
- {
234
- return true
235
- }
236
-
237
- default: {
238
- return false
239
- }
240
- }
241
- }
242
-
243
221
  const stringSerializerMap = {
244
222
  'date-time': '$asDatetime',
245
223
  date: '$asDate',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-json-stringify",
3
- "version": "2.5.4",
3
+ "version": "2.6.0",
4
4
  "description": "Stringify your JSON at max speed",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",