I have a simple module, it's code
var Router = function(pattern) {
this.setRoutePattern(pattern);
};
Router.prototype = {
setRoutePattern: function(){
this._pattern = pattern || "controller/action/id";
}
};
module.exports.router = Router;
then in my other file I want to use router and have the following code:
var router = require('./../routing').router();
But this line of code fail with no method exception
Object #<Object> has no method 'setRoutePattern'
Why this happened, why prototype methods do not visible in constructor if I load code with require function?
Router? It probably shouldn't (SRP), so you could just havemodule.exports = Router;