UNPKG

ccs-sim

Version:
78 lines (77 loc) 2.07 kB
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== 'function' && b !== null) throw new TypeError( 'Class extends value ' + String(b) + ' is not a constructor or null', ); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); }; })(); import TreeNode from './treeNode'; import { postOrder } from './traversal'; var Point = /** @class */ (function (_super) { __extends(Point, _super); function Point(props) { return _super.call(this, props) || this; } Point.prototype.calcPressure = function () { var _this = this; var min = Infinity; var selectLowerPressure = function (n) { if (n !== _this) min = Math.min(min, n.pressure); }; postOrder(this, selectLowerPressure); return min; }; Object.defineProperty(Point.prototype, 'pressure', { get: function () { return this.calcPressure(); }, enumerable: false, configurable: true, }); Object.defineProperty(Point.prototype, 'flowrate', { get: function () { var _this = this; var sum = 0; var addFlow = function (n) { if (n !== _this) sum += n.flowrate; }; postOrder(this, addFlow); return sum; }, enumerable: false, configurable: true, }); Object.defineProperty(Point.prototype, 'temperature', { get: function () { return 10; }, enumerable: false, configurable: true, }); return Point; })(TreeNode); export default Point;