FEATURE: hasModule global helper to figure out if module exists

This commit is contained in:
Sam 2014-12-31 12:29:18 +11:00
parent 43c3e6b47f
commit 2aec93c13d
2 changed files with 6 additions and 1 deletions

View File

@ -49,6 +49,7 @@
"notEqual",
"require",
"requirejs",
"hasModule",
"Blob",
"File"],
"node" : false,

View File

@ -1,4 +1,4 @@
var define, requireModule, require, requirejs;
var define, requireModule, require, requirejs, hasModule;
(function() {
var registry = {}, seen = {}, state = {};
@ -32,6 +32,10 @@ var define, requireModule, require, requirejs;
};
}
hasModule = function(name){
return !!registry[name];
};
requirejs = require = requireModule = function(name) {
if (state[name] !== FAILED &&
seen.hasOwnProperty(name)) {