@wix/sdk-runtime
Advanced tools
Comparing version 0.2.5 to 0.2.6
function transformPath(obj, { path, isRepeated, isMap, }, transformFn) { | ||
const pathParts = path.split('.'); | ||
if (pathParts.length === 1) { | ||
if (!(path in obj)) { | ||
// we can assume that the current obj is a map and we need | ||
// to transform inside the values of the map | ||
obj = Object.fromEntries(Object.entries(obj).map(([key, value]) => [ | ||
key, | ||
transformPath(value, { path, isRepeated, isMap }, transformFn), | ||
])); | ||
} | ||
else { | ||
obj[path] = isRepeated | ||
? obj[path].map(transformFn) | ||
: isMap | ||
? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) | ||
: transformFn(obj[path]); | ||
} | ||
if (pathParts.length === 1 && path in obj) { | ||
obj[path] = isRepeated | ||
? obj[path].map(transformFn) | ||
: isMap | ||
? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) | ||
: transformFn(obj[path]); | ||
return obj; | ||
} | ||
const [first, ...rest] = pathParts; | ||
if (!(first in obj)) { | ||
// we can assume that the current obj is a map and we need | ||
// to find the rest of the path inside the values of the map | ||
obj = Object.fromEntries(Object.entries(obj).map(([key, value]) => [ | ||
if (first.endsWith('{}')) { | ||
const cleanPath = first.slice(0, -2); | ||
obj[cleanPath] = Object.fromEntries(Object.entries(obj[cleanPath]).map(([key, value]) => [ | ||
key, | ||
transformPath(value, { path, isRepeated, isMap }, transformFn), | ||
transformPath(value, { path: rest.join('.'), isRepeated, isMap }, transformFn), | ||
])); | ||
@@ -33,3 +22,3 @@ } | ||
} | ||
else { | ||
else if (first in obj) { | ||
obj[first] = transformPath(obj[first], { path: rest.join('.'), isRepeated, isMap }, transformFn); | ||
@@ -36,0 +25,0 @@ } |
@@ -6,27 +6,16 @@ "use strict"; | ||
const pathParts = path.split('.'); | ||
if (pathParts.length === 1) { | ||
if (!(path in obj)) { | ||
// we can assume that the current obj is a map and we need | ||
// to transform inside the values of the map | ||
obj = Object.fromEntries(Object.entries(obj).map(([key, value]) => [ | ||
key, | ||
transformPath(value, { path, isRepeated, isMap }, transformFn), | ||
])); | ||
} | ||
else { | ||
obj[path] = isRepeated | ||
? obj[path].map(transformFn) | ||
: isMap | ||
? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) | ||
: transformFn(obj[path]); | ||
} | ||
if (pathParts.length === 1 && path in obj) { | ||
obj[path] = isRepeated | ||
? obj[path].map(transformFn) | ||
: isMap | ||
? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) | ||
: transformFn(obj[path]); | ||
return obj; | ||
} | ||
const [first, ...rest] = pathParts; | ||
if (!(first in obj)) { | ||
// we can assume that the current obj is a map and we need | ||
// to find the rest of the path inside the values of the map | ||
obj = Object.fromEntries(Object.entries(obj).map(([key, value]) => [ | ||
if (first.endsWith('{}')) { | ||
const cleanPath = first.slice(0, -2); | ||
obj[cleanPath] = Object.fromEntries(Object.entries(obj[cleanPath]).map(([key, value]) => [ | ||
key, | ||
transformPath(value, { path, isRepeated, isMap }, transformFn), | ||
transformPath(value, { path: rest.join('.'), isRepeated, isMap }, transformFn), | ||
])); | ||
@@ -37,3 +26,3 @@ } | ||
} | ||
else { | ||
else if (first in obj) { | ||
obj[first] = transformPath(obj[first], { path: rest.join('.'), isRepeated, isMap }, transformFn); | ||
@@ -40,0 +29,0 @@ } |
{ | ||
"name": "@wix/sdk-runtime", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"license": "UNLICENSED", | ||
@@ -82,3 +82,3 @@ "sideEffects": false, | ||
}, | ||
"falconPackageHash": "4065860b3b32a19242e9d7552a2dce5560b3abc84701818688dfc6fb" | ||
"falconPackageHash": "926ce38187a1c4338b958073dbcc7c3979c2d010bfef043024e34687" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129984
3255