Optimized Performance with Targeted Cloning (Managed Package)

To maximize performance, clone only the specific object nodes that you want to modify. This approach creates an object where only the specified node is modifiable, and the other nodes of the object remain in their original read-only state.

REQUIRED EDITIONS
Available in: Lightning Experience
Available in: Enterprise, Developer, and Unlimited Editions

Cloning Specific Nodes

Managed Package Icon This feature is part of the Communications Cloud managed package.

This process makes sure that you make modifiable copies of only the specific nodes that you want to modify.

Example
Example

This example uses the map() iterator to create modifiable copies of only the necessary attribute nodes.

let newModifiableNode = childLineItem.originalNonModifiableAttributeNode?.map(originalNonModifiableAttribute => {
    let attr = enhancedDeepClone(originalNonModifiableAttribute); // This copy is modifiable
    attr.binded = childLineItem.action === 'Add' && this.bindedAttributes[childLineItem.PricebookEntry.Product2.ProductCode] !== undefined && this.bindedAttributes[childLineItem.PricebookEntry.Product2.ProductCode].includes(attr.code);
    return attr;
    });

Reinsert the new modifiable node into the original object after cloning.

childLineItem = {...childLineItem, originalNonModifiableAttributeNode: newModifiableNode};