Last active
August 29, 2015 14:00
-
-
Save fflorent/11225982 to your computer and use it in GitHub Desktop.
AMD using require and the default parameters
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
/** | |
* AMD's define function using ES6 default parameter and require. | |
* | |
* With some tweaks of AMD and using an ES6 Browser, this idioms intends to improve readability | |
* and maintainability of modules declared with define()... At least, until browsers implement | |
* ES6 Modules. | |
*/ | |
define("mymodule", function( | |
r = require, | |
module1 = r("module1"), | |
lib1 = r("lib/lib1"), | |
... | |
) { | |
var MyModule = {}; | |
// .... | |
return MyModule; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment