Skip to main content Link Search Menu Expand Document (external link)

Encoding overview

This module provides encoding & decoding functionality for:

  • base64 (RFC4648)
  • base64 (URL)
  • hex

Added in v2.0.0


Table of contents


decoding

decodeBase64

Decodes a base64 (RFC4648) encoded string into a Uint8Array.

Signature

export declare const decodeBase64: (str: string) => Either.Either<Uint8Array, DecodeException>

Added in v2.0.0

decodeBase64String

Decodes a base64 (RFC4648) encoded string into a UTF-8 string.

Signature

export declare const decodeBase64String: (str: string) => Either.Either<string, DecodeException>

Added in v2.0.0

decodeBase64Url

Decodes a base64 (URL) encoded string into a Uint8Array.

Signature

export declare const decodeBase64Url: (str: string) => Either.Either<Uint8Array, DecodeException>

Added in v2.0.0

decodeBase64UrlString

Decodes a base64 (URL) encoded string into a UTF-8 string.

Signature

export declare const decodeBase64UrlString: (str: string) => Either.Either<string, DecodeException>

Added in v2.0.0

decodeHex

Decodes a hex encoded string into a Uint8Array.

Signature

export declare const decodeHex: (str: string) => Either.Either<Uint8Array, DecodeException>

Added in v2.0.0

decodeHexString

Decodes a hex encoded string into a UTF-8 string.

Signature

export declare const decodeHexString: (str: string) => Either.Either<string, DecodeException>

Added in v2.0.0

encoding

encodeBase64

Encodes the given value into a base64 (RFC4648) string.

Signature

export declare const encodeBase64: (input: Uint8Array | string) => string

Added in v2.0.0

encodeBase64Url

Encodes the given value into a base64 (URL) string.

Signature

export declare const encodeBase64Url: (input: Uint8Array | string) => string

Added in v2.0.0

encodeHex

Encodes the given value into a hex string.

Signature

export declare const encodeHex: (input: Uint8Array | string) => string

Added in v2.0.0

errors

DecodeException

Creates a checked exception which occurs when decoding fails.

Signature

export declare const DecodeException: (input: string, message?: string) => DecodeException

Added in v2.0.0

models

DecodeException (interface)

Represents a checked exception which occurs when decoding fails.

Signature

export interface DecodeException {
  readonly _tag: "DecodeException"
  readonly [DecodeExceptionTypeId]: DecodeExceptionTypeId
  readonly input: string
  readonly message?: string
}

Added in v2.0.0

refinements

isDecodeException

Returns true if the specified value is an DecodeException, false otherwise.

Signature

export declare const isDecodeException: (u: unknown) => u is DecodeException

Added in v2.0.0

symbols

DecodeExceptionTypeId

Signature

export declare const DecodeExceptionTypeId: typeof DecodeExceptionTypeId

Added in v2.0.0

DecodeExceptionTypeId (type alias)

Signature

export type DecodeExceptionTypeId = typeof DecodeExceptionTypeId

Added in v2.0.0