aboutsummaryrefslogtreecommitdiffstats
path: root/lib/init.server.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-11-01 10:17:55 +0000
committers-ol <s-ol@users.noreply.github.com>2018-11-01 10:17:55 +0000
commit30fb0dc40d595b9e0b7747ad8e5c4e8cf7e3023b (patch)
treedc56f20ec4d78115e15761c402589b5aec94ef55 /lib/init.server.moon
parentdefer all scripts (diff)
downloadmmm-30fb0dc40d595b9e0b7747ad8e5c4e8cf7e3023b.tar.gz
mmm-30fb0dc40d595b9e0b7747ad8e5c4e8cf7e3023b.zip
move mmm code from lib to mmm etc
Diffstat (limited to 'lib/init.server.moon')
-rw-r--r--lib/init.server.moon60
1 files changed, 0 insertions, 60 deletions
diff --git a/lib/init.server.moon b/lib/init.server.moon
deleted file mode 100644
index cc3851d..0000000
--- a/lib/init.server.moon
+++ /dev/null
@@ -1,60 +0,0 @@
-export MODE, print, warn, relative, on_client
-MODE = 'SERVER'
-
-deep_tostring = (tbl, space='') ->
- buf = space .. tostring tbl
-
- return buf unless 'table' == type tbl
-
- buf = buf .. ' {\n'
- for k,v in pairs tbl
- buf = buf .. "#{space} [#{k}]: #{deep_tostring v, space .. ' '}\n"
- buf = buf .. "#{space}}"
- buf
-
-print = do
- _print = print
- (...) ->
- contents = [deep_tostring v for v in *{ ... } ]
- _print table.unpack contents
-
--- warning messages
-warn = (...) ->
- contents = [deep_tostring v for v in *{ ... } ]
- io.stderr\write table.concat contents, '\t'
- io.stderr\write '\n'
-
--- relative imports
-relative = do
- _require = require
-
- (base, sub) ->
- sub = 0 unless 'number' == type sub
-
- for i=1, sub
- base = base\match '^(.*)%.%w+$'
-
- (name, x) ->
- name = base .. name if '.' == name\sub 1, 1
- _require name
-
-import compile, insert_loader from require 'lib.duct_tape'
-insert_loader!
-
-on_client = (fn, ...) ->
- args = {...}
- -- warn code
- "<script type=\"application/lua\">
- local fn = #{compile fn}
- on_load = on_load or {}
- table.insert(on_load, function()
- fn(#{table.concat [string.format '%q', v for v in *args ], ', '})
- end)
- </script>"
-
-{
- -- access / flush the appended data
- flush: ->
- with x = buffer
- buffer = ''
-}