Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Created March 14, 2011 17:16
Show Gist options
  • Save robotlolita/869476 to your computer and use it in GitHub Desktop.
Save robotlolita/869476 to your computer and use it in GitHub Desktop.
// 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