JS: Move JavaScript to commandbar subdirectory

This commit is contained in:
Eryn Wells 2024-08-07 08:11:45 -10:00
parent ccd2a25920
commit 563693fb79
5 changed files with 0 additions and 0 deletions

View file

@ -1,54 +0,0 @@
class Term {
stringValue;
constructor(stringValue) {
this.stringValue = stringValue;
}
toString() {
return `Term[${stringValue}]`;
}
valueOf() {
return this.stringValue;
}
}
export class NumberTerm extends Term {
value;
constructor(stringValue) {
super(stringValue);
const parsedValue = parseInt(stringValue);
if (isNaN(parsedValue)) {
throw new TypeError("Number value is not a valid number");
}
this.value = parsedValue;
}
valueOf() {
return this.value;
}
toString() {
return `Number[${this.value}]`;
}
}
export class NameTerm extends Term {
static regex = /[-\w]+/;
constructor(stringValue) {
if (!NameTerm.regex.test(stringValue)) {
throw new TypeError("Name must be string with non-zero length");
}
super(stringValue);
}
toString() {
return `Name[${this.stringValue}]`;
}
}