Encoding
This module provides encoding & decoding functionality for:
- base64 (RFC4648)
- base64 (URL)
- hex
Decoding
decodeBase64
Decodes a base64 (RFC4648) encoded string into a Uint8Array.
Signature
declare function decodeBase64(str: string): Either<Uint8Array<ArrayBufferLike>, DecodeException>decodeBase64String
Decodes a base64 (RFC4648) encoded string into a UTF-8 string.
Signature
declare function decodeBase64String(str: string): Either<string, DecodeException>decodeBase64Url
Decodes a base64 (URL) encoded string into a Uint8Array.
Signature
declare function decodeBase64Url(str: string): Either<Uint8Array<ArrayBufferLike>, DecodeException>decodeBase64UrlString
Decodes a base64 (URL) encoded string into a UTF-8 string.
Signature
declare function decodeBase64UrlString(str: string): Either<string, DecodeException>Decodes a hex encoded string into a Uint8Array.
Signature
declare function decodeHex(str: string): Either<Uint8Array<ArrayBufferLike>, DecodeException>decodeHexString
Decodes a hex encoded string into a UTF-8 string.
Signature
declare function decodeHexString(str: string): Either<string, DecodeException>decodeUriComponent
Decodes a URI component string into a UTF-8 string.
Signature
declare function decodeUriComponent(str: string): Either<string, DecodeException>Encoding
encodeBase64
Encodes the given value into a base64 (RFC4648) string.
Signature
declare const encodeBase64: (input: Uint8Array | string) => stringencodeBase64Url
Encodes the given value into a base64 (URL) string.
Signature
declare const encodeBase64Url: (input: Uint8Array | string) => stringEncodes the given value into a hex string.
Signature
declare const encodeHex: (input: Uint8Array | string) => stringencodeUriComponent
Encodes a UTF-8 string into a URI component string.
Signature
declare function encodeUriComponent(str: string): Either<string, EncodeException>Errors
DecodeException
Creates a checked exception which occurs when decoding fails.
Signature
declare const DecodeException: (input: string, message?: string) => DecodeExceptionEncodeException
Creates a checked exception which occurs when encoding fails.
Signature
declare const EncodeException: (input: string, message?: string) => EncodeExceptionModels
DecodeException interface
Represents a checked exception which occurs when decoding fails.
Signature
interface DecodeException { readonly _tag: "DecodeException"; readonly [DecodeExceptionTypeId]: typeof DecodeExceptionTypeId; readonly input: string; readonly message?: string;}EncodeException interface
Represents a checked exception which occurs when encoding fails.
Signature
interface EncodeException { readonly _tag: "EncodeException"; readonly [EncodeExceptionTypeId]: typeof EncodeExceptionTypeId; readonly input: string; readonly message?: string;}Refinements
isDecodeException
Returns true if the specified value is an DecodeException, false otherwise.
Signature
declare const isDecodeException: (u: unknown) => u is DecodeExceptionisEncodeException
Returns true if the specified value is an EncodeException, false otherwise.
Signature
declare const isEncodeException: (u: unknown) => u is EncodeExceptionSymbols
DecodeExceptionTypeId
Signature
declare const DecodeExceptionTypeId: unique symbolDecodeExceptionTypeId type
Signature
type DecodeExceptionTypeId = typeof DecodeExceptionTypeIdEncodeExceptionTypeId
Signature
declare const EncodeExceptionTypeId: unique symbolEncodeExceptionTypeId type
Signature
type EncodeExceptionTypeId = typeof EncodeExceptionTypeId