summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorportix <none@none>2013-03-23 12:20:59 +0100
committerportix <none@none>2013-03-23 12:20:59 +0100
commit9407a0638770d48f9021d51731c2ae0e41bd6e81 (patch)
tree7ec0f3b0fa162afb65d688d987538b3882b7a39c /scripts
parent057f6c0a122b30c47a77fe13eb1b3d7885a0fbe3 (diff)
downloaddwb-9407a0638770d48f9021d51731c2ae0e41bd6e81.zip
Deprecate replace, same functionality with provide
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/dwb.js40
-rw-r--r--scripts/lib/extensions.js7
2 files changed, 24 insertions, 23 deletions
diff --git a/scripts/lib/dwb.js b/scripts/lib/dwb.js
index c54dc2b7..752d97cb 100644
--- a/scripts/lib/dwb.js
+++ b/scripts/lib/dwb.js
@@ -4,6 +4,7 @@
var _callbacks = [];
var _initialized = false;
var _pending = [];
+ var _contexts = {};
var _applyRequired = function(names, callback)
{
if (names === null)
@@ -58,7 +59,6 @@
callback.apply(callback, modules);
}
};
- var _contexts = {};
Object.defineProperties(this, {
"Glob" :
{
@@ -177,6 +177,9 @@
*
* @param {String} name The name of the module
* @param {Object} module The module
+ * @param {Boolean} overwrite
+ * Whether to overwrite existing module with
+ * the same name
* @example
* provide("foo", {
* baz : 37,
@@ -186,9 +189,19 @@
* */
"provide" :
{
- value : function(name, module)
+ value : function(name, module, overwrite)
{
- if (_modules[name])
+ if (overwrite)
+ {
+ if (!module && _modules[name])
+ {
+ for (var key in _modules[name])
+ delete _modules[name][key];
+
+ delete _modules[name];
+ }
+ }
+ if (!overwrite && _modules[name])
{
io.debug({
offset : 1, arguments : arguments,
@@ -198,6 +211,7 @@
}
else
_modules[name] = module;
+
var pl = _pending.length;
if (pl > 0)
{
@@ -206,7 +220,9 @@
for (var i=0; i<pl; i++)
{
if (_pending[i].names.every(function(name) { return _modules[name]; }))
+ {
finished.push(_pending[i]);
+ }
else
pending.push(_pending[i]);
}
@@ -217,27 +233,15 @@
}
},
/**
- * Same as provide but replaces modules if they are already defined
* @name replace
* @function
- *
- * @param {String} name The name of the module
- * @param {Object} module The module
- *
+ * @deprecated use {@link provide}
* */
"replace" :
{
- value : function(name, module)
+ value : function()
{
- if (! module && _modules[name] )
- {
- for (var key in _modules[name])
- delete _modules[name][key];
-
- delete _modules[name];
- }
- else
- _modules[name] = module;
+ return _deprecated("replace", "provide", arguments);
}
},
/**
diff --git a/scripts/lib/extensions.js b/scripts/lib/extensions.js
index 3b8896e5..0edab6ec 100644
--- a/scripts/lib/extensions.js
+++ b/scripts/lib/extensions.js
@@ -138,15 +138,12 @@
delete _registered[name];
- replace(name);
+ provide(name, null, true);
return true;
}
return false;
};
- var _onSuccess = function()
- {
- }
Object.defineProperties(extensions,
{
/**
@@ -315,7 +312,7 @@
_registered[name] = plugin;
if (plugin.exports)
- replace(name, plugin.exports);
+ provide(name, plugin.exports, true);
extensions.message(name, "Successfully loaded and initialized.");
}