Skip to content

Commit

Permalink
fix(lib-dynamodb): check for function types in processKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
siddsriv committed Jan 19, 2024
1 parent 7841411 commit c58b50b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/lib-dynamodb/src/commands/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,18 @@ const processKeysInObj = (obj: any, processFunc: Function, keyNodes: KeyNodeChil
if (Array.isArray(obj)) {
accumulator = [...obj];
} else {
accumulator = { ...obj };
accumulator = {};
for (const [k, v] of Object.entries(obj)) {
if (typeof v !== "function") {
accumulator[k] = v;
}
}
}

for (const [nodeKey, nodes] of Object.entries(keyNodes)) {
if (typeof obj[nodeKey] === "function") {
continue;
}
const processedValue = processObj(obj[nodeKey], processFunc, nodes);
if (processedValue !== undefined) {
accumulator[nodeKey] = processedValue;
Expand All @@ -82,6 +90,9 @@ const processAllKeysInObj = (obj: any, processFunc: Function, keyNodes: KeyNodes
return obj.map((item) => processObj(item, processFunc, keyNodes));
}
return Object.entries(obj).reduce((acc, [key, value]) => {
if (typeof value === "function") {
return acc;
}
const processedValue = processObj(value, processFunc, keyNodes);
if (processedValue !== undefined) {
acc[key] = processedValue;
Expand Down

0 comments on commit c58b50b

Please sign in to comment.