mirror of
https://github.com/less/less.js.git
synced 2026-01-23 14:18:00 -05:00
- Limited @import (plugin) support to add/addMultiple of functions - Altered @import (plugin) loading to support browser - Support proper closure scoping of @import (plugin) loaded functions
29 lines
874 B
JavaScript
29 lines
874 B
JavaScript
function makeRegistry( base ) {
|
|
return {
|
|
_data: {},
|
|
add: function(name, func) {
|
|
// precautionary case conversion, as later querying of
|
|
// the registry by function-caller uses lower case as well.
|
|
name = name.toLowerCase();
|
|
|
|
if (this._data.hasOwnProperty(name)) {
|
|
//TODO warn
|
|
}
|
|
this._data[name] = func;
|
|
},
|
|
addMultiple: function(functions) {
|
|
Object.keys(functions).forEach(
|
|
function(name) {
|
|
this.add(name, functions[name]);
|
|
}.bind(this));
|
|
},
|
|
get: function(name) {
|
|
return this._data[name] || ( base && base.get( name ));
|
|
},
|
|
inherit : function() {
|
|
return makeRegistry( this );
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = makeRegistry( null ); |