Sorry if the question is too simple, but I missed something. Just switched the ES5 module, which looked like this:
module.exports = { func1: function(a, b) {...}, func2: function(a, b) {...} };
For the ES6 class, which looks like this:
export default class { func1(a, b) {...} func2(a, b) {...} }
And all was well: in both cases I could export mod from 'module'; and call mod.func1(a, b) and mod.func2(a, b) .
However, I have a function that gets a module function to call:
var caller = function(func, val1, val2) { let a = something(val1); let b = something(val2); return func(a, b); };
When I call caller(mod.func1, x, y) , I get the desired result with the first implementation, but undefined is not a function with the second.
The mod.func1 returns [Function] in both cases, but obviously something else is returning from the ES6 class.
What am I doing wrong, and how can I get a class function that I can call in another function?
Update: with the second implementation, I forgot to add the instance code:
import Mod from 'module'; var mod = new Mod();