Skip to main content
Home
This release is 44 versions behind 1.0.10 — the latest version of @std/encoding. Jump to latest
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%
Downloads67,105/wk
Published2 years ago (0.199.0)

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

ascii85

encode and decode for Ascii85/base85 encoding.

I
Ascii85Options

encoding/decoding options

T
Ascii85Standard

encode and decode for Ascii85/base85 encoding.

f
decode

Decodes a given ascii85 encoded string.

f
encode

Encodes a given Uint8Array into ascii85, supports multiple standards

base32

encode and decode for base32 encoding.

f
byteLength

Returns number of bytes encoded in the given RFC4648 base32 string input.

f
decode

Decodes a given RFC4648 base32 encoded string.

f
encode

Encodes a given Uint8Array into RFC4648 base32 representation

base58

encode and decode for base58 encoding.

f
decode

Decodes a given b58 string according to draft-mspotny-base58-03 RFC base58 representation: https://tools.ietf.org/id/draft-msporny-base58-01.html#rfc.section.1

f
encode

Encodes a given Uint8Array, ArrayBuffer or string into draft-mspotny-base58-03 RFC base58 representation: https://tools.ietf.org/id/draft-msporny-base58-01.html#rfc.section.1

base64

encode and decode for base64 encoding.

f
decode

Decodes a given RFC4648 base64 encoded string

f
encode

CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation

base64url

encode and decode for base64 URL safe encoding.

f
decode

Converts given base64url encoded data back to original

f
encode

Encodes a given ArrayBuffer or string into a base64url representation

binary

Functions for encoding binary data in array buffers.

T
DataType
No documentation available
T
Endianness

How encoded binary data is ordered.

f
getNBytes

Reads exactly n bytes from r.

f
putVarbig

Encodes bigint x into b. Returns the number of bytes used, or 0 if b is shorter than sizeof(o.dataType).

f
putVarnum

Encodes number x into b. Returns the number of bytes used, or 0 if b is shorter than sizeof(o.dataType).

f
readExact

Reads the exact number of bytes from r required to fill b.

f
readVarbig

Decodes a bigint from r, consuming sizeof(o.dataType) bytes. If less than sizeof(o.dataType) bytes were read, throws Deno.errors.unexpectedEof.

f
readVarnum

Decodes a number from r, consuming sizeof(o.dataType) bytes. If less than sizeof(o.dataType) bytes were read, throws Deno.errors.unexpectedEof.

f
sizeof

Number of bytes required to store dataType.

f
varbig

Decodes a bigint from b. If o.bytes is shorter than sizeof(o.dataType), returns null.

f
varbigBytes

Encodes x into a new Uint8Array.

I
VarbigOptions

Options for working with the bigint type.

f
varnum

Decodes a number from b. If o.bytes is shorter than sizeof(o.dataType), returns null.

f
varnumBytes

Encodes x into a new Uint8Array.

I
VarnumOptions

Options for working with the number type.

f
writeVarbig

Encodes and writes x to w. Resolves to the number of bytes written.

f
writeVarnum

Encodes and writes x to w. Resolves to the number of bytes written.

hex

Port of the Go encoding/hex library.

f
decode

Decodes src into src.length / 2 bytes. If the input is malformed, an error will be thrown.

f
encode

Encodes src into src.length * 2 bytes.

varint

Functions for encoding typed integers in array buffers.

f
decode

Given a 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
decode32

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
encode

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

Functions for encoding typed integers in array buffers.

v
MaxVarIntLen32
No documentation available
v
MaxVarIntLen64
No documentation available

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.