-
-
Save rwaldron/1463586 to your computer and use it in GitHub Desktop.
`given(d).define(m)` - an alternative to `define(d,m)`
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
function define() { | |
console.log( arguments ); | |
} | |
function given( dependencies ) { | |
return { | |
define: function( id, module ) { | |
if ( module != null ) { | |
// Assume the first arg is the module | |
module = id; | |
id = undefined; | |
} | |
return define( id, dependencies, module ); | |
} | |
}; | |
} | |
// usage: | |
given(['foo', 'bar']).define(function( foo, bar ) { | |
// Return a value for the module being defined | |
}); | |
// Normally the ID isn't explicitly set, used by build systems | |
given(['foo', 'bar']).define('myModule', function( foo, bar ) { | |
// Same as above | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment