Utils / Controller / runUserScript
Function: runUserScript()
ts
function runUserScript<T>(
scriptBody,
argNames,
argValues
): Promise<T>;Compiles and runs a user-supplied JS snippet via the AsyncFunction constructor (same family as new Function(...), but the script body may use top-level await).
Meant for the scripts a user writes in the editor of a node (see the CodeEditor component).
No sandboxing/isolation is applied on purpose — same trust model as a Node-RED Function node. The script body may be sync or return a Promise; the result is always awaited so both styles work transparently.
Throws (rejects) on compile or runtime errors — callers are responsible for try/catch and deciding how to react.
Type Parameters
| Type Parameter | Default type |
|---|---|
|
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<T>