Created
June 26, 2012 18:25
-
-
Save espadrine/2997742 to your computer and use it in GitHub Desktop.
Isaac's Module Idea
This file contains 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
let {sum, pi} = import './math.js'; | |
alert('2n = ' + sum(pi, pi)); |
This file contains 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
let O = import './cyclic2.js'; | |
export { even: function(n) { return n == 0 || O.odd(n - 1); } }; |
This file contains 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
// `cyclic1.js`' exports are evaluated at runtime, so this throws an error. | |
let E = import './cyclic1.js'; | |
export { odd: function(n) { return n != 0 && E.even(n-1); } }; |
This file contains 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
Loader.load('http://json.org/modules/json2.js', | |
function(JSON) { | |
alert(JSON.stringify([0, {a: true}])); | |
}); |
This file contains 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
// A simple math module. | |
export { | |
sum: function(x, y) { | |
return x + y; | |
}, | |
pi: 3.141593, | |
}; |
This file contains 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
let widgets = import './widgets.js'; | |
let {messageBox, confirmDialog} = widgets.alert; |
This file contains 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
let M = import './math.js'; | |
alert('2n = ' + M.sum(M.pi, M.pi)); |
This file contains 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
let drawShape = shape.draw; | |
let drawGun = cowboy.draw; |
This file contains 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
<script module="JSON" src="http://json.org/modules/json2.js"></script> | |
<script module="YUI" src="http://developer.yahoo.com/modules/yui3.js"></script> | |
<script> | |
alert(JSON.stringify({'hi': 'world'})); | |
alert(YUI.dom.Color.toHex('blue')); | |
</script> |
This file contains 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
export { | |
button: import './button.js', | |
alert: import './alert.js', | |
textarea: import './textarea.js', | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The renaming example is backwards. Should be:
Dave