mapper-factory 1.0.15 → 1.0.16
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/README.md +30 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,11 +6,15 @@ Work well on data structure and after enjoy the coding process :)
|
|
|
6
6
|
## Installation
|
|
7
7
|
To install the package, you can use npm by running the following command:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```
|
|
10
|
+
npm i mapper-factory
|
|
11
|
+
```
|
|
10
12
|
|
|
11
13
|
Or using yarn
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
```
|
|
16
|
+
yarn add mapper-factory
|
|
17
|
+
```
|
|
14
18
|
|
|
15
19
|
## Usage
|
|
16
20
|
### Mapping simple objects
|
|
@@ -102,11 +106,33 @@ In that way you can create a new JS Object User passing a JSON object. Automatic
|
|
|
102
106
|
|
|
103
107
|
In this specific case we have trasformed a JSON object:
|
|
104
108
|
|
|
105
|
-
|
|
109
|
+
```
|
|
110
|
+
{
|
|
111
|
+
firstName: 'Rick',
|
|
112
|
+
lastName: 'Sanchez',
|
|
113
|
+
employees: [
|
|
114
|
+
{ firstName: 'Summer', lastName: 'Smith' },
|
|
115
|
+
{ firstName: 'Morty', lastName: 'Smith' }
|
|
116
|
+
],
|
|
117
|
+
rolesToMap: [ 'CEO', 'EMPLOYEE' ],
|
|
118
|
+
boss: { firstName: 'Nello', lastName: 'Stanco' }
|
|
119
|
+
}
|
|
120
|
+
```
|
|
106
121
|
|
|
107
122
|
In this JS Object:
|
|
108
123
|
|
|
109
|
-
|
|
124
|
+
```
|
|
125
|
+
User {
|
|
126
|
+
name: 'Rick',
|
|
127
|
+
surname: 'Sanchez',
|
|
128
|
+
employees: [
|
|
129
|
+
User { name: 'Summer', surname: 'Smith' },
|
|
130
|
+
User { name: 'Morty', surname: 'Smith' }
|
|
131
|
+
],
|
|
132
|
+
roles: [ 'CEO TEST TRASFORMER', 'EMPLOYEE TEST TRASFORMER' ],
|
|
133
|
+
boss: User { name: 'Nello', surname: 'Stanco' }
|
|
134
|
+
}
|
|
135
|
+
```
|
|
110
136
|
|
|
111
137
|
Just using the constructor of *User* class.
|
|
112
138
|
|