mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-16 21:54:16 +00:00
2 lines
821 B
JavaScript
2 lines
821 B
JavaScript
(()=>{function s(r){let e=[],a=new Uint8Array(1024);for(;;){let n=0;try{n=Javy.IO.readSync(0,a)}catch(o){if(o.message.includes("os error 29"))break;throw new Error("Error reading from stdin")}if(n<0)throw new Error("Error reading from stdin");if(n===0)break;if(e=[...e,...a.subarray(0,n)],!e.includes(10))continue;let t=0;for(let o=0;t<e.length;t++)if(e[t]===10){let u=e.splice(o,t+1),i=new Uint8Array(u),d;try{d=JSON.parse(new TextDecoder().decode(i))}catch(w){throw new Error(`Error parsing JSON '${new TextDecoder().decode(i)}' from stdin: ${w.message}`)}r(d),o=t+1}e=e.slice(t)}}function f(r){let c=new TextEncoder().encode(JSON.stringify(r)+`
|
|
`),e=new Uint8Array(c);Javy.IO.writeSync(1,e)}var p=function(r){f({header:r.header,data:{greeting:"Hello "+r.data.name+"!"}})};console.log("Greet module loaded");s(p);})();
|