alamid-list
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -235,5 +235,7 @@ "use strict"; | ||
/** | ||
* Calls the given function with the View as first argument and the given config (optionally). Plugins can be used | ||
* Calls the given function with the List as first argument and the given config (optionally). Plugins can be used | ||
* to hook into class methods by overriding them. | ||
* | ||
* You may call this function multiple times with the same plugin, the plugin will only be applied once. | ||
* | ||
* @param {Function} plugin | ||
@@ -244,4 +246,9 @@ * @param {Object=} config | ||
List.use = function (plugin, config) { | ||
plugin(this, config); | ||
this._plugins = this._plugins || []; | ||
if (this._plugins.indexOf(plugin) === -1) { | ||
plugin(this, config); | ||
this._plugins.push(plugin); | ||
} | ||
return this; | ||
@@ -248,0 +255,0 @@ }; |
{ | ||
"name": "alamid-list", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Simple observable arrays", | ||
@@ -5,0 +5,0 @@ "main": "./lib/List.js", |
@@ -49,2 +49,8 @@ "use strict"; | ||
it("should apply the same plugin only once", function () { | ||
List.use(plugin, config); | ||
List.use(plugin, config); | ||
expect(plugin).to.have.been.calledOnce; | ||
}); | ||
it("should be usable on other objects too", function () { | ||
@@ -51,0 +57,0 @@ var otherObj = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52128
1280