From 76cb9c2a39d477a64824a985ade40507e3bbade1 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 21:34:48 -0800 Subject: feat(vanilla): add testing infrastructure and tests (NK-wjnczv) --- vanilla/node_modules/@exodus/bytes/multi-byte.d.ts | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 vanilla/node_modules/@exodus/bytes/multi-byte.d.ts (limited to 'vanilla/node_modules/@exodus/bytes/multi-byte.d.ts') diff --git a/vanilla/node_modules/@exodus/bytes/multi-byte.d.ts b/vanilla/node_modules/@exodus/bytes/multi-byte.d.ts new file mode 100644 index 0000000..a62313f --- /dev/null +++ b/vanilla/node_modules/@exodus/bytes/multi-byte.d.ts @@ -0,0 +1,64 @@ +/** + * Decode / encode the legacy multi-byte encodings according to the + * [Encoding standard](https://encoding.spec.whatwg.org/) + * ([§10](https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(simplified)-encodings), + * [§11](https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(traditional)-encodings), + * [§12](https://encoding.spec.whatwg.org/#legacy-multi-byte-japanese-encodings), + * [§13](https://encoding.spec.whatwg.org/#legacy-multi-byte-korean-encodings)). + * + * ```js + * import { createMultibyteDecoder, createMultibyteEncoder } from '@exodus/bytes/multi-byte.js' + * ``` + * + * > [!WARNING] + * > This is a lower-level API for legacy multi-byte encodings. + * > + * > For a safe WHATWG Encoding-compatible API, see `@exodus/bytes/encoding.js` import (and variants of it). + * > + * > Be sure to know what you are doing and check documentation when directly using encodings from this file. + * + * Supports all legacy multi-byte encodings listed in the WHATWG Encoding standard: + * `gbk`, `gb18030`, `big5`, `euc-jp`, `iso-2022-jp`, `shift_jis`, `euc-kr`. + * + * @module @exodus/bytes/multi-byte.js + */ + +/// + +import type { Uint8ArrayBuffer } from './array.js'; + +/** + * Create a decoder for a supported legacy multi-byte `encoding`, given its lowercased name `encoding`. + * + * Returns a function `decode(arr, stream = false)` that decodes bytes to a string. + * + * The returned function will maintain internal state while `stream = true` is used, allowing it to + * handle incomplete multi-byte sequences across multiple calls. + * State is reset when `stream = false` or when the function is called without the `stream` parameter. + * + * @param encoding - The encoding name (e.g., 'gbk', 'gb18030', 'big5', 'euc-jp', 'iso-2022-jp', 'shift_jis', 'euc-kr') + * @param loose - If true, replaces unmapped bytes with replacement character instead of throwing (default: false) + * @returns A function that decodes bytes to string, with optional streaming support + */ +export function createMultibyteDecoder( + encoding: string, + loose?: boolean +): (arr: Uint8Array, stream?: boolean) => string; + +/** + * Create an encoder for a supported legacy multi-byte `encoding`, given its lowercased name `encoding`. + * + * Returns a function `encode(string)` that encodes a string to bytes. + * + * In `'fatal'` mode (default), will throw on non well-formed strings or any codepoints which could + * not be encoded in the target encoding. + * + * @param encoding - The encoding name (e.g., 'gbk', 'gb18030', 'big5', 'euc-jp', 'iso-2022-jp', 'shift_jis', 'euc-kr') + * @param options - Encoding options + * @param options.mode - Encoding mode (default: 'fatal'). Currently, only 'fatal' mode is supported. + * @returns A function that encodes string to bytes + */ +export function createMultibyteEncoder( + encoding: string, + options?: { mode?: 'fatal' } +): (string: string) => Uint8ArrayBuffer; -- cgit v1.2.3