map-factory
Advanced tools
Comparing version 3.7.4 to 3.7.5
@@ -0,1 +1,5 @@ | ||
### 3.7.5 | ||
Fixed a bug where ```{"alwaysSet":true}``` was not setting an empty array in all use cases. | ||
### 3.7.4 | ||
@@ -2,0 +6,0 @@ |
@@ -120,3 +120,3 @@ "use strict"; | ||
// console.log(indent, "Destination has a value"); | ||
// console.log(indent, "Destination has a value", key, value, isValueArray); | ||
if (isPropertyArray) { | ||
@@ -133,5 +133,9 @@ arrayIndex = match[2] || 0; | ||
// console.log(indent, "resolve", fromValue, destinationObject, parentIsArray); | ||
// console.log(indent, "resolve", key, fromValue, destinationObject, parentIsArray); | ||
if (parentIsArray === true && destinationStartedEmpty) return null; | ||
if (isValueArray) { | ||
destinationObject[key] = []; | ||
} | ||
return destinationObject; | ||
@@ -138,0 +142,0 @@ } |
@@ -283,2 +283,40 @@ "use strict"; | ||
}); | ||
group("multiple mappings and arrays", function () { | ||
lab.test("when two mappings have an array as the first mapping", function () { | ||
var mapper = (0, _index2.default)({ alwaysSet: true }); | ||
var source = { | ||
foo: 0, | ||
bar: [] | ||
}; | ||
var expected = { bar: [], foo: 0 }; | ||
mapper.map("bar").to("bar[]").map("foo"); | ||
var actual = mapper.execute(source); | ||
(0, _code.expect)(actual).to.equal(expected); | ||
}); | ||
lab.test("when two mappings have an array as the second mapping", function () { | ||
var mapper = (0, _index2.default)({ alwaysSet: true }); | ||
var source = { | ||
foo: 0, | ||
bar: [] | ||
}; | ||
var expected = { bar: [], foo: 0 }; | ||
mapper.map("foo").map("bar").to("bar[]"); | ||
var actual = mapper.execute(source); | ||
(0, _code.expect)(actual).to.equal(expected); | ||
}); | ||
}); | ||
}); | ||
@@ -285,0 +323,0 @@ |
{ | ||
"name": "map-factory", | ||
"version": "3.7.4", | ||
"version": "3.7.5", | ||
"description": "A simple object mapping utility that makes it easy to map data from one object to another. Create object mappers using fluent interface that supports deep references (dot notation), custom transformations, and object merging.", | ||
@@ -55,3 +55,3 @@ "main": "./dist/lib/index.js", | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^9.0.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
@@ -58,0 +58,0 @@ "benchmark": "^2.1.3", |
248965
6004