https://github.com/brianreavis/microplugin.js Микросистема плагинов для библиотек. `var TextEditor = function(options) { this.initializePlugins(options.plugins); };
MicroPlugin.mixin(TextEditor);
var editor = new TextEditor({
plugins: ['links','images']
});
Плагины создавать очень просто:
MyLibrary.define("math", function(options) { // You can return values which will be available to other plugins // when they load the plugin via "require()". Explained more in // the next section. return { random : Math.random, sqrt : Math.sqrt, sin2 : function(t) { return Math.pow(Math.sin(t), 2); }, cos2 : function(t) { return Math.pow(Math.sin(t), 2); } }; }); Есть система зависимостей: MyLibrary.define("calculations", function(options) {
var math = this.require("math");
var theta = math.random();
var success = math.sqrt(math.sin2(theta) + math.cos2(theta)) === 1;
alert("Does the law of sines work? " + success); });```