import { Node } from 'node-graph-engine'; export class Selected { nodes = new Map(); add (node: Node, allowMultipleSelected = false) { if (!allowMultipleSelected) { this.nodes.clear(); this.nodes.set(node.id, node); } else if (!this.nodes.has(node.id)) { this.nodes.set(node.id, node); } } clear () { this.nodes.clear(); } remove (node: Node) { this.nodes.delete(node.id); } contains (node: Node) { return this.nodes.has(node.id); } each (callback: (node: Node, index: number) => void) { this.nodes.forEach(callback); } }