Created
January 4, 2011 10:57
-
-
Save temsa/764653 to your computer and use it in GitHub Desktop.
A possible module syntax
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
module.name("foobar") | |
.import("bar/foo").as("foo") | |
.import("baz")//.as("baz") is implied | |
.declare(function(require) { | |
var foo = require("foo"), | |
bazbar = require("baz").bar; | |
return {hello: foo.bar, world: bazbar}; | |
}); | |
//-- An alternative syntax, more DRY, more concise, quite easy to understand as well, but a little more difficult already | |
module.name("foobar")// name could be optionnal, provided by bundlers if needed | |
.import("bar/foo") | |
.import("baz") | |
.define(function(foo, baz) { | |
return {hello: foo.bar, world: baz.bar}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment