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

Loading…
Cancel
Save