@hazae41/base64
v1.0.15
Published
Base64 adapter for WebAssembly and JS implementations
Downloads
139
Maintainers
Readme
Base64
Base64 adapter for WebAssembly and JS implementations
npm i @hazae41/base64
Features
Current features
- 100% TypeScript and ESM
- No external dependencies
Getting started
Buffer (NodeJS)
import { Base64 } from "@hazae41/base64"
Base64.set(Base64.fromBuffer())
WebAssembly
npm i @hazae41/base64.wasm
import { Base64 } from "@hazae41/base64"
import { Base64Wasm } from "@hazae41/base64.wasm"
await Base64Wasm.initBundled()
Base64.set(Base64.fromBufferOrWasm(Base64Wasm))
Scure (JavaScript)
npm i @scure/base
import { Base64 } from "@hazae41/base64"
import * as Scure from "@scure/base"
Base64.set(Base64.fromBufferOrScure(Scure))
Usage
const encoded: string = Base64.get().getOrThrow().encodePaddedOrThrow(new Uint8Array([1,2,3,4,5]))
using decoded: Copiable = Base64.get().getOrThrow().decodePaddedOrThrow(encoded)
const decoded2: Uint8Array = decoded.bytes.slice()