* Creates a new node with updated data (immutable) * 创建具有更新数据的新节点(不可变)
(data: Record<string, unknown>)
| 242 | * 创建具有更新数据的新节点(不可变) |
| 243 | */ |
| 244 | updateData(data: Record<string, unknown>): GraphNode { |
| 245 | const node = this.clone(); |
| 246 | node._data = { ...node._data, ...data }; |
| 247 | return node; |
| 248 | } |
| 249 | |
| 250 | private clone(): GraphNode { |
| 251 | const cloned = Object.create(GraphNode.prototype) as GraphNode; |