Reputation: 2208
In foo.js
class Foo {
run(){
console.log("test");
}
}
In index.js
'use strict'
var test = require('./foo.js'),
Test = new test();
Test.run();
How to export the Foo class in iojs 3?
I tryed this way and worked, but i dont know if this is the right way:
module.exports = class Foo {
run(){
console.log("test");
}
}
Upvotes: 0
Views: 297
Reputation: 388
In current io.js you can do something like this to get your class exported so it can be imported with require():
'use strict'
class Foo {
}
module.exports = Foo;
and
const Foo = require('./foo');
Upvotes: 0