Overview
The javascript app and script component pre-load a set of useful modules that are then available in to the code in the script.
from
The $from function creates a range of numbers starting at the first input, and ending on the second.
let items = $from(1,10, 100)
Try it!
list
the list module is preloaded, with the list function assigned the name "$list".
let items = $list(data).filter(p=>p.age>20).items;
range
The $range function returns an area of numbers starting with the first number inputted and ending with the second number provided. If a third number is provided, it is used as the step size.
let numbers = $range(1,100);
//step size 2
let numbers2 = $range(1,100,2);
Try it!
sort
The sort module is pre-loaded and the sort function named "$sort"
let items = $sort(data, p=>p.date);
Try it!
wait
The $wait function halts the current processing for approx the amount of time provided (in ms). If no time is provided, the current processing is momentarily halted (that is, the processor is returned back to the user interface and will return as soon as UI finished whatever processing it need.)
await $wait(100);
await $wait();
Try it!
The $wait function is useful in situations where a long-running process could tie up the processor, which when running in the browser will often hang the browser tab and will prompt the user to see if they wish to exit the tab. Periodically calling $wait() will prevnt the UI from hanging.
cache
The $cache object can be used to share data between executions of the script. Data in the $cache is not made available to other components or scripts, only the script in question.
$cache.test = 10;
global
The $global object can be used to share data between executions of the script. Data in the $global object is made available to other components and scripts.
$global.test = 10;