From 172e4cc857849826c48bdf4d3e052bde28ecbf46 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Wed, 24 Dec 2025 14:58:33 -0600 Subject: [PATCH] add docs about script.js processor --- astro.config.mjs | 5 +++++ src/content/docs/processors/script/js.mdx | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/content/docs/processors/script/js.mdx diff --git a/astro.config.mjs b/astro.config.mjs index 70ea094..96bc080 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -81,6 +81,11 @@ export default defineConfig({ collapsed: true, autogenerate: { directory: 'processors/string' } }, + { + label: "Script", + collapsed: true, + autogenerate: { directory: 'processors/script' } + }, ] }, { diff --git a/src/content/docs/processors/script/js.mdx b/src/content/docs/processors/script/js.mdx new file mode 100644 index 0000000..3640bf4 --- /dev/null +++ b/src/content/docs/processors/script/js.mdx @@ -0,0 +1,23 @@ +--- +title: JavaScript +sidebar: + order: 1 +--- + +The `script.js` processor takes in any payload type and executes a JavaScript function that is able to process the payload. The end value of `payload` will be returned as the output of the processor. + +Ending with a `payload` value of `undefined` is treated the same as any other processor returning `nil`. + +This run your JavaScript program in a [sandboxed environment](https://gitlab.com/cznic/quickjs). It currently support the [ES2023](https://tc39.es/ecma262/2023/) specification. + +- **type**: `script.js` +- **params**: + - **program**: The JavaScript program to run. The payload is available as a global variable called `payload`. +### Example +Replace all occurrences of `|` with `,` in the payload +``` +- type: script.js + params: + program: | + payload = payload.replaceAll('|',','); +``` \ No newline at end of file