Created
March 14, 2011 17:16
-
-
Save robotlolita/869476 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// base.js: | |
function PluginBase() { | |
this.something = 1 | |
} | |
PluginBase.prototype.something = function () { | |
console.log("in base class") | |
} | |
exports.PluginBase = PluginBase | |
///////////////////////////////// | |
// plugin.js | |
var inherit = require('util').inherits | |
var PluginBase = require('./base.js').PluginBase | |
inherit(Plugin, PluginBase) | |
function Plugin() { | |
console.log("constructor") | |
} | |
Plugin.prototype.some_method = function() { | |
console.log("in loaded plugin") | |
this.something() | |
} | |
exports.Plugin = Plugin | |
////////////////////////////////////////////////// | |
// test.js | |
var Plugin = require('./plugin').Plugin | |
var instance = new Plugin() | |
instance.some_method() // in loaded plugin | |
instance.something() // in base class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment