Reputation: 1610
I need to require a file passing a parameter, for this I used the following syntax:
module.exports = function(bot) {
const menu = new TelegrafInlineMenu(bot);
return menu;
};
the problem's that the code above export the function, I need to return the menu
object, is there a way to do this?
I require the script using:
const menu = require('menu')(bot);
problem's that menu
is a function not an object
Upvotes: 0
Views: 48
Reputation: 26296
function TelegrafInlineMenu(bot) {
// constructor
if (!(this instanceof TelegrafInlineMenu)) {
return new TelegrafInlineMenu(bot);
}
}
TelegrafInlineMenu.prototype.someFunction = function () {
// etc.
};
module.exports = TelegrafInlineMenu;
Upvotes: 1