52 lines
1016 B
JavaScript
52 lines
1016 B
JavaScript
/**
|
|
* Expose `AsteroidModule`.
|
|
*/
|
|
|
|
module.exports = AsteroidModule;
|
|
|
|
/**
|
|
* Module dependencies.
|
|
*/
|
|
|
|
var Module = require('module-loader').Module
|
|
, debug = require('debug')('asteroid-module')
|
|
, util = require('util')
|
|
, inherits = util.inherits
|
|
, assert = require('assert');
|
|
|
|
/**
|
|
* Create a new `AsteroidModule` with the given `options`.
|
|
*
|
|
* @param {Object} options
|
|
* @return {AsteroidModule}
|
|
*/
|
|
|
|
function AsteroidModule(options) {
|
|
Module.apply(this, arguments);
|
|
|
|
// throw an error if args are not supplied
|
|
assert(typeof options === 'object', 'AsteroidModule requires an options object');
|
|
|
|
debug('created with options', options);
|
|
}
|
|
|
|
/**
|
|
* Inherit from `Module`.
|
|
*/
|
|
|
|
inherits(AsteroidModule, Module);
|
|
|
|
/**
|
|
* Define an option of the given key/name with the provided type.
|
|
*/
|
|
|
|
AsteroidModule.defineOption = function (key, type, options) {
|
|
var od = this.optionsDefinition = this.optionsDefinition || {};
|
|
|
|
options = options || {};
|
|
options.type = type;
|
|
|
|
od[key] = options;
|
|
}
|
|
|