(input: Uint8Array | string): stringEncodes the given value into a base64 (URL) string.
When to use
Use to encode text or bytes as an unpadded Base64Url string for contexts that require the URL-safe alphabet.
Details
String inputs are encoded as UTF-8 bytes before Base64Url encoding.
Uint8Array inputs are encoded directly. The output removes = padding and
replaces + with - and / with _.
Example (Encoding URL-safe Base64)
import { Encoding } from "effect"
// URL-safe base64 encoding (uses - and _ instead of + and /)
console.log(Encoding.encodeBase64Url("hello?")) // "aGVsbG8_"
const bytes = new Uint8Array([72, 101, 108, 108, 111, 63])
console.log(Encoding.encodeBase64Url(bytes)) // "SGVsbG8_"export const const encodeBase64Url: (
input: Uint8Array | string
) => string
Encodes the given value into a base64 (URL) string.
When to use
Use to encode text or bytes as an unpadded Base64Url string for contexts that
require the URL-safe alphabet.
Details
String inputs are encoded as UTF-8 bytes before Base64Url encoding.
Uint8Array inputs are encoded directly. The output removes = padding and
replaces + with - and / with _.
Example (Encoding URL-safe Base64)
import { Encoding } from "effect"
// URL-safe base64 encoding (uses - and _ instead of + and /)
console.log(Encoding.encodeBase64Url("hello?")) // "aGVsbG8_"
const bytes = new Uint8Array([72, 101, 108, 108, 111, 63])
console.log(Encoding.encodeBase64Url(bytes)) // "SGVsbG8_"
encodeBase64Url: (input: string | Uint8Array<ArrayBufferLike>input: interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array | string) => string = (input: string | Uint8Array<ArrayBufferLike>input) =>
typeof input: string | Uint8Array<ArrayBufferLike>input === "string" ? const base64UrlEncodeUint8Array: (
data: Uint8Array
) => string
base64UrlEncodeUint8Array(const encoder: TextEncoderencoder.TextEncoder.encode(input?: string): Uint8Array<ArrayBuffer>The TextEncoder.encode() method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object.
encode(input: stringinput)) : const base64UrlEncodeUint8Array: (
data: Uint8Array
) => string
base64UrlEncodeUint8Array(input: Uint8Array<ArrayBufferLike>input)