Created
October 23, 2013 09:16
-
-
Save luozhihua/7115289 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
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
var ogle = (function() { | |
function Ogle(){} | |
var modules = {}; | |
Ogle.prototype = { | |
define: function(key, func){ | |
modules[key] = func; | |
}, | |
require: function(key, func) { | |
var module = modules[key], | |
props = {}, | |
o = new Ogle(); | |
module(props); | |
for (var k in props) { | |
o[k] = props[k]; | |
} | |
func(o); | |
} | |
}; | |
var a = new Ogle(); | |
a.constructor = null; | |
return a; | |
}()); | |
ogle.define('tools', function(exports){ | |
exports.log = function(m){ | |
console.log('> '+ m); | |
}; | |
}); | |
ogle.require('tools', function(o){ | |
o.log('Hello Ogle!'); | |
o.log(o.a); | |
}); | |
ogle.log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment