Skip to content

Instantly share code, notes, and snippets.

@temsa
Created January 4, 2011 10:57
Show Gist options
  • Save temsa/764653 to your computer and use it in GitHub Desktop.
Save temsa/764653 to your computer and use it in GitHub Desktop.
A possible module syntax
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