Skip to content

Commit b3204e4

Browse files
authored
Merge pull request #31 from mlersch/mlersch-patch-1
Updated README.md
2 parents ba09a52 + aac7da5 commit b3204e4

1 file changed

Lines changed: 26 additions & 22 deletions

File tree

README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ var map = {
6969
{
7070
key: "foo",
7171
transform: function (value) {
72-
return val + "_foo";
72+
return value + "_foo";
7373
}
7474
},
7575
{
7676
key: "baz",
7777
transform: function (value) {
78-
return val + "_baz";
78+
return value + "_baz";
7979
}
8080
}
8181
],
@@ -133,18 +133,19 @@ When using an `Array` as the destination you can pass a `String`, an `Object` or
133133
If you want to append items to an existing `Array`, append a `+` after the `[]`
134134
```javascript
135135
{
136-
"sourceArray[]":{
137-
"key":"destination[]+",
136+
"sourceArray[]": {
137+
"key": "destination[]+",
138138
"transform": (val) => mappingFunction(val)
139139
},
140-
"otherSourceArray[]":{
141-
"key":"destination[]+",
142-
"transform:":(val) => mappingFunction(val)
140+
"otherSourceArray[]": {
141+
"key": "destination[]+",
142+
"transform": (val) => mappingFunction(val)
143143
}
144144
}
145+
145146
// Results in the destination array appending the source values
146147
{
147-
"destination":[
148+
"destination": [
148149
{/*Results from the mapping function applied to sourceArray */},
149150
{/*Results from the mapping function applied to otherSourceArray */},
150151
]
@@ -163,17 +164,20 @@ By default `null` values on the source `Object` is not mapped. You can override
163164

164165
```javascript
165166
var original = {
166-
"sourceKey":null,
167-
"otherSourceKey":null
167+
"sourceKey": null,
168+
"otherSourceKey": null
168169
}
170+
169171
var transform = {
170-
"sourceKey":"canBeNull?",
171-
"otherSourceKey":"cannotBeNull"
172+
"sourceKey": "canBeNull?",
173+
"otherSourceKey": "cannotBeNull"
172174
}
175+
173176
var results = ObjectMapper(original, {}, transform);
177+
174178
// Results would be the following
175179
{
176-
canBeNull:null
180+
canBeNull: null
177181
}
178182
```
179183

@@ -216,15 +220,15 @@ other projects.
216220
var objectMapper = require('object-mapper');
217221

218222
var src = {
219-
"sku" : "12345",
220-
"upc" : "99999912345X",
221-
"title" : "Test Item",
222-
"description" : "Description of test item",
223-
"length" : 5,
224-
"width" : 2,
225-
"height" : 8,
226-
"inventory" : {
227-
"onHandQty" : 12
223+
"sku": "12345",
224+
"upc": "99999912345X",
225+
"title": "Test Item",
226+
"description": "Description of test item",
227+
"length": 5,
228+
"width": 2,
229+
"height": 8,
230+
"inventory": {
231+
"onHandQty": 12
228232
}
229233
};
230234

0 commit comments

Comments
 (0)