[js-transform] inline java script support (#11473)

* [js-transform] inline java script support

Signed-off-by: Pauli Anttila <pauli.anttila@gmail.com>
This commit is contained in:
pali
2021-12-12 23:09:36 +02:00
committed by GitHub
parent 26729956bc
commit 45729890b1
5 changed files with 107 additions and 30 deletions

View File

@@ -5,6 +5,10 @@ Transform an input to an output using JavaScript.
It expects the transformation rule to be read from a file which is stored under the `transform` folder.
To organize the various transformations, one should use subfolders.
Simple transformation rules can also be given as a inline script.
Inline script should be start by `|` character following the JavaScript.
Beware that complex inline script could cause issues to e.g. item file parsing.
## Examples
Let's assume we have received a string containing `foo bar baz` and we're looking for a length of the last word (`baz`).
@@ -37,6 +41,10 @@ transform/scale.js:
Following example will return value `23.54` when `input` data is `214`.
### Inline script example:
Normally JavaScript transformation is given by filename, e.g. `JS(transform/getValue.js)`.
Inline script can be given by `|` character following the JavaScript, e.g. `JS(| input / 10)`.
## Test JavaScript