Other APIs

更新时间:
复制 MD 格式

This topic describes other standard Web APIs available in the EdgeRoutine runtime environment.

URL object

See the MDN Web Docs for URL.

URLSearchParams

See the MDN Web Docs for URLSearchParams.

TextDecoder

See the MDN Web Docs for TextDecoder.

TextEncoder

See the MDN Web Docs for TextEncoder.

atob

See the MDN Web Docs for WindowOrWorkerGlobalScope.atob().

btoa

See the MDN Web Docs for WindowOrWorkerGlobalScope.btoa().

setTimeout/clearTimeout/setInterval/clearInterval

For definitions of these timer functions, see the MDN Web Docs for window.setTimeout.

Note
  • The time precision for setTimeout and setInterval is in milliseconds. To prevent a side-channel attack, we recommend setting the timer resolution to at least 50 ms.

  • Each request has a time limit. If the specified delay exceeds this limit, it throws an exception. For example, if a request's time limit is 60 seconds, setting a 100-second delay for setTimeout or setInterval causes an exception.

  • A resource limit applies to setTimeout and setInterval. You can create a maximum of 16 timers per request. Clearing a timer with clearTimeout or clearInterval does not reduce this count. For setInterval, its callback can trigger a maximum of 16 times per request.

  • These timer callbacks are bound to the lifecycle of the request that created them. If the original request is canceled or terminated, the scheduled callbacks for setTimeout and setInterval will not execute.

setImmediate/clearImmediate

For definitions of these functions, see the MDN Web Docs for window.setImmediate.

Note

The setImmediate function guarantees at least one context switch. It is also subject to a resource limit. You can call it a maximum of 16 times per request. Calling clearImmediate does not reset this limit.

String conversion functions

  • utf8ToString: Converts a UTF-8 buffer to a string.

  • utf16ToString: Converts a UTF-16 buffer to a string.

Note

The input buffer for these functions is limited to 1 MB. For converting larger amounts of data, use the TextEncoder/TextDecoder APIs. If your data exceeds the 1 MB limit, you must split it into smaller chunks in your JavaScript code.

Console

The console object works only in the debugging environment and has no effect in production. The following methods are supported in the debugging environment:

  • info

  • log

  • error

  • warn

  • trace

  • assert