if you're making a term that you want to use again and again, you PROBABLY don't want to use the "with" method to create it. it's PROBABLY more useful to [just] have it in hand as a full class. because then you can use it again and again without needing to REMEMBER how to make it.
again, this language bites off a number, using the number term class.
TRANSLATED:
it's easy. make a term class that extends the term class you want to extend.
class NumberTerm extends RegExpTerm {
constructor() {
super(/\d+/)
}
}
and OVERRIDE what you want to OVERRIDE.
class NumberTerm extends RegExpTerm {
//...
name() {
return "number"
}
}
then use it.
const numberTerm = new NumberTerm()
function translate(text) {
return numberTerm.translate(text)
}
back to the dream