mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
Add an examples of CoffeeScript
This commit is contained in:
parent
f847a29b09
commit
327ef6c810
4
app.js
4
app.js
|
@ -228,7 +228,7 @@ function require(FN) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
T = "(function(global){var module=new require.__ModuleObject__();return(function(exports,require,module,__filename,__dirname){"
|
T = "(function(global){var module=new require.__ModulePrototype__();return(function(exports,require,module,__filename,__dirname){"
|
||||||
+ '"use strict";'
|
+ '"use strict";'
|
||||||
+ T
|
+ T
|
||||||
+ "\n\nreturn module.exports})(module.exports,global.require,module,__filename__,__dirname__)})(require.__global__);\n\n////@ sourceURL="
|
+ "\n\nreturn module.exports})(module.exports,global.require,module,__filename__,__dirname__)})(require.__global__);\n\n////@ sourceURL="
|
||||||
|
@ -256,7 +256,7 @@ function require(FN) {
|
||||||
return cache[FN];
|
return cache[FN];
|
||||||
}
|
}
|
||||||
require.__global__ = this;
|
require.__global__ = this;
|
||||||
require.__ModuleObject__ = function() {
|
require.__ModulePrototype__ = function() {
|
||||||
this.exports = {};
|
this.exports = {};
|
||||||
};
|
};
|
||||||
require.__getDirName__ = function(path) {
|
require.__getDirName__ = function(path) {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
fortune = require "lib/fortune.coffee"
|
||||||
|
|
||||||
song = ["do", "re", "mi", "fa", "so"]
|
song = ["do", "re", "mi", "fa", "so"]
|
||||||
|
|
||||||
singers = {Jagger: "Rock", Elvis: "Roll"}
|
singers = {Jagger: "Rock", Elvis: "Roll"}
|
||||||
|
@ -22,5 +24,6 @@ main = (args) ->
|
||||||
console.log bitlist.join(',')
|
console.log bitlist.join(',')
|
||||||
console.log JSON.stringify(kids)
|
console.log JSON.stringify(kids)
|
||||||
console.log "Hello world, CoffeeScript"
|
console.log "Hello world, CoffeeScript"
|
||||||
|
console.log fortune.sayFortune("Foutune!")
|
||||||
|
|
||||||
exports.main = main
|
exports.main = main
|
9
lib/fortune.coffee
Normal file
9
lib/fortune.coffee
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
###
|
||||||
|
Fortune Cookie Reader v1.0
|
||||||
|
Released under the MIT License
|
||||||
|
###
|
||||||
|
|
||||||
|
sayFortune = (fortune) ->
|
||||||
|
console.log fortune # in bed!
|
||||||
|
|
||||||
|
exports.sayFortune = sayFortune
|
Loading…
Reference in New Issue
Block a user