Skip to main content
Home
This release is 2 versions behind 1.0.10 — the latest version of @std/encoding. Jump to latest

Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Downloads108,220/wk
Published10 months ago (1.0.8)

Utilities for encoding and decoding common formats like hex, base64, and varint

default

Utilities for encoding and decoding common formats like hex, base64, and varint.

T
Ascii85Standard

Supported ascii85 standards for EncodeAscii85Options and DecodeAscii85Options.

f
decodeAscii85

Decodes a ascii85-encoded string.

T
DecodeAscii85Options

Options for decodeAscii85.

f
decodeBase32

Decodes a base32-encoded string.

f
decodeBase58

Decodes a base58-encoded string.

f
decodeBase64

Decodes a base64-encoded string.

f
decodeBase64Url

Decodes a given base64url-encoded string.

f
decodeHex

Decodes the given hex-encoded string. If the input is malformed, an error is thrown.

f
decodeVarint

Given a non empty buf, starting at offset (default: 0), begin decoding bytes as Varint encoded bytes, for a maximum of 10 bytes (offset + 10). The returned tuple is of the decoded varint 32-bit number, and the new offset with which to continue decoding other data.

f
decodeVarint32

Given a buf, starting at offset (default: 0), begin decoding bytes as Varint encoded bytes, for a maximum of 5 bytes (offset + 5). The returned tuple is of the decoded varint 32-bit number, and the new offset with which to continue decoding other data.

f
encodeAscii85

Converts data into an ascii85-encoded string.

I
EncodeAscii85Options

Options for encodeAscii85.

f
encodeBase32

Converts data into a base32-encoded string.

f
encodeBase58

Converts data into a base58-encoded string.

f
encodeBase64

Converts data into a base64-encoded string.

f
encodeBase64Url

Convert data into a base64url-encoded string.

f
encodeHex

Converts data into a hex-encoded string.

f
encodeVarint

Takes unsigned number num and converts it into a Varint encoded Uint8Array, returning a tuple consisting of a Uint8Array slice of the encoded Varint, and an offset where the Varint encoded bytes end within the Uint8Array.

v
MaxUint64

The maximum value of an unsigned 64-bit integer. Equivalent to 2n**64n - 1n

v
MaxVarintLen32

The maximum length, in bytes, of a Varint encoded 32-bit integer.

v
MaxVarintLen64

The maximum length, in bytes, of a Varint encoded 64-bit integer.

T
Ascii85Standard

Supported ascii85 standards for EncodeAscii85Options and DecodeAscii85Options.

f
decodeAscii85

Decodes a ascii85-encoded string.

T
DecodeAscii85Options

Options for decodeAscii85.

f
encodeAscii85

Converts data into an ascii85-encoded string.

I
EncodeAscii85Options

Options for encodeAscii85.

base32

Utilities for base32 encoding and decoding.

f
decodeBase32

Decodes a base32-encoded string.

f
encodeBase32

Converts data into a base32-encoded string.

base58

Utilities for base58 encoding and decoding.

f
decodeBase58

Decodes a base58-encoded string.

f
encodeBase58

Converts data into a base58-encoded string.

base64

Utilities for base64 encoding and decoding.

f
decodeBase64

Decodes a base64-encoded string.

f
encodeBase64

Converts data into a base64-encoded string.

base64url

Utilities for base64url encoding and decoding.

f
decodeBase64Url

Decodes a given base64url-encoded string.

f
encodeBase64Url

Convert data into a base64url-encoded string.

hex

Port of the Go encoding/hex library.

f
decodeHex

Decodes the given hex-encoded string. If the input is malformed, an error is thrown.

f
encodeHex

Converts data into a hex-encoded string.

unstable-base32

Functions to encode and decode to and from base32 strings.

T
Base32Format

The base 32 encoding formats.

f
calcMax

Calculate the output size needed to encode a given input size for encodeRawBase32.

f
decodeBase32

decodeBase32 takes an input source and decodes it into a Uint8Array<ArrayBuffer> using the specified format.

f
decodeRawBase32

decodeRawHex is a low-level function that decodes a Uint8Array<ArrayBuffer> from hexadecimal in place. Param i must be greater than or equal to param o. The function assumes that the encoded data starts at param i and ends at the end of the buffer.

f
encodeBase32

encodeBase32 takes an input source and encodes it into a base32 string. If a Uint8Array<ArrayBuffer> or ArrayBuffer is provided, the underlying source will be detached and reused for the encoding. If you need the input source after providing it to this function, call .slice() to pass in a copy.

f
encodeRawBase32

encodeRawBase32 is a low-level function that encodes a Uint8Array<ArrayBuffer> to base32 in place. The function assumes that the raw data starts at param i and ends at the end of the buffer, and that the entire buffer provided is large enough to hold the encoded data.

unstable-base32-stream

TransformStream classes to encode and decode to and from base32 data in a streaming manner.

c
Base32DecoderStream

Transforms a base32 stream into a Uint8Array stream.

c
Base32EncoderStream

Transforms a Uint8Array<ArrayBuffer> stream into a base32 stream.

unstable-base64

Functions to encode and decode to and from base64 strings.

T
Base64Format

The base 64 encoding formats.

f
calcMax

Calculate the output size needed to encode a given input size for encodeRawBase64.

f
decodeBase64

decodeBase64 takes an input source and decodes it into a Uint8Array<ArrayBuffer> using the specified format.

f
decodeRawBase64

decodeRawHex is a low-level function that decodes a Uint8Array<ArrayBuffer> from hexadecimal in place. Param i must be greater than or equal to param o. The function assumes that the encoded data starts at param i and ends at the end of the buffer.

f
encodeBase64

encodeBase64 takes an input source and encodes it into a base64 string. If a Uint8Array<ArrayBuffer> or ArrayBuffer is provided, the underlying source will be detached and reused for the encoding. If you need the input source after providing it to this function, call .slice() to pass in a copy.

f
encodeRawBase64

encodeRawBase64 is a low-level function that encodes a Uint8Array<ArrayBuffer> to base64 in place. The function assumes that the raw data starts at param i and ends at the end of the buffer, and that the entire buffer provided is large enough to hold the encoded data.

unstable-base64-stream

TransformStream classes to encode and decode to and from base64 data in a streaming manner.

c
Base64DecoderStream

Transforms a base64 stream into a Uint8Array stream.

c
Base64EncoderStream

Transforms a Uint8Array<ArrayBuffer> stream into a base64 stream.

unstable-hex

Functions to encode and decode to and from hexadecimal strings.

f
calcMax

Calculate the output size needed to encode a given input size for encodeRawHex.

f
decodeHex

decodeHex takes an input source and decodes it into a Uint8Array<ArrayBuffer> using the specified format.

f
decodeRawHex

decodeRawHex is a low-level function that decodes a Uint8Array<ArrayBuffer> from hexadecimal in place. Param i must be greater than or equal to param o. The function assumes that the encoded data starts at param i and ends at the end of the buffer.

f
encodeHex

encodeHex takes an input source and encodes it into a hexadecimal string. If a Uint8Array<ArrayBuffer> or ArrayBuffer is provided, the underlying source will be detached and reused for the encoding. If you need the input source after providing it to this function, call .slice() to pass in a copy.

f
encodeRawHex

encodeRawHex is a low-level function that encodes a Uint8Array<ArrayBuffer> to hexadecimal in place. The function assumes that the raw data starts at param i and ends at the end of the buffer, and that the entire buffer provided is large enough to hold the encoded data.

unstable-hex-stream

TransformStream classes to encode and decode to and from hexadecimal data in a streaming manner.

c
HexDecoderStream

Transforms a hexadecimal stream into a Uint8Array stream.

c
HexEncoderStream

Transforms a Uint8Array<ArrayBuffer> stream into a hexadecimal stream.

varint

Utilities for Varint encoding of typed integers. Varint encoding represents integers using a variable number of bytes, with smaller values requiring fewer bytes.

f
decodeVarint

Given a non empty buf, starting at offset (default: 0), begin decoding bytes as Varint encoded bytes, for a maximum of 10 bytes (offset + 10). The returned tuple is of the decoded varint 32-bit number, and the new offset with which to continue decoding other data.

f
decodeVarint32

Given a buf, starting at offset (default: 0), begin decoding bytes as Varint encoded bytes, for a maximum of 5 bytes (offset + 5). The returned tuple is of the decoded varint 32-bit number, and the new offset with which to continue decoding other data.

f
encodeVarint

Takes unsigned number num and converts it into a Varint encoded Uint8Array, returning a tuple consisting of a Uint8Array slice of the encoded Varint, and an offset where the Varint encoded bytes end within the Uint8Array.

v
MaxUint64

The maximum value of an unsigned 64-bit integer. Equivalent to 2n**64n - 1n

v
MaxVarintLen32

The maximum length, in bytes, of a Varint encoded 32-bit integer.

v
MaxVarintLen64

The maximum length, in bytes, of a Varint encoded 64-bit integer.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.