(state: NodeState | undefined)
| 306 | } |
| 307 | |
| 308 | private pvtSerialize(state: NodeState | undefined): NodeState { |
| 309 | const item: NodeState = { |
| 310 | name: this.name, |
| 311 | expr: this.expr, |
| 312 | expanded: this.expanded || !this.parent, |
| 313 | children: [] |
| 314 | }; |
| 315 | if (!state) { |
| 316 | state = item; |
| 317 | } else { |
| 318 | state.children.push(item); |
| 319 | } |
| 320 | for (const child of this.children ?? []) { |
| 321 | child.pvtSerialize(item); |
| 322 | } |
| 323 | return item; |
| 324 | } |
| 325 | |
| 326 | public serialize(): NodeState { |
| 327 | return this.pvtSerialize(undefined); |