@hugoalh/base32
v0.1.1
Published
A module for Base32 encode and decode.
Maintainers
Readme
Base32 (ES)
🔗 DistBoard @hugoalh ● GitHub ● JSR ● NPM
An ECMAScript module for Base32 encode and decode.
🌟 Features
- Support multiple variants alphabet and padding:
- RFC 4648 §6: Base32 encoding (Standard)
- RFC 4648 §7: Base32 encoding with extended hex alphabet (Base32Hex)
- Douglas Crockford's Base32 encoding (Base32Crockford)
- Geohash Base32 encoding (Base32Geohash)
- Word-safe Base32 encoding (Base32WordSafe)
- Zooko Wilcox-O'Hearn's Base32 encoding (z-base-32) (Base32Z)
- Support stream encode and decode.
🎯 Runtime Targets
Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:
🛡️ Runtime Permissions
This does not request any runtime permission.
#️⃣ Sources & Entrypoints
- GitHub Raw
https://raw.githubusercontent.com/hugoalh/base32-es/{Tag}/mod.ts - JSR
jsr:@hugoalh/base32[@{Tag}] - NPM
npm:@hugoalh/base32[@{Tag}]
| Name | Path | Description |
|:--|:--|:--|
| . | ./mod.ts | Default. |
[!NOTE]
- Different runtimes have vary support for the sources and entrypoints, visit the runtime documentation for more information.
- It is recommended to include tag for immutability.
- These are not part of the public APIs hence should not be used:
- Benchmark/Test file (e.g.:
example.bench.ts,example.test.ts).- Entrypoint name or path include any underscore prefix (e.g.:
_example.ts,foo/_example.ts).- Identifier/Namespace/Symbol include any underscore prefix (e.g.:
_example,Foo._example).
🧩 APIs
class Base32Decoder { constructor(options?: Base32DecodeOptions); get variant(): Base32Variant; decodeToBytes(item: string | Uint8Array): Uint8Array; decodeToText(item: string | Uint8Array): string; }class Base32Encoder { constructor(options?: Base32EncodeOptions); get padding(): boolean; get variant(): Base32Variant; encodeToBytes(item: string | Uint8Array): Uint8Array; encodeToText(item: string | Uint8Array): string; }class Base32DecoderStream extends TransformStream<Uint8Array, Uint8Array> { constructor(options?: Base32DecodeOptions); }class Base32EncoderStream extends TransformStream<Uint8Array, Uint8Array> { constructor(options?: Base32EncodeOptions); }type Base32Variant = | "crockford" | "geohash" | "hex" | "hexadecimal" | "rfc3548" | "rfc4648-6" | "rfc4648-7" | "standard" | "wordsafe" | "z";interface Base32BasicOptions { variant?: Base32Variant; }interface Base32DecodeOptions extends Base32BasicOptions { }interface Base32EncodeOptions extends Base32BasicOptions { padding?: boolean | null; }
[!NOTE]
- For the full or prettier documentation, can visit via:
✍️ Examples
new Base32Encoder().encodeToText("foobar"); //=> "MZXW6YTBOI======"
