UNPKG

cognitive-complexity-ts

Version:

This program analyses TypeScript and JavaScript code according to the [Cognitive Complexity metric](https://www.sonarsource.com/docs/CognitiveComplexity.pdf). It produces a JSON summary and a GUI for exploring the complexity of your codebase.

35 lines 1.1 kB
import { ToggleableBox } from "../box/ToggleableBox.js"; import { CopyText } from "../controls/CopyText.js"; import { concatFilePath } from "../../domain/path.js"; import { showInTree, StickyTitle } from "./StickyTitle.js"; export class Folder { constructor(folder, children) { this.content = children; this.depth = folder.depth; const fullPath = concatFilePath(folder.path, folder.name); this.title = new StickyTitle([ folder.name, CopyText(fullPath), ], folder.depth); this.box = new ToggleableBox([ this.title.dom, ], false, () => this.scrollIntoView()); this.box.changeHideableContent(() => [this.content.dom]); } get dom() { return this.box.dom; } scrollIntoView() { showInTree(this.dom, this.depth); } setDepth(depth) { if (this.depth !== depth) { this.depth = depth; this.title.setDepth(depth); } } setOpenness(open) { this.box.setOpenness(open); } } //# sourceMappingURL=Folder.js.map