Last active
October 7, 2019 16:14
-
-
Save paton/ab27a1be7e843d220ee3 to your computer and use it in GitHub Desktop.
Super simple implementation of define() and require() used in Localize.js (https://localizejs.com)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage: