ts-serializable 4.5.0 → 4.5.4

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [4.5.4] - 2025-12-14
6
+
7
+ ### 📚 Documentation
8
+
9
+ - *(README)* Remove emojis from section headers for consistency
10
+
11
+ # Changelog
12
+
13
+ All notable changes to this project will be documented in this file.
14
+
15
+ ## [4.5.3] - 2025-12-13
16
+
17
+ ### 🚜 Refactor
18
+
19
+ - *(DeserializeProperty)* Update ESLint directives for better readability
20
+
21
+ # Changelog
22
+
23
+ All notable changes to this project will be documented in this file.
24
+
25
+ ## [4.5.2] - 2025-12-09
26
+
27
+ # Changelog
28
+
29
+ All notable changes to this project will be documented in this file.
30
+
31
+ ## [4.5.1] - 2025-12-07
32
+
33
+ ### 🐛 Bug Fixes
34
+
35
+ - Update README badges for npm downloads, license, and CI workflows
36
+
37
+ # Changelog
38
+
39
+ All notable changes to this project will be documented in this file.
40
+
5
41
  ## [4.5.0] - 2025-12-07
6
42
 
7
43
  ### 🚀 Features
package/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # ts-serializable
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/ts-serializable.svg)](https://www.npmjs.com/package/ts-serializable)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm downloads](https://img.shields.io/npm/dm/ts-serializable.svg)](https://www.npmjs.com/package/ts-serializable)
5
+ [![License: MIT](https://img.shields.io/github/license/LabEG/Serializable.svg)](https://github.com/LabEG/Serializable/blob/master/LICENSE)
6
+ [![Test PR](https://github.com/LabEG/Serializable/workflows/Test%20Pull%20Request/badge.svg)](https://github.com/LabEG/Serializable/actions)
7
+ [![CodeQL](https://github.com/LabEG/Serializable/workflows/CodeQL%20Advanced/badge.svg)](https://github.com/LabEG/Serializable/security/code-scanning)
5
8
 
6
9
  Powerful and flexible TypeScript/JavaScript library for serialization and deserialization with decorators
7
10
 
8
- ## Features
11
+ ## Features
9
12
 
10
13
  - 🎯 **Type-safe** - Convert JSON to strongly-typed class instances
11
14
  - 🎨 **Decorator-based** - Clean and intuitive API using TypeScript decorators
@@ -16,49 +19,49 @@ Powerful and flexible TypeScript/JavaScript library for serialization and deseri
16
19
  - 📝 **FormData Support** - Built-in conversion to FormData for file uploads
17
20
  - ⚡ **Lightweight** - Minimal dependencies and small bundle size
18
21
 
19
- ## 📋 Table of Contents
22
+ ## Table of Contents
20
23
 
21
24
  - [ts-serializable](#ts-serializable)
22
- - [Features](#-features)
23
- - [📋 Table of Contents](#-table-of-contents)
24
- - [🚀 Installation](#-installation)
25
- - [🎯 Quick Start](#-quick-start)
25
+ - [Features](#features)
26
+ - [Table of Contents](#table-of-contents)
27
+ - [Installation](#installation)
28
+ - [Quick Start](#quick-start)
26
29
  - [Why Use ts-serializable?](#why-use-ts-serializable)
27
- - [🎓 Core Concepts](#-core-concepts)
30
+ - [Core Concepts](#core-concepts)
28
31
  - [Type Safety](#type-safety)
29
32
  - [Default Values](#default-values)
30
33
  - [Error Handling](#error-handling)
31
- - [🎨 Decorators](#-decorators)
34
+ - [Decorators](#decorators)
32
35
  - [@jsonProperty](#jsonproperty)
33
36
  - [@jsonIgnore](#jsonignore)
34
37
  - [@jsonName](#jsonname)
35
38
  - [@jsonObject](#jsonobject)
36
- - [🔧 Advanced Usage](#-advanced-usage)
37
- - [🔧 Standalone Functions](#-standalone-functions)
38
- - [🐍 Naming Strategies](#-naming-strategies)
39
- - [⚙️ Configuration Settings](#️-configuration-settings)
40
- - [🎭 View Models and DTOs](#-view-models-and-dtos)
41
- - [📤 FormData Conversion](#-formdata-conversion)
39
+ - [Advanced Usage](#advanced-usage)
40
+ - [Standalone Functions](#standalone-functions)
41
+ - [Naming Strategies](#naming-strategies)
42
+ - [Configuration Settings](#configuration-settings)
43
+ - [View Models and DTOs](#view-models-and-dtos)
44
+ - [FormData Conversion](#formdata-conversion)
42
45
  - [Basic Usage](#basic-usage)
43
46
  - [Complex Object Graphs](#complex-object-graphs)
44
47
  - [With Custom Prefix](#with-custom-prefix)
45
48
  - [Appending to Existing FormData](#appending-to-existing-formdata)
46
49
  - [Special Type Handling](#special-type-handling)
47
- - [💡 Additional Features](#-additional-features)
50
+ - [Additional Features](#additional-features)
48
51
  - [Deep Copy](#deep-copy)
49
52
  - [Nested Objects](#nested-objects)
50
53
  - [Arrays of Objects](#arrays-of-objects)
51
- - [📚 API Reference](#-api-reference)
54
+ - [API Reference](#api-reference)
52
55
  - [Serializable Class Methods](#serializable-class-methods)
53
56
  - [Static Methods](#static-methods)
54
57
  - [Instance Methods](#instance-methods)
55
- - [Standalone Functions](#standalone-functions)
58
+ - [Standalone Functions](#standalone-functions-1)
56
59
  - [Available Naming Strategies](#available-naming-strategies)
57
- - [🤝 Contributing](#-contributing)
58
- - [📄 License](#-license)
59
- - [🙏 Acknowledgments](#-acknowledgments)
60
+ - [Contributing](#contributing)
61
+ - [License](#license)
62
+ - [Acknowledgments](#acknowledgments)
60
63
 
61
- ## 🚀 Installation
64
+ ## Installation
62
65
 
63
66
  ```bash
64
67
  npm install ts-serializable reflect-metadata
@@ -71,7 +74,7 @@ npm install ts-serializable reflect-metadata
71
74
  import "reflect-metadata";
72
75
  ```
73
76
 
74
- ## 🎯 Quick Start
77
+ ## Quick Start
75
78
 
76
79
  Here's a simple example to get you started:
77
80
 
@@ -121,7 +124,7 @@ const user: User = User.fromJSON(jsonString);
121
124
  user.getFullName(); // ✅ Works perfectly and returns a string
122
125
  ```
123
126
 
124
- ## 🎓 Core Concepts
127
+ ## Core Concepts
125
128
 
126
129
  ### Type Safety
127
130
 
@@ -159,7 +162,7 @@ class StrictUser extends Serializable {
159
162
  }
160
163
  ```
161
164
 
162
- ## 🎨 Decorators
165
+ ## Decorators
163
166
 
164
167
  ### @jsonProperty
165
168
 
@@ -249,7 +252,7 @@ class User extends Serializable {
249
252
  }
250
253
  ```
251
254
 
252
- ## 🔧 Advanced Usage
255
+ ## Advanced Usage
253
256
 
254
257
  This example is written in TypeScript, but it also works in JavaScript (without type annotations).
255
258
 
@@ -317,7 +320,7 @@ user.getFullName(); // works fine and returns a string
317
320
  user.getAge(); // works fine and returns a number
318
321
  ```
319
322
 
320
- ## 🔧 Standalone Functions
323
+ ## Standalone Functions
321
324
 
322
325
  The library provides standalone utility functions `fromJSON` and `toJSON` that can be used with any objects, not just classes that extend `Serializable`. This is useful when you want to use the serialization features without inheritance.
323
326
 
@@ -483,7 +486,7 @@ console.log(jsonToSend);
483
486
  // }
484
487
  ```
485
488
 
486
- ## 🐍 Naming Strategies
489
+ ## Naming Strategies
487
490
 
488
491
  The library supports automatic conversion between different naming conventions, making it easy to work with APIs that use different naming styles. Supported strategies include:
489
492
 
@@ -528,7 +531,7 @@ user.dateOfBirth?.toISOString() === json.date_of_birth; // true
528
531
  user.veryStrangePropertyName === json["very::strange::json:name"]; // true
529
532
  ```
530
533
 
531
- ## ⚙️ Configuration Settings
534
+ ## Configuration Settings
532
535
 
533
536
  You can customize serialization behavior at three levels:
534
537
 
@@ -554,7 +557,7 @@ Supported settings:
554
557
  - **defaultValueHandling**, enum, default Ignore - ...coming soon.
555
558
  - **logLevel**, enum, default Warning - ...coming soon.
556
559
 
557
- ## 🎭 View Models and DTOs
560
+ ## View Models and DTOs
558
561
 
559
562
  If you need to create view-models from DTO or entity models, you can add view-specific properties and mark them with `@jsonIgnore()` to exclude them from serialization.
560
563
 
@@ -580,7 +583,7 @@ JSON.stringify(user);
580
583
  // Result: {"firstName":"","familyName":""}
581
584
  ```
582
585
 
583
- ## 📤 FormData Conversion
586
+ ## FormData Conversion
584
587
 
585
588
  When working with file uploads, converting files to JSON (base64) can freeze the UI for large files. The library provides built-in FormData conversion as a more efficient alternative.
586
589
 
@@ -771,7 +774,7 @@ The FormData conversion handles different types intelligently:
771
774
 
772
775
  **Note:** All decorators (`@jsonIgnore`, `@jsonName`, naming strategies) are respected during FormData conversion.
773
776
 
774
- ## 💡 Additional Features
777
+ ## Additional Features
775
778
 
776
779
  ### Deep Copy
777
780
 
@@ -842,7 +845,7 @@ const team = Team.fromJSON(json);
842
845
  console.log(team.members[0] instanceof User); // true
843
846
  ```
844
847
 
845
- ## 📚 API Reference
848
+ ## API Reference
846
849
 
847
850
  ### Serializable Class Methods
848
851
 
@@ -916,14 +919,14 @@ console.log(team.members[0] instanceof User); // true
916
919
  - `PascalCaseNamingStrategy` - Converts to PascalCase
917
920
  - `KebabCaseNamingStrategy` - Converts to kebab-case
918
921
 
919
- ## 🤝 Contributing
922
+ ## Contributing
920
923
 
921
924
  Contributions are welcome! Please feel free to submit a Pull Request.
922
925
 
923
- ## 📄 License
926
+ ## License
924
927
 
925
928
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
926
929
 
927
- ## 🙏 Acknowledgments
930
+ ## Acknowledgments
928
931
 
929
932
  Special thanks to all contributors and users of this library.
@@ -36,9 +36,9 @@ import { onWrongType } from "./OnWrongType.js";
36
36
  * // Returns the string "30" since String is checked first
37
37
  * ```
38
38
  */
39
- // eslint-disable-next-line max-lines-per-function, max-statements, complexity
39
+ // eslint-disable-next-line max-lines-per-function, max-statements
40
40
  export const deserializeProperty = (obj, prop, acceptedTypes, jsonValue, settings
41
- // eslint-disable-next-line max-params
41
+ // eslint-disable-next-line max-params, complexity
42
42
  ) => {
43
43
  for (const acceptedType of acceptedTypes) { // Type Symbol is not a property
44
44
  if ( // Null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-serializable",
3
- "version": "4.5.0",
3
+ "version": "4.5.4",
4
4
  "author": "Eugene Labutin",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/LabEG/Serializable#readme",