[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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user