Javascript Runtime

NameDescriptionSignatures
atobBase64 decodes a given stringatob(string) string
btoaBase64 encodes a given stringbota(string) string
to_jsonConverts a given object to JSONto_json(any) object
dump_jsonPrints a given object as JSON in consoledump_json(any)
to_arraySets/Updates objects prototype to array to enable Array.XXX functionsto_array(any) array
hex_to_asciiConverts a given hex string to asciihex_to_ascii(string) string
RandRand returns a random byte slice of length nRand(n int) []byte
RandIntRandInt returns a random intRandInt() int
loglog prints given input to stdout with [JS] prefix for debugging purposeslog(msg string), log(msg map[string]interface{})
getNetworkPortgetNetworkPort registers defaultPort and returns defaultPort if it is a colliding port with other protocolsgetNetworkPort(port string, defaultPort string) string
isPortOpenisPortOpen checks if given TCP port is open on host. timeout is optional and defaults to 5 secondsisPortOpen(host string, port string, [timeout int]) bool
isUDPPortOpenisUDPPortOpen checks if the given UDP port is open on the host. Timeout is optional and defaults to 5 seconds.isUDPPortOpen(host string, port string, [timeout int]) bool
ToBytesToBytes converts given input to byte sliceToBytes(...interface{}) []byte
ToStringToString converts given input to stringToString(...interface{}) string
ExportConverts a given value to a string and is appended to output of scriptExport(value any)
ExportAsExports given value with specified key and makes it available in DSL and responseExportAs(key string,value any)

Template Flow

NameDescriptionSignatures
logLogs a given object/message to stdout (only for debugging purposes)log(obj any) any
iterateNormalizes and Iterates over all arguments (can be a string,array,null etc) and returns an array of objects\nNote: If the object type is unknown(i.e could be a string or array) iterate should be used and it will always return an array of stringsiterate(...any) []any
DedupeDe-duplicates given values and returns a new array of unique valuesnew Dedupe()

Code Protocol

NameDescriptionSignatures
OSOS returns the current OSOS() string
IsLinuxIsLinux checks if the current OS is LinuxIsLinux() bool
IsWindowsIsWindows checks if the current OS is WindowsIsWindows() bool
IsOSXIsOSX checks if the current OS is OSXIsOSX() bool
IsAndroidIsAndroid checks if the current OS is AndroidIsAndroid() bool
IsIOSIsIOS checks if the current OS is IOSIsIOS() bool
IsJSIsJS checks if the current OS is JSIsJS() bool
IsFreeBSDIsFreeBSD checks if the current OS is FreeBSDIsFreeBSD() bool
IsOpenBSDIsOpenBSD checks if the current OS is OpenBSDIsOpenBSD() bool
IsSolarisIsSolaris checks if the current OS is SolarisIsSolaris() bool
ArchArch returns the current architectureArch() string
Is386Is386 checks if the current architecture is 386Is386() bool
IsAmd64IsAmd64 checks if the current architecture is Amd64IsAmd64() bool
IsARMIsArm checks if the current architecture is ArmIsARM() bool
IsARM64IsArm64 checks if the current architecture is Arm64IsARM64() bool
IsWasmIsWasm checks if the current architecture is WasmIsWasm() bool

JavaScript Protocol

NameDescriptionSignatures
setset variable from init code. this function is available in init code block onlyset(string, interface{})
updatePayloadupdate/override any payload from init code. this function is available in init code block onlyupdatePayload(string, interface{})