javascript - Multiple Inheritance in Node js with constructor set in parent class -
how can set constructor in parent class , call object in class inherited parent class.
parent class:
var request = resuire('request'); var = function(options) { if(!(this instanceof a)) { return new a(options); } var self = this; self.id = math.random(); self.baseurl = 'http://example.com/'; self.options = options || {uri: self._baseurl}; } a.prototype._request = function reqest(options, callback){ var self = this; request(options, function(err, res, body){ self._determineresponse(err, res, body, function(){ return body; }, callback); } }
child class:
var util = require('util'); var = require('a'); var b = function(){ var self = this; } b.prototype.auth(username, password, callback) { // access parent method (private or public) here perform request a._request .... } util.inherits(b, a);
query:
- how set parent constructor
- best way access parent method
Comments
Post a Comment