Skip to content

Commit 16e1211

Browse files
committed
fix: correct typos and improve clarity in README documentation
1 parent 20bb3e9 commit 16e1211

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Serializable
22
=====
33

4-
Small library for deserialization and serialization for javascript and typescript
4+
Small library for deserialization and serialization for JavaScript and TypeScript
55

66
Description
77
------
88

9-
- For working this library needed Metadata Reflection API. If your platform (browser/nodejs) don't support it you must use polifyll. Example: [reflect-metadata](https://www.npmjs.com/package/reflect-metadata)
9+
- For working, this library needs the Metadata Reflection API. If your platform (browser/Node.js) doesn't support it, you must use a polyfill. Example: [reflect-metadata](https://www.npmjs.com/package/reflect-metadata)
1010

11-
- By default library don't crash on wrong types in json and return default value on wrong property. If you need more secure behavior you must override method `onWrongType` on `Serializable` object and drop exception in this method, by your logic want.
11+
- By default, the library doesn't crash on wrong types in JSON and returns the default value on the wrong property. If you need more secure behavior, you must override the method `onWrongType` on the `Serializable` object and throw an exception in this method, according to your logic.
1212

1313
Installation
1414
------
@@ -22,36 +22,36 @@ npm install ts-serializable
2222
Usage
2323
------
2424

25-
This example writed on typescript, but if remove typing, then him will work and on javascript.
25+
This example is written in TypeScript, but if you remove typing, it will also work in JavaScript.
2626

2727
```typescript
2828
import { jsonProperty, Serializable } from "ts-serializable";
2929

3030
export class User extends Serializable {
3131

32-
// @jsonProperty parrameters is accepted types for json
33-
// properties, if property in json will not by found or
34-
// will have invalid type, then will return default value
32+
// @jsonProperty parameters are accepted types for JSON
33+
// properties. If a property in JSON is not found or
34+
// has an invalid type, it will return the default value.
3535
@jsonProperty(Number, null)
36-
public id: number | null = null; // default value necessarily
36+
public id: number | null = null; // default value is necessary
3737

3838
@jsonProperty(String)
39-
public firstName: string = ''; // default value necessarily
39+
public firstName: string = ''; // default value is necessary
4040

4141
@jsonProperty(String)
42-
public familyName: string = ''; // default value necessarily
42+
public familyName: string = ''; // default value is necessary
4343

4444
@jsonProperty(String, void 0)
45-
public lastName?: string = void 0; // default value necessarily
45+
public lastName?: string = void 0; // default value is necessary
4646

4747
@jsonProperty(Date)
48-
public birthdate: Date = new Date(); // default value necessarily
48+
public birthdate: Date = new Date(); // default value is necessary
4949

5050
@jsonProperty([String])
51-
public tags: string[] = []; // default value necessarily
51+
public tags: string[] = []; // default value is necessary
5252

5353
@jsonProperty(OtherClassConstructor, null)
54-
public other: OtherClassConstructor | null = null; // default value necessarily
54+
public other: OtherClassConstructor | null = null; // default value is necessary
5555

5656
public getFullName(): string {
5757
return [
@@ -79,19 +79,19 @@ user.getAge();
7979
* With Serializable
8080
*/
8181
const user: User = new User().fromJSON(json);
82-
user.getFullName(); // work fine and return string
83-
user.getAge(); // work fine and return number
82+
user.getFullName(); // works fine and returns a string
83+
user.getAge(); // works fine and returns a number
8484

8585
// or
8686
const user: User = User.fromJSON(json);
87-
user.getFullName(); // work fine and return string
88-
user.getAge(); // work fine and return number
87+
user.getFullName(); // works fine and returns a string
88+
user.getAge(); // works fine and returns a number
8989
```
9090

9191
Naming strategies
9292
------
9393

94-
Supported conversion between different naming cases, such as SnakeCase, KebabCase, PascalCase and CamelCase. Also you can set custom name for property of json object.
94+
Supported conversion between different naming cases, such as SnakeCase, KebabCase, PascalCase and CamelCase. Also, you can set a custom name for a property of a JSON object.
9595

9696
```typescript
9797
const json = {
@@ -157,18 +157,18 @@ Supported settings:
157157
View-Models from Backend Models
158158
------
159159

160-
If you need to create view-model from dto or entities model you can use same model. Just add VM property to dto or entities model and mark this property by @jsonIgnore() decorator and this property will not be serialized to json.
160+
If you need to create a view-model from a DTO or entities model, you can use the same model. Just add a VM property to the DTO or entities model and mark this property with the @jsonIgnore() decorator, and this property will not be serialized to JSON.
161161

162162
```typescript
163163
import { jsonProperty, jsonIgnore, Serializable } from "ts-serializable";
164164

165165
export class User extends Serializable {
166166

167167
@jsonProperty(String)
168-
public firstName: string = ''; // default value necessarily
168+
public firstName: string = ''; // default value is necessary
169169

170170
@jsonProperty(String)
171-
public familyName: string = ''; // default value necessarily
171+
public familyName: string = ''; // default value is necessary
172172

173173
@jsonIgnore()
174174
public isExpanded: boolean = false;
@@ -184,7 +184,7 @@ JSON.stringify(user);
184184
Class to FormData
185185
------
186186

187-
Sometimes classes contain properties with the File type. Sending such classes via json is a heavy task. Converting a file property to json can freeze the interface for a few seconds if the file is large. A much better solution is to send an Ajax form. Example:
187+
Sometimes classes contain properties with the File type. Sending such classes via JSON is a heavy task. Converting a file property to JSON can freeze the interface for a few seconds if the file is large. A much better solution is to send an Ajax form. Example:
188188

189189
```typescript
190190
import { Serializable } from "ts-serializable";

0 commit comments

Comments
 (0)