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

Encoding.ts overview

This module provides encoding & decoding functionality for:

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

Since v2.0.0


Exports Grouped by Category


decoding

decodeBase64

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

Signature

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

Source

Since v2.0.0

decodeBase64String

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

Signature

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

Source

Since v2.0.0

decodeBase64Url

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

Signature

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

Source

Since v2.0.0

decodeBase64UrlString

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

Signature

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

Source

Since v2.0.0

decodeHex

Decodes a hex encoded string into a Uint8Array.

Signature

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

Source

Since v2.0.0

decodeHexString

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

Signature

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

Source

Since v2.0.0

decodeUriComponent

Decodes a URI component string into a UTF-8 string.

Signature

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

Source

Since v3.12.0

encoding

encodeBase64

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

Signature

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

Source

Since v2.0.0

encodeBase64Url

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

Signature

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

Source

Since v2.0.0

encodeHex

Encodes the given value into a hex string.

Signature

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

Source

Since v2.0.0

encodeUriComponent

Encodes a UTF-8 string into a URI component string.

Signature

declare const encodeUriComponent: (str: string) => Either.Either<string, EncodeException>

Source

Since v3.12.0

errors

DecodeException

Creates a checked exception which occurs when decoding fails.

Signature

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

Source

Since v2.0.0

EncodeException

Creates a checked exception which occurs when encoding fails.

Signature

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

Source

Since v3.12.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
}

Source

Since v2.0.0

EncodeException (interface)

Represents a checked exception which occurs when encoding fails.

Signature

export interface EncodeException {
  readonly _tag: "EncodeException"
  readonly [EncodeExceptionTypeId]: EncodeExceptionTypeId
  readonly input: string
  readonly message?: string
}

Source

Since v3.12.0

refinements

isDecodeException

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

Signature

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

Source

Since v2.0.0

isEncodeException

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

Signature

declare const isEncodeException: (u: unknown) => u is EncodeException

Source

Since v3.12.0

symbols

DecodeExceptionTypeId

Signature

declare const DecodeExceptionTypeId: unique symbol

Source

Since v2.0.0

DecodeExceptionTypeId (type alias)

Signature

type DecodeExceptionTypeId = typeof DecodeExceptionTypeId

Source

Since v2.0.0

EncodeExceptionTypeId

Signature

declare const EncodeExceptionTypeId: unique symbol

Source

Since v3.12.0

EncodeExceptionTypeId (type alias)

Signature

type EncodeExceptionTypeId = typeof EncodeExceptionTypeId

Source

Since v3.12.0