Overview
Menu

Web standards

Edge Functions designs a serverless code execution environment based on the V8 JavaScript engine and provides the following standardized Web APIs.

JavaScript Standard Built-in Objects

Edge Functions supports all JavaScript standard built-in objects. For more information, see Standard built-in objects.

URL

const urlInfo = new URL('https://www.tencentcloud.com/');
The URL API is used to parse, construct, standardize, and encode URLs. For more information, see URL.

Blob

const blob = new Blob(['hello', 'world'], { type: 'text/plain' });
The Blob API represents a file-like object of immutable and raw data. For more information, see Blob.

Base64

btoa

function btoa(data: string | ArrayBuffer | ArrayBufferView): string;
The btoa() method performs Base64 encoding. Unicode strings are not supported. For more information, see btoa().

atob

function atob(data: string): string;
The atob() method performs Base64 decoding. Unicode strings are not supported. For more information, see atob().

btoaUTF8

function btoaUTF8(data: string): string;
The btoaUTF8() method performs Base64 encoding. Unicode strings are supported.

atobUTF8

function atobUTF8(data: string): string;
The atobUTF8() method performs Base64 decoding. Unicode strings are supported.



Timer

setTimeout

setTimeout(func: function): number;
setTimeout(func: function, delay: number): number;
setTimeout(func: function, delay: number, ...args: any[]): number;
Functioning as an ordinary timer, it executes the designated function upon expiration. For more details, see setTimeout.

clearTimeout

clearTimeout(timeoutID: number): void;
It is an ordinary timer to clear the designated timeoutID. For more information, see clearTimeout.

setInterval

setInterval(func: function): number;
setInterval(func: function, delay: number): number;
setInterval(func: function, delay: number, ...args: any[]): number;
Functioning as a recurring timer, it implemets the designated function upon expiration. For more information, see setInterval.

clearInterval

clearInterval(intervalID: number): void;
It is used to clear a recurring timer. For more details, seeclearInterval.

setImmediate

setImmediate(func: function): number;
setImmediate(func: function, ...args: any[]): number;
Functioning as an immediate timer, it executes the designated function after the EDGE-FUNCTION stack has been cleared. For more information, see setImmediate.

clearImmediate

clearImmediate(immediateID: number): void;
It is used to clear an immediate timer. For more information, see setImmediate.

EventTarget and Event

EventTarget

const eventTarget = new EventTarget();
The EventTarget API allows objects to publish and subscribe to events. For more information, see EventTarget.

Event

const event = new Event('type name');
The Event API represents a basic event. For more information, see Event.

AbortSignal and AbortController

AbortSignal

const signal = AbortSignal.abort();
The AbortSignal API represents a signal object that allows you to stop a request. For more information, see AbortSignal.

AbortController

const controller = new AbortController();
The AbortController API represents a controller object that allows you to stop a request. For more information, see AbortController.

CompressionStream and DecompressionStream

CompressionStream

const { readable, writable } = new CompressionStream('gzip');
CompressionStream supports compression methods including gzip, deflate, and br. For more details, see CompressionStream.

DecompressionStream

const { readable, writable } = new DecompressionStream('gzip');
DecompressionStream supports decompression methods including gzip, deflate, and br. For more details, see DecompressionStream.