0

I have a "super" module in my Node.js application with a constructor and some prototype functions.

var parser = function(options, util, cache, url) {

    this.options        = options;
    this.util           = util;
    this.cache          = cache;
    this.url            = url;
}

parser.prototype.start = function() {
    console.log("I am a default start function");
    console.log(this.constructor.name);
}

module.exports = parser;

I have a handful of other modules that inherit from this module. Now, when i invoke the start function i would like to get the name of that module's constructor. For some reason this is not working for me.

var parser = require('../parser');
var util   = require('util');

var DKAN = function(options, util, cache, url) {

    parser.apply(this,arguments);

}

util.inherits(DKAN, parser);

DKAN.prototype.check = function($) {
    var DKANParser = this;
    if ($('meta[content*="Drupal"]').length !== 0 ) {
        DKANParser.start();
        return true;
    } else return false;
}

module.exports = DKAN;

When invoking the DKANParser.start() i only get the first console.log with "I am a default start function" and cannot get the name of constructor whih is supposed to be DKAN

4

0 回答 0