Skip to content

Instantly share code, notes, and snippets.

@espadrine
Created June 26, 2012 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espadrine/2997742 to your computer and use it in GitHub Desktop.
Save espadrine/2997742 to your computer and use it in GitHub Desktop.
Isaac's Module Idea
let {sum, pi} = import './math.js';
alert('2n = ' + sum(pi, pi));
let O = import './cyclic2.js';
export { even: function(n) { return n == 0 || O.odd(n - 1); } };
// `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); } };
Loader.load('http://json.org/modules/json2.js',
function(JSON) {
alert(JSON.stringify([0, {a: true}]));
});
// A simple math module.
export {
sum: function(x, y) {
return x + y;
},
pi: 3.141593,
};
let widgets = import './widgets.js';
let {messageBox, confirmDialog} = widgets.alert;
let M = import './math.js';
alert('2n = ' + M.sum(M.pi, M.pi));
let drawShape = shape.draw;
let drawGun = cowboy.draw;
<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>
export {
button: import './button.js',
alert: import './alert.js',
textarea: import './textarea.js',
};
@dherman
Copy link

dherman commented Jun 26, 2012

The renaming example is backwards. Should be:

let drawShape = shape.draw;
let drawGun = cowboy.draw;

Dave

@espadrine
Copy link
Author

@dherman: Oops. Fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment