influxweb
11/3/2014 - 8:11 AM

Super simple implementation of define() and require() used in Localize.js (https://localizejs.com)

Super simple implementation of define() and require() used in Localize.js (https://localizejs.com)

var define, require;

(function() {
  var modules = {};

  require = function(name) {
    return modules[name]();
  };

  define = function(name, fn) {
    var exports;
    
    modules[name] = function() {
      if (!exports) {
        exports = {};
        exports = fn(require, exports) || exports;
      }
      return exports;
    };
  };

})();