add docs about script.js processor

This commit is contained in:
Joel Wetzell
2025-12-24 14:58:33 -06:00
parent e17b117000
commit 172e4cc857
2 changed files with 28 additions and 0 deletions
+23
View File
@@ -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('|',',');
```