@@ -12,15 +12,15 @@ import {classToFormData} from "../utils/ClassToFormData.js";
1212import { getPropertyName } from "../utils/GetProperyName.js" ;
1313
1414/**
15- * Class how help you deserialize object to classes.
15+ * Class that helps you deserialize objects to classes.
1616 *
1717 * @export
1818 * @class Serializable
1919 */
2020export class Serializable {
2121
2222 /**
23- * Global setting for serialization and deserialization
23+ * Global settings for serialization and deserialization.
2424 *
2525 * @static
2626 * @type {SerializationSettings }
@@ -29,7 +29,7 @@ export class Serializable {
2929 public static defaultSettings : SerializationSettings = new SerializationSettings ( ) ;
3030
3131 /**
32- * Deserialize object from static method.
32+ * Deserialize an object using a static method.
3333 *
3434 * Example:
3535 * const obj: MyObject = MyObject.fromJSON({...data});
@@ -48,13 +48,13 @@ export class Serializable {
4848 }
4949
5050 /**
51- * Deserialize object from static method.
51+ * Deserialize an object from a string using a static method.
5252 *
5353 * Example:
54- * const obj: MyObject = MyObject.fromString({...data});
54+ * const obj: MyObject = MyObject.fromString(" {...data}" );
5555 *
5656 * @static
57- * @param {object } json
57+ * @param {string } str
5858 * @returns {object }
5959 * @memberof Serializable
6060 */
@@ -67,10 +67,10 @@ export class Serializable {
6767 }
6868
6969 /**
70- * Fill property of current model by data from string.
70+ * Fill properties of the current model with data from a string.
7171 *
7272 * Example:
73- * const obj: MyObject = new MyObject().fromString("{...data}"" );
73+ * const obj: MyObject = new MyObject().fromString("{...data}");
7474 *
7575 * @param {string } str
7676 * @returns {this }
@@ -81,7 +81,7 @@ export class Serializable {
8181 }
8282
8383 /**
84- * Fill property of current model by data from json .
84+ * Fill properties of the current model with data from JSON .
8585 *
8686 * Example:
8787 * const obj: MyObject = new MyObject().fromJSON({...data});
@@ -98,7 +98,7 @@ export class Serializable {
9898 Array . isArray ( unknownJson ) ||
9999 typeof unknownJson !== "object"
100100 ) {
101- this . onWrongType ( String ( unknownJson ) , "is not object" , unknownJson ) ;
101+ this . onWrongType ( String ( unknownJson ) , "is not an object" , unknownJson ) ;
102102 return this ;
103103 }
104104
@@ -132,7 +132,7 @@ export class Serializable {
132132 }
133133
134134 /**
135- * Process serialization for @jsonIgnore decorator
135+ * Process serialization for the @jsonIgnore decorator.
136136 *
137137 * @returns {object }
138138 * @memberof Serializable
@@ -159,15 +159,15 @@ export class Serializable {
159159 }
160160
161161 /**
162- * Serialize class to FormData.
162+ * Serialize the class to FormData.
163163 *
164- * Can be used for prepare ajax form with files.
165- * Send files via ajax json its heavy task, because need convert file to base 64 format,
166- * user interface can be freeze on many seconds on this operation if file is too big .
167- * Ajax forms its lightweight alternative.
164+ * Can be used to prepare an AJAX form with files.
165+ * Sending files via AJAX JSON is a heavy task because it requires converting files to base64 format.
166+ * The user interface can freeze for several seconds during this operation if the file is too large .
167+ * AJAX forms are a lightweight alternative.
168168 *
169169 * @param {string } formPrefix Prefix for form property names
170- * @param {FormData } formData Can be update an existing FormData
170+ * @param {FormData } formData Can update an existing FormData
171171 * @returns {FormData }
172172 * @memberof Serializable
173173 */
@@ -176,7 +176,7 @@ export class Serializable {
176176 }
177177
178178 /**
179- * Process serialization for @jsonIgnore decorator
179+ * Process serialization for the @jsonIgnore decorator.
180180 *
181181 * @returns {string }
182182 * @memberof Serializable
@@ -186,8 +186,8 @@ export class Serializable {
186186 }
187187
188188 /**
189- * Process exceptions from wrong types.
190- * By default just print warning in console, but can by override for drop exception or logging to backend.
189+ * Process exceptions for incorrect types.
190+ * By default, it just prints a warning in the console, but it can be overridden to throw exceptions or log to the backend.
191191 *
192192 * @protected
193193 * @param {string } prop
@@ -201,7 +201,7 @@ export class Serializable {
201201 }
202202
203203 /**
204- * Deserialize one property
204+ * Deserialize one property.
205205 *
206206 * @private
207207 * @param {object } object
@@ -224,7 +224,7 @@ export class Serializable {
224224 jsonValue === null
225225 ) {
226226 return null ;
227- } else if ( // Void, for deep copy classes only, json don 't have void type
227+ } else if ( // Void, for deep copy classes only, JSON doesn 't have a void type
228228 acceptedType === void 0 &&
229229 jsonValue === void 0
230230 ) {
@@ -264,7 +264,7 @@ export class Serializable {
264264 unicodeTime = jsonValue . getTime ( ) ;
265265 }
266266 if ( isNaN ( unicodeTime ) ) { // Preserve invalid time
267- this . onWrongType ( prop , "is invalid date" , jsonValue ) ;
267+ this . onWrongType ( prop , "is an invalid date" , jsonValue ) ;
268268 }
269269
270270 return new Date ( unicodeTime ) ;
@@ -297,25 +297,25 @@ export class Serializable {
297297 const TypeConstructor : new ( ) => Serializable = acceptedType as new ( ) => Serializable ;
298298
299299 return new TypeConstructor ( ) . fromJSON ( jsonValue , settings ) ;
300- } else if ( // Instance any other class, not Serializable, for parse from other classes instance
300+ } else if ( // Instance any other class, not Serializable, for parsing from other class instances
301301 acceptedType instanceof Function &&
302302 jsonValue instanceof acceptedType
303303 ) {
304304 return jsonValue ;
305305 }
306306 }
307307
308- // Process wrong type and return default value
308+ // Process incorrect type and return default value
309309 this . onWrongType ( prop , "is invalid" , jsonValue ) ;
310310
311311 return Reflect . get ( this , prop ) ;
312312 }
313313
314314 /**
315- * Extract correct name for property.
315+ * Extract the correct name for a property.
316316 * Considers decorators for transforming the property name.
317317 *
318- * @param {string } property Source name of property
318+ * @param {string } property Source name of the property
319319 * @param {Partial<SerializationSettings> } settings Serialization settings
320320 * @returns
321321 */
0 commit comments