Add support for bare object references in the property mapper

master
Sven Slootweg 7 years ago
parent fda5765197
commit 8c380ff7d6

@ -13,9 +13,17 @@ module.exports = function createPropertyMapper(propertyMap) {
transformer: destinationPath
}
} else {
let destinationPathParts = destinationPath.split(".");
let destinationObject = destinationPathParts[0];
let destinationProperty = destinationPathParts.slice(1).join(".");
let destinationObject, destinationProperty;
if (destinationPath.includes(".")) {
let destinationPathParts = destinationPath.split(".");
destinationObject = destinationPathParts[0];
destinationProperty = destinationPathParts.slice(1).join(".");
} else {
destinationObject = destinationPath;
destinationProperty = sourceProperty;
}
return {
sourceProperty: sourceProperty,
@ -82,8 +90,8 @@ module.exports = function createPropertyMapper(propertyMap) {
};
let mapper = module.exports({
foo: "one.foo",
bar: "two.bar",
foo: "one",
bar: "two",
twoFoo: "two.foo",
baz: (value) => {
return {

Loading…
Cancel
Save