aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/@exodus/bytes/base32.d.ts
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
commit76cb9c2a39d477a64824a985ade40507e3bbade1 (patch)
tree41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/@exodus/bytes/base32.d.ts
parent819a39a21ac992b1393244a4c283bbb125208c69 (diff)
downloadneko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/@exodus/bytes/base32.d.ts')
-rw-r--r--vanilla/node_modules/@exodus/bytes/base32.d.ts83
1 files changed, 83 insertions, 0 deletions
diff --git a/vanilla/node_modules/@exodus/bytes/base32.d.ts b/vanilla/node_modules/@exodus/bytes/base32.d.ts
new file mode 100644
index 0000000..bf7c2fc
--- /dev/null
+++ b/vanilla/node_modules/@exodus/bytes/base32.d.ts
@@ -0,0 +1,83 @@
+/**
+ * Implements base32 and base32hex from [RFC4648](https://datatracker.ietf.org/doc/html/rfc4648)
+ * (no differences from [RFC3548](https://datatracker.ietf.org/doc/html/rfc4648)).
+ *
+ * ```js
+ * import { fromBase32, toBase32 } from '@exodus/bytes/base32.js'
+ * import { fromBase32hex, toBase32hex } from '@exodus/bytes/base32.js'
+ * ```
+ *
+ * @module @exodus/bytes/base32.js
+ */
+
+/// <reference types="node" />
+
+import type { OutputFormat, Uint8ArrayBuffer } from './array.js';
+
+/**
+ * Options for base32 encoding
+ */
+export interface ToBase32Options {
+ /** Whether to include padding characters (default: false) */
+ padding?: boolean;
+}
+
+/**
+ * Padding mode for base32 decoding
+ * - `true`: padding is required
+ * - `false`: padding is not allowed
+ * - `'both'`: padding is optional (default)
+ */
+export type PaddingMode = boolean | 'both';
+
+/**
+ * Options for base32 decoding
+ */
+export interface FromBase32Options {
+ /** Output format (default: 'uint8') */
+ format?: OutputFormat;
+ /** Padding mode */
+ padding?: PaddingMode;
+}
+
+/**
+ * Encode a `Uint8Array` to a base32 string (RFC 4648)
+ *
+ * @param arr - The input bytes
+ * @param options - Encoding options
+ * @returns The base32 encoded string
+ */
+export function toBase32(arr: Uint8Array, options?: ToBase32Options): string;
+
+/**
+ * Encode a `Uint8Array` to a base32hex string (RFC 4648)
+ *
+ * @param arr - The input bytes
+ * @param options - Encoding options (padding defaults to false)
+ * @returns The base32hex encoded string
+ */
+export function toBase32hex(arr: Uint8Array, options?: ToBase32Options): string;
+
+/**
+ * Decode a base32 string to bytes
+ *
+ * Operates in strict mode for last chunk, does not allow whitespace
+ *
+ * @param string - The base32 encoded string
+ * @param options - Decoding options
+ * @returns The decoded bytes
+ */
+export function fromBase32(string: string, options?: FromBase32Options): Uint8ArrayBuffer;
+export function fromBase32(string: string, options: FromBase32Options & { format: 'buffer' }): Buffer;
+
+/**
+ * Decode a base32hex string to bytes
+ *
+ * Operates in strict mode for last chunk, does not allow whitespace
+ *
+ * @param string - The base32hex encoded string
+ * @param options - Decoding options
+ * @returns The decoded bytes
+ */
+export function fromBase32hex(string: string, options?: FromBase32Options): Uint8ArrayBuffer;
+export function fromBase32hex(string: string, options: FromBase32Options & { format: 'buffer' }): Buffer;