Skip to main content
Home

@aicone/byte@0.8.10
Built and signed on GitHub Actions

Works with
This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers
It is unknown whether 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%
Published9 months ago (0.8.10)

Javascript library to manipulate Uint8Array using concat, get8Uint, Uint8BE, etc

@aicone/byte

Byte

@version 0.8.10 A lightweight utility class that extends Uint8Array to simplify encoding and decoding between various formats including hexadecimal, base64, base64url, and UTF-8 strings.

Features

  • Create a byte array from hex, base64, base64url, or string input.
  • Convert a byte array back to string formats.
  • Validate input before conversion.
  • All instances are Uint8Array subclasses.

Usage

import { Byte } from "./Byte.js";

// Create from raw array
const bytes = Byte.create([72, 101, 108, 108, 111]); // "Hello"

// Create from Hex
const fromHex = Byte.fromHex("48656c6c6f");

// Create from Base64
const fromBase64 = Byte.fromBase64("SGVsbG8=");

// Create from Base64URL
const fromBase64Url = Byte.fromBase64Url("SGVsbG8");

// Create from String
const fromString = Byte.fromString("Hello");

// Conversions
console.log(bytes.toHex());          // "48656c6c6f"
console.log(bytes.toBase64());      // "SGVsbG8="
console.log(bytes.toBase64Url());   // "SGVsbG8"
console.log(bytes.toUtf8String());  // "Hello"

Contributing

Contributions to improve the library are welcome. Please open an issue or pull request on the GitHub repository.

Donation

License

This project is licensed under the MIT License.

Built and signed on
GitHub Actions

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.

Add Package

deno add jsr:@aicone/byte

Import symbol

import * as byte from "@aicone/byte";
or

Import directly with a jsr specifier

import * as byte from "jsr:@aicone/byte";

Add Package

pnpm i jsr:@aicone/byte
or (using pnpm 10.8 or older)
pnpm dlx jsr add @aicone/byte

Import symbol

import * as byte from "@aicone/byte";

Add Package

yarn add jsr:@aicone/byte
or (using Yarn 4.8 or older)
yarn dlx jsr add @aicone/byte

Import symbol

import * as byte from "@aicone/byte";

Add Package

vlt install jsr:@aicone/byte

Import symbol

import * as byte from "@aicone/byte";

Add Package

npx jsr add @aicone/byte

Import symbol

import * as byte from "@aicone/byte";

Add Package

bunx jsr add @aicone/byte

Import symbol

import * as byte from "@aicone/byte";