Created
December 17, 2012 18:09
-
-
Save kazupon/4320463 to your computer and use it in GitHub Desktop.
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 () { | |
// imports | |
//var _ = this._ || require('underscore'); | |
// common function 1 | |
var add = function (a, b) { | |
return a + b; | |
}; | |
// common function 2 | |
var sub = function (a, b) { | |
return a - b; | |
}; | |
// exports | |
this.add = add; | |
this.sub = sub; | |
}).call(this); |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<title>Common module</title> | |
<script type="text/javascript" charset="utf-8" src="./common.js"></script> | |
</head> | |
<body> | |
<script type="text/javascript" charset="utf-8"> | |
console.log('add', add(1, 1)); | |
console.log('sub', sub(10, 1)); | |
</script> | |
</body> | |
</html> |
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
var add = require('./common').add; | |
var sub = require('./common').sub; | |
console.log('add', add(1, 1)); | |
console.log('sub', sub(10, 1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment