refactor: restructure repo layout

This commit is contained in:
2026-03-27 10:24:55 +01:00
parent 1a6d5a7dda
commit 648fef9929
95 changed files with 33 additions and 44 deletions

View File

@@ -0,0 +1,22 @@
/**
* Execute the javascript code in node.js.
* @typedef {Object} Args
* @property {string} code - Javascript code to execute, such as `console.log("hello world")`
* @param {Args} args
*/
exports.run = function ({ code }) {
let output = "";
const oldStdoutWrite = process.stdout.write.bind(process.stdout);
process.stdout.write = (chunk, _encoding, callback) => {
output += chunk;
if (callback) callback();
};
const value = eval(code);
if (value !== undefined) {
output += value;
}
process.stdout.write = oldStdoutWrite;
return output;
}