I have a class in a file:
// file: MyClass.js
class MyClass {
constructor() {
...
}
...
};
export default MyClass;
And in another file (in another directory):
// file: SomeFile.js
import MyClass from <file_path>;
const instance = MyClass();
I want to get the location of the instance initiation, and I would like to get it in the class itself.. maybe something like that:
// file: MyClass.js
class MyClass {
constructor() {
this.instPath = getInstPath(); // => string of the SomeFile.js path
...
}
...
};
export default MyClass;
I want to get this string path without passing any parameters in the class instance, any ideas?