Skip to main content

@std/encoding@0.215.0

latest
Works with
It is unknown whether this package works with Node.js, Deno, Browsers, Cloudflare Workers, Bun
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score64%
Published2 years ago (0.215.0)
ascii85

Utilities for working with ascii85 encoding.

Functions

f
decodeAscii85(
ascii85: string,
options?: Ascii85Options
): Uint8Array

Decodes a given ascii85-encoded string.

f
encodeAscii85(
data: ArrayBuffer | Uint8Array | string,
options?: Ascii85Options
): string

Converts data into an ascii58-encoded string.

Interfaces

I

Options for encodeAscii85 and decodeAscii85.

  • delimiter: boolean

    Whether to use a delimiter (if supported).

  • standard: Ascii85Standard

    Character set and delimiter (if supported and used).

Type Aliases

T
Ascii85Standard = "Adobe" | "btoa" | "RFC 1924" | "Z85"

Supported ascii85 standards for Ascii85Options.

base32

Utilities for base32 encoding and decoding.

Functions

f
decodeBase32(b32: string): Uint8Array

Decodes a base32-encoded string.

f
encodeBase32(data: ArrayBuffer | Uint8Array | string): string

Converts data to a base32-encoded string.

base58

Utilities for base58 encoding and decoding.

Functions

f
decodeBase58(b58: string): Uint8Array

Decodes a base58-encoded string.

f
encodeBase58(data: ArrayBuffer | Uint8Array | string): string

Converts data to a base58-encoded string.

base64

Utilities for base64 encoding and decoding.

Functions

f
decodeBase64(b64: string): Uint8Array

Decodes a base64-encoded string.

f
encodeBase64(data: ArrayBuffer | Uint8Array | string): string

Converts data into a base64-encoded string.

base64url

Utilities for base64url encoding and decoding.

Functions

f
decodeBase64Url(b64url: string): Uint8Array

Decodes a given base64url-encoded string.

f
encodeBase64Url(data: ArrayBuffer | Uint8Array | string): string

Convert data into a base64url-encoded string.

hex

Port of the Go encoding/hex library.

Examples

Example 1

import {
  decodeHex,
  encodeHex,
} from "@std/encoding/hex";

const binary = new TextEncoder().encode("abc");
const encoded = encodeHex(binary);
console.log(encoded);
// => "616263"

console.log(decodeHex(encoded));
// => Uint8Array(3) [ 97, 98, 99 ]

Functions

f
decodeHex(src: string): Uint8Array

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

f
encodeHex(src: string | Uint8Array | ArrayBuffer): string

Converts data into a hex-encoded string.

varint

Functions for encoding typed integers in array buffers.

Functions

f
decode(
buf: Uint8Array,
offset?
): [bigint, number]

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
decode32(
buf: Uint8Array,
offset?
): [number, number]

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(
num: bigint | number,
buf?: Uint8Array,
offset?
): [Uint8Array, number]

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.

Variables

v
MaxUInt64: 18446744073709551615

Functions for encoding typed integers in array buffers.

v
No documentation available
v
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.