MCPcopy Create free account
hub / github.com/apitable/apitable / objectCombOperand

Function objectCombOperand

packages/core/src/automation_manager/utils.ts:145–170  ·  view source on GitHub ↗
(operands: any[])

Source from the content-addressed store, hash-verified

143 * @param operands
144 */
145export const objectCombOperand = (operands: any[]) => {
146 const newItems: any[] = [];
147 for (let idx = 0; idx < operands.length; idx += 2) {
148 // idx 0 2 4 6 8
149 const itemKey = operands[idx]; // 0
150 const itemValue = operands[idx + 1]; //1
151 // even numbers is key & odd numbers is value
152 const newItemKeys = newItems.filter((_item, index) => {
153 return index % 2 === 0;
154 });
155 const itemKeyIndex = newItemKeys.findIndex(key => isEqual(key, itemKey));
156 if (itemKeyIndex > -1) {
157 const itemValueIndex = itemKeyIndex * 2 + 1;
158 const oldItemValue = newItems[itemValueIndex];
159 if (isObjectOperand(oldItemValue) && isObjectOperand(itemValue)) {
160 newItems[itemValueIndex] = mergeOperand(oldItemValue, itemValue);
161 } else {
162 newItems[itemValueIndex] = itemValue;
163 }
164 } else {
165 newItems.push(itemKey);
166 newItems.push(itemValue);
167 }
168 }
169 return newItems;
170};
171export const removeArrayOperandItemByIndex = (arrayOperand: any, index: number) => {
172 return produce(arrayOperand, (draft: any) => {
173 if (isOperand(draft)) {

Callers 3

onPropertyChangeFunction · 0.90
mergeOperandFunction · 0.85

Calls 5

isObjectOperandFunction · 0.85
mergeOperandFunction · 0.85
findIndexMethod · 0.80
filterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected