UNPKG

@scalenc/nc-format

Version:

Library for handling TRUMPF NC file format.

49 lines 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Variables = void 0; class Variables { parent; alias = {}; values = {}; constructor(parent) { this.parent = parent; } get ownKeys() { return Object.keys(this.values); } setAlias(name, target) { this.alias[name.toUpperCase()] = target.toUpperCase(); } tryGetNumber(name) { name = this.getAliasName(name.toUpperCase()); // eslint-disable-next-line security/detect-object-injection return this.values[name] ?? this.parent?.tryGetNumber(name); } hasOwnNumber(name) { name = this.getAliasName(name.toUpperCase()); return Object.keys(this.values).includes(name); } hasNumber(name) { return (this.hasOwnNumber(name) || this.parent?.hasNumber(name)) ?? false; } getNumberOrDefault(name) { return this.tryGetNumber(name) ?? 0.0; } setNumber(name, value) { name = this.getAliasName(name.toUpperCase()); // eslint-disable-next-line security/detect-object-injection this.values[name] = value; } clearOwn() { this.values = {}; } getAliasName(name) { if (this.parent) { name = this.parent.getAliasName(name); } // eslint-disable-next-line security/detect-object-injection return this.alias[name] ?? name; } } exports.Variables = Variables; //# sourceMappingURL=Variables.js.map