~technomancy/fennel-lang.org

ref: 10dd8905af0f1c2d8af67b530805215304b1d112 fennel-lang.org/see-worker.lua -rw-r--r-- 783 bytes
10dd8905 — Jesse Wertheim Replace link to freenode with libera.chat 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package.loaded.ffi = {typeof=function() end}
os = {getenv=function() end}
io = {open=function() end}
bit = {band = function(a,b) return a & b end,
       rshift=function(a,b) return a >> b end}
unpack = table.unpack

local antifennel = dofile("antifennel.lua")
local fennel = require("fennel")
local js = require("js")

js.global.onmessage = function(_, e)
   local isFennel = e.data:match("^ ")
   local compiler = isFennel and fennel.compileString or antifennel
   local ok, result = pcall(compiler, e.data)
   if not ok then
      js.global:postMessage(result .. "\n")
   elseif isFennel then
      js.global:postMessage(result .. " ")
   else
      js.global:postMessage(result .. "\t")
   end
end

js.global:postMessage("Loaded Fennel " .. fennel.version .. " in " .. _VERSION)