File: src/components/Tree/Node.ts

Recommend this page to a friend!
  Classes of Dom Hastings   JS Webdav Client   src/components/Tree/Node.ts   Download  
File: src/components/Tree/Node.ts
Role: Class source
Content type: text/plain
Description: Class source
Class: JS Webdav Client
Access files of a Webdav server
Author: By
Last change:
Date: 6 months ago
Size: 863 bytes
 

Contents

Class file image Download
import EventEmitter from '@dom111/typed-event-emitter/EventEmitter'; type NodeEvents = { updated: []; }; export class Node extends EventEmitter<NodeEvents> { #fullPath: string[]; #children: Node[] | null; #name: string; constructor( fullPath: string[], name: string, children: Node[] | null = null ) { super(); this.#fullPath = fullPath; this.#name = name; this.#children = children; } children(): Node[] | null { return this.#children; } fullPath(): string[] { return this.#fullPath; } hasChildren(): boolean | null { if (this.#children === null) { return null; } return this.#children.length > 0; } name(): string { return this.#name; } setChildren(children: Node[]): void { this.#children = children; this.emit('updated'); } } export default Node;