From 327ef6c8103eab259b21d21bb3eb396269a43410 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 29 Nov 2022 02:38:11 +0900 Subject: [PATCH] Add an examples of CoffeeScript --- app.js | 4 ++-- helloworld.coffee | 3 +++ lib/fortune.coffee | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 lib/fortune.coffee diff --git a/app.js b/app.js index 2bf9b5c..091aa0f 100644 --- a/app.js +++ b/app.js @@ -228,7 +228,7 @@ function require(FN) { } // 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";' + T + "\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]; } require.__global__ = this; -require.__ModuleObject__ = function() { +require.__ModulePrototype__ = function() { this.exports = {}; }; require.__getDirName__ = function(path) { diff --git a/helloworld.coffee b/helloworld.coffee index a5f4888..3ae8fe2 100644 --- a/helloworld.coffee +++ b/helloworld.coffee @@ -1,3 +1,5 @@ +fortune = require "lib/fortune.coffee" + song = ["do", "re", "mi", "fa", "so"] singers = {Jagger: "Rock", Elvis: "Roll"} @@ -22,5 +24,6 @@ main = (args) -> console.log bitlist.join(',') console.log JSON.stringify(kids) console.log "Hello world, CoffeeScript" + console.log fortune.sayFortune("Foutune!") exports.main = main \ No newline at end of file diff --git a/lib/fortune.coffee b/lib/fortune.coffee new file mode 100644 index 0000000..53acb3e --- /dev/null +++ b/lib/fortune.coffee @@ -0,0 +1,9 @@ +### +Fortune Cookie Reader v1.0 +Released under the MIT License +### + +sayFortune = (fortune) -> + console.log fortune # in bed! + +exports.sayFortune = sayFortune \ No newline at end of file