The question is how to refer to other static methods from a static method of a class exported from NodeJS module? Here's a setup. I have following modules: test1.js
var Parent = class {
static smethod1 () {
return this.smethod2();
}
static smethod2 () {
return "Testing tube";
}
}
module.exports = {
Parent:Parent
}
Then I have test2.js that requires this module
var mod = require('./test1');
var Parent = mod.Parent;
module.exports = {
sm1: Parent.smethod1,
sm2: Parent.smethod2
}
Finally, I have a code that is being run in run.js
var test2 = require('./test2');
console.log(test2.sm1());
Naturally, I want to see "Testing tube" line printed out. I am getting error
return this.smethod2();
^
TypeError: this.smethod2 is not a function
Of course, there's shenanigans on NodeJS where this refers to a module, but shouldn't it be referring to a function instead ? Is there way to refer to static method smethod2 from smethod1 with current setup ? If not, what are the workarounds ?