etf_js

Types

An error that occured while decoding the ETF encoded binary

pub type EtfDecodeError {
  NotEtf
  Invalid
  AtomLengthInvalid
  Compressed
  PakoNotInstalled
  Unknown(Dynamic)
}

Constructors

  • NotEtf

    The given binary is not an ETF binary

  • Invalid

    The given ETF binary has some invalidity

  • AtomLengthInvalid

    An atom parsed from the binary has an invalid length (>255)

  • Compressed

    Binary is compressed but the no_compression method was called

  • PakoNotInstalled

    The pako library is not installed (from npm). This error occurs if both DecompressionStream and node:zlib are not available, usually in older browsers (<May 2023).

  • Unknown(Dynamic)

    An unknown error occured. The enum argument is the error passed.

Functions

pub fn to_dynamic(
  bits: BitArray,
) -> Promise(Result(Dynamic, EtfDecodeError))

Converts an erlang ETF encoded bitarray into a JS object returned as a Dynamic.

pub fn to_dynamic_no_compression(
  bits: BitArray,
) -> Result(Dynamic, EtfDecodeError)

Converts an erlang ETF encoded bitarray into a JS object returned as a Dynamic.

This method is synchronous and does not support compressed ETF binaries.

Search Document