summaryrefslogtreecommitdiff
path: root/lib/fortune.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-08 02:18:49 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-08 02:18:49 +0100
commitbbbd8bbab8737f5067c85376daf79cd8a5a9c4cb (patch)
tree844d1385d7b88623eee3c2ea2c420280006ad349 /lib/fortune.js
parente4e0cf21a31b74d5ee1e6d45b343ea60ed44f372 (diff)
parentdf674eef8e20c43426c0af5aa3d1a09b5e24c58a (diff)
merge
Diffstat (limited to 'lib/fortune.js')
-rw-r--r--lib/fortune.js28
1 files changed, 0 insertions, 28 deletions
diff --git a/lib/fortune.js b/lib/fortune.js
deleted file mode 100644
index 7adba5a..0000000
--- a/lib/fortune.js
+++ /dev/null
@@ -1,28 +0,0 @@
-function choice (a){ return a[ Math.floor(Math.random()*a.length) ] }
-
-var fs = require("fs"), path = require("path")
-var fortunes = {}
-var dir = "fortune"
-
-fs.readdirSync(path.resolve(dir)).forEach(function(fn){
-
- var file = dir + '/' + fn
- var stat = fs.statSync(file)
-
- if (stat && ! stat.isDirectory()) {
- fortunes[fn] = fs.readFileSync(file)
- .toString()
- .split("\n")
- .filter(function(s){ return !! s })
- }
-
-})
-
-module.exports = function(tag){
- if (tag in fortunes) {
- return choice(fortunes[tag])
- }
- else {
- return "bucky"
- }
-} \ No newline at end of file