Skip to content

Commit 1bcc67f

Browse files
committed
Edit grammar and syntax in readme
1 parent 74d2194 commit 1bcc67f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# fast-json-stringify  [![Build Status](https://travis-ci.org/fastify/fast-json-stringify.svg?branch=master)](https://travis-ci.org/fastify/fast-json-stringify)
22

3-
__fast-json-stringify__ is two times faster than `JSON.stringify()`.
4-
It is particularly suited if you are sending small JSON payloads, the
5-
advantages reduces on large payloads.
3+
__fast-json-stringify__ is significantly faster than `JSON.stringify()` for small payloads. Its performance advantage shrinks as your payload grows.
64

75
Benchmarks:
86

@@ -119,7 +117,7 @@ And nested ones, too.
119117

120118
<a name="required"></a>
121119
#### Required
122-
You can set specific fields of an object as required in your schema, by adding the field name inside the `required` array in your schema.
120+
You can set specific fields of an object as required in your schema by adding the field name inside the `required` array in your schema.
123121
Example:
124122
```javascript
125123
const schema = {
@@ -136,7 +134,7 @@ const schema = {
136134
required: ['mail']
137135
}
138136
```
139-
If the object to stringify has not the required field(s), `fast-json-stringify` will throw an error.
137+
If the object to stringify is missing the required field(s), `fast-json-stringify` will throw an error.
140138

141139
<a name="missingFields"></a>
142140
#### Missing fields
@@ -165,7 +163,7 @@ console.log(stringify(obj)) // '{"mail":"[email protected]"}'
165163

166164
<a name="patternProperties"></a>
167165
#### Pattern properties
168-
`fast-json-stringify` supports pattern properties as defined inside JSON schema.
166+
`fast-json-stringify` supports pattern properties as defined by JSON schema.
169167
*patternProperties* must be an object, where the key is a valid regex and the value is an object, declared in this way: `{ type: 'type' }`.
170168
*patternProperties* will work only for the properties that are not explicitly listed in the properties object.
171169
Example:
@@ -200,12 +198,12 @@ console.log(stringify(obj)) // '{"matchfoo":"42","otherfoo":"str","matchnum":3,"
200198

201199
<a name="additionalProperties"></a>
202200
#### Additional properties
203-
`fast-json-stringify` supports additional properties as defined inside JSON schema.
201+
`fast-json-stringify` supports additional properties as defined by JSON schema.
204202
*additionalProperties* must be an object or a boolean, declared in this way: `{ type: 'type' }`.
205203
*additionalProperties* will work only for the properties that are not explicitly listed in the *properties* and *patternProperties* objects.
206204

207-
If *additionalProperties* is not present or is setted to false, every property that is not explicitly listed in the *properties* and *patternProperties* objects, will be ignored, as said in <a href="#missingFields">Missing fields</a>.
208-
If *additionalProperties* is setted to *true*, it will be used `fast-safe-stringify` to stringify the additional properties. If you want to achieve maximum performances we strongly encourage you to use a fixed schema where possible.
205+
If *additionalProperties* is not present or is set to `false`, every property that is not explicitly listed in the *properties* and *patternProperties* objects,will be ignored, as described in <a href="#missingFields">Missing fields</a>.
206+
If *additionalProperties* is set to `true`, it will be used by `fast-safe-stringify` to stringify the additional properties. If you want to achieve maximum performance, we strongly encourage you to use a fixed schema where possible.
209207
Example:
210208
```javascript
211209
const stringify = fastJson({
@@ -243,9 +241,9 @@ console.log(stringify(obj)) // '{"matchfoo":"42","otherfoo":"str","matchnum":3,"
243241

244242
#### AnyOf
245243

246-
`fast-json-stringify` supports anyOf keyword as defined inside JSON schema. *anyOf* must be an array of valid JSON schemas. The differents schemas will be tried in this order so `stringify` will be slower the farest the right type is from the start of the array.
244+
`fast-json-stringify` supports the anyOf keyword as defined by JSON schema. *anyOf* must be an array of valid JSON schemas. The different schemas will be tested in the specified order. The more schemas `stringify` has to try before finding a match, the slower it will be.
247245

248-
*anyOf* uses [ajv](https://www.npmjs.com/package/ajv) as a JSON schema validator to find the schema that match the data and this has an impact on performances. Use it only as a last resort.
246+
*anyOf* uses [ajv](https://www.npmjs.com/package/ajv) as a JSON schema validator to find the schema that matches the data. This has an impact on performance—only use it as a last resort.
249247

250248
Example:
251249
```javascript
@@ -264,7 +262,7 @@ const stringify = fastJson({
264262
}
265263
```
266264
267-
This schema will accept a string or a boolean for the property `undecidedType`. If no schema match the data, it will be stringified as `null`.
265+
This schema will accept a string or a boolean for the property `undecidedType`. If no schema matches the data, it will be stringified as `null`.
268266
269267
<a name="ref"></a>
270268
#### Reuse - $ref
@@ -371,8 +369,8 @@ console.log(stringify(obj)) // '{"id":18446744073709551615}'
371369
372370
<a name="uglify"></a>
373371
#### Uglify
374-
If you want to squeeze a little bit more performance out of the serialisation, at the cost of readability in the generated code, you can pass `uglify: true` as an option.
375-
Note that you have to manually install `uglify-es` in order for it to work. Only version 3 is supported.
372+
If you want to squeeze a little bit more performance out of the serialization at the cost of readability in the generated code, you can pass `uglify: true` as an option.
373+
Note that you have to manually install `uglify-es` in order for this to work. Only version 3 is supported.
376374
Example:
377375
378376
Note that if you are using Node 8.3.0 or newer, there are no performance gains from using Uglify. See https://www.nearform.com/blog/node-js-is-getting-a-new-v8-with-turbofan/

0 commit comments

Comments
 (0)