EdgeRoutine (ER) supports additional API operations, including URL handling, text encoding and decoding, Base64 conversion, timers, string utilities, and console debugging.
URL
For details, see URL on MDN.
URLSearchParams
For details, see URLSearchParams on MDN.
TextDecoder
For details, see TextDecoder on MDN.
TextEncoder
For details, see TextEncoder on MDN.
Atob
For details, see WindowOrWorkerGlobalScope.atob() on MDN.
BtoA
For details, see WindowOrWorkerGlobalScope.btoa() on MDN.
setTimeout/clearTimeout/setInterval/clearInterval
For details about setTimeout, clearTimeout, setInterval, and clearInterval, see window.setTimeout on MDN.
-
setTimeout and setInterval allow you to set a time period in milliseconds. To protect data from side-channel attacks, we recommend that you set the time period to 50 milliseconds.
-
Each request has a response time limit. If the specified time period exceeds the response time, an exception is thrown. For example, if the response time is 60 seconds and setTimeout or setInterval is set to 100 seconds, an exception is thrown.
-
setTimeout and setInterval can be set up to 16 times per request. Each invocation consumes one quota, even if you clear the value. setInterval also consumes one quota each time it triggers, and can be invoked up to 16 times.
-
These callback functions are bound to the lifecycle of a request. If you cancel or terminate the request, the callbacks are not invoked.
setImmediate/clearImmediate
For details about setImmediate and clearImmediate, see window.setImmediate on MDN.
setImmediate switches from one context to another. setImmediate can be invoked up to 16 times per request. Each invocation consumes one quota, even if you clear the value.
String-related operations
-
utf8ToString: converts UTF-8-encoded data into strings. -
utf16ToString: converts UTF-16-encoded data into strings.
These functions have a limited buffer size. For large data, we recommend that you use TextEcnoder/Decoder instead. The input buffer size cannot exceed 1 MB. If the input exceeds 1 MB, use a JavaScript method to split the content.
Console
The console operation takes effect only in debugging environments and supports the following methods:
-
info
-
log
-
error
-
warn
-
trace
-
assert