browser - Luke-zhang-04/utils GitHub Wiki
▸ fetchWithTimeout(resource, «destructured»?): Promise<Response>
Fetch API with timeout
| Name | Type | Description |
|---|---|---|
resource |
RequestInfo |
Resource to fetch |
«destructured» |
FetchOptions |
- |
Promise<Response>
Response
▸ hash(data, algo?, enc?): Promise<string>
Hashes data with a SHA algorithm
| 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 |
Promise<string>
String of hashed data
▸ hmacHash(data, secret, algo?, enc?): Promise<string>
Salts and hashes data with HMAC and a SHA algorithm
| 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 |
Promise<string>
String of hashed data
▸ toBase64(bytes): string
Converts a byte array to a base64 string
| Name | Type | Description |
|---|---|---|
bytes |
Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array
|
Converts byte array to a base64 string |
string
String with base64 encoding, not URL safe
▸ toHex(bytes): string
Converts a byte array to a hex string
| Name | Type | Description |
|---|---|---|
bytes |
Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array
|
Converts byte array to a hex string |
string
String with hex encoding