UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

65 lines (64 loc) 2.36 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var ID = 1; exports.IndexNode = function (base) { return /** @class */ (function (_super) { __extends(IndexNode, _super); function IndexNode() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.id = ID++; _this.children = []; return _this; // findChildById (id : IndexNodeId) : IndexNode | null { // let child // // this.forEach(node => { // if (node.id === id) { child = node; return false } // }) // // return child // } } IndexNode.prototype.addChild = function (child) { this.children.push(child); return child; }; IndexNode.prototype.traverse = function (func) { var children = this.children; if (func(this) === false) return false; for (var i = 0; i < children.length; i++) if (children[i].traverse(func) === false) return false; }; IndexNode.prototype.forEachChild = function (func) { var children = this.children; for (var i = 0; i < children.length; i++) if (func(children[i]) === false) return false; }; IndexNode.prototype.getRoot = function () { var root = this; while (root.parent) root = root.parent; return root; }; IndexNode.prototype.isRoot = function () { return !Boolean(this.parent); }; return IndexNode; }(base)); };