Buckets:
| const logs = []; | |
| const fmt = (value) => { | |
| if (typeof value === 'string') return value; | |
| try { | |
| return JSON.stringify(value); | |
| } catch { | |
| return String(value); | |
| } | |
| }; | |
| const capture = | |
| (level, prefix) => | |
| (...args) => { | |
| logs.push(prefix + args.map(fmt).join(' ')); | |
| }; | |
| console.log = capture('log', ''); | |
| console.info = capture('info', ''); | |
| console.debug = capture('debug', ''); | |
| console.warn = capture('warn', 'warn: '); | |
| console.error = capture('error', 'error: '); | |
| self.onmessage = async (event) => { | |
| const reply = { logs, result: null, error: null }; | |
| try { | |
| const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; | |
| // The prelude bundled ahead of this shim defines self.nerdamer, | |
| // passed into the execution scope as the `nerdamer` parameter. | |
| const value = await new AsyncFunction('nerdamer', event.data.code)(self.nerdamer); | |
| if (value !== undefined) reply.result = fmt(value); | |
| } catch (err) { | |
| reply.error = err instanceof Error ? err.stack || err.message : String(err); | |
| } | |
| self.postMessage(reply); | |
| }; | |
Xet Storage Details
- Size:
- 1.04 kB
- Xet hash:
- ef312a87ee6a925995389d06eaa24b695e97c42c3b5a470ea235785194f00ad3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.