From 2aec93c13d9cf75ffab56baac9d7d0ec853e10e8 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 31 Dec 2014 12:29:18 +1100 Subject: [PATCH] FEATURE: hasModule global helper to figure out if module exists --- .jshintrc | 1 + vendor/assets/javascripts/loader.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index a8d17196ecc..bc41ce0afef 100644 --- a/.jshintrc +++ b/.jshintrc @@ -49,6 +49,7 @@ "notEqual", "require", "requirejs", + "hasModule", "Blob", "File"], "node" : false, diff --git a/vendor/assets/javascripts/loader.js b/vendor/assets/javascripts/loader.js index eaee097c7d7..b05ae92b2ed 100644 --- a/vendor/assets/javascripts/loader.js +++ b/vendor/assets/javascripts/loader.js @@ -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)) {