fast-json-stringify
Advanced tools
| 'use strict' | ||
| const test = require('tap').test | ||
| const build = require('..') | ||
| test('nested objects with same properties', (t) => { | ||
| t.plan(1) | ||
| const schema = { | ||
| title: 'nested objects with same properties', | ||
| type: 'object', | ||
| properties: { | ||
| stringProperty: { | ||
| type: 'string' | ||
| }, | ||
| objectProperty: { | ||
| type: 'object', | ||
| additionalProperties: true | ||
| } | ||
| } | ||
| } | ||
| const stringify = build(schema) | ||
| try { | ||
| const value = stringify({ | ||
| stringProperty: 'string1', | ||
| objectProperty: { | ||
| stringProperty: 'string2', | ||
| numberProperty: 42 | ||
| } | ||
| }) | ||
| t.is(value, '{"stringProperty":"string1","objectProperty":{"stringProperty":"string2","numberProperty":42}}') | ||
| } catch (e) { | ||
| t.fail() | ||
| } | ||
| }) |
+3
-5
@@ -27,8 +27,4 @@ 'use strict' | ||
| ` | ||
| // used to support patternProperties and additionalProperties | ||
| // they need to check if a field belongs to the properties in the schema | ||
| code += ` | ||
| var properties = ${JSON.stringify(schema.properties)} || {} | ||
| ` | ||
| code += ` | ||
| ${$asString.toString()} | ||
@@ -222,2 +218,3 @@ ${$asStringSmall.toString()} | ||
| var code = ` | ||
| var properties = ${JSON.stringify(schema.properties)} || {} | ||
| var keys = Object.keys(obj) | ||
@@ -373,2 +370,3 @@ for (var i = 0; i < keys.length; i++) { | ||
| return ` | ||
| var properties = ${JSON.stringify(schema.properties)} || {} | ||
| var keys = Object.keys(obj) | ||
@@ -375,0 +373,0 @@ for (var i = 0; i < keys.length; i++) { |
+5
-5
| { | ||
| "name": "fast-json-stringify", | ||
| "version": "1.2.0", | ||
| "version": "1.2.1", | ||
| "description": "Stringify your JSON at max speed", | ||
@@ -32,10 +32,10 @@ "main": "index.js", | ||
| "pre-commit": "^1.2.2", | ||
| "proxyquire": "^1.8.0", | ||
| "standard": "^11.0.0", | ||
| "tap": "^11.1.1", | ||
| "proxyquire": "^2.0.0", | ||
| "standard": "^11.0.1", | ||
| "tap": "^11.1.3", | ||
| "uglify-es": "^3.3.10" | ||
| }, | ||
| "dependencies": { | ||
| "ajv": "^6.0.0" | ||
| "ajv": "^6.4.0" | ||
| } | ||
| } |
+2
-0
| # fast-json-stringify [](https://travis-ci.org/fastify/fast-json-stringify) | ||
| [](https://greenkeeper.io/) | ||
| __fast-json-stringify__ is significantly faster than `JSON.stringify()` for small payloads. Its performance advantage shrinks as your payload grows. It pairs well with [__flatstr__](https://www.npmjs.com/package/flatstr), which triggers a V8 optimization that improves performance when eventually converting the string to a `Buffer`. | ||
@@ -4,0 +6,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
74527
1.07%24
4.35%2691
1.09%405
0.5%Updated