Files
cell/scripts/js.cm
2025-06-02 08:18:08 -05:00

51 lines
1.5 KiB
Plaintext

var js = this
js[cell.DOC] = `
Provides functions for introspecting and configuring the QuickJS runtime engine.
Includes debug info, memory usage, GC controls, code evaluation, etc.
`
js.calc_mem[cell.DOC] = `
:param value: A JavaScript value to analyze.
:return: Approximate memory usage (in bytes) of that single value.
Compute the approximate size of a single JS value in memory. This is a best-effort estimate.
`
js.mem_limit[cell.DOC] = `
:param bytes: The maximum memory (in bytes) QuickJS is allowed to use.
:return: None
Set the upper memory limit for the QuickJS runtime. Exceeding this limit may cause operations to
fail or throw errors.
`
js.gc_threshold[cell.DOC] = `
:param bytes: The threshold (in bytes) at which the engine triggers automatic garbage collection.
:return: None
Set the threshold (in bytes) for QuickJS to perform an automatic GC pass when memory usage surpasses it.
`
js.max_stacksize[cell.DOC] = `
:param bytes: The maximum allowed stack size (in bytes) for QuickJS.
:return: None
Set the maximum stack size for QuickJS. If exceeded, the runtime may throw a stack overflow error.
`
js.gc[cell.DOC] = `
:return: None
Force an immediate, full garbage collection pass, reclaiming unreachable memory.
`
js.eval[cell.DOC] = `
:param src: A string of JavaScript source code to evaluate.
:param filename: (Optional) A string for the filename or label, used in debugging or stack traces.
:return: The result of evaluating the given source code.
Execute a string of JavaScript code in the current QuickJS context.
`
return js