browser - Luke-zhang-04/utils GitHub Wiki

Module: browser

Table of contents

Namespaces

Functions

Functions

fetchWithTimeout

fetchWithTimeout(resource, «destructured»?): Promise<Response>

Fetch API with timeout

Parameters

Name Type Description
resource RequestInfo Resource to fetch
«destructured» FetchOptions -

Returns

Promise<Response>

Response

Defined in

browser/fetch.ts:20


hash

hash(data, algo?, enc?): Promise<string>

Hashes data with a SHA algorithm

Parameters

Name Type Default value Description
data string undefined Data to hash
algo "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512" "SHA-256" Hash algorithm. The only available algorithms are those provided by the SubtleCrypto API
enc "hex" | "base64" "hex" Hash digest encoding types. Only hex and base64 are supported

Returns

Promise<string>

String of hashed data

Defined in

browser/crypto.ts:22


hmacHash

hmacHash(data, secret, algo?, enc?): Promise<string>

Salts and hashes data with HMAC and a SHA algorithm

Parameters

Name Type Default value Description
data string undefined Data to hash
secret string undefined Secret to salt the data with
algo "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512" "SHA-256" Hash algorithm. The only available algorithms are those provided by the SubtleCrypto API
enc "hex" | "base64" "hex" Hash digest encoding types. Only hex and base64 are supported

Returns

Promise<string>

String of hashed data

Defined in

browser/crypto.ts:48


toBase64

toBase64(bytes): string

Converts a byte array to a base64 string

Parameters

Name Type Description
bytes Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array Converts byte array to a base64 string

Returns

string

String with base64 encoding, not URL safe

Defined in

browser/encoding.ts:15


toHex

toHex(bytes): string

Converts a byte array to a hex string

Parameters

Name Type Description
bytes Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array Converts byte array to a hex string

Returns

string

String with hex encoding

Defined in

browser/encoding.ts:34

⚠️ **GitHub.com Fallback** ⚠️