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/array.d.ts | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 vanilla/node_modules/@exodus/bytes/array.d.ts (limited to 'vanilla/node_modules/@exodus/bytes/array.d.ts') diff --git a/vanilla/node_modules/@exodus/bytes/array.d.ts b/vanilla/node_modules/@exodus/bytes/array.d.ts new file mode 100644 index 0000000..c81d16f --- /dev/null +++ b/vanilla/node_modules/@exodus/bytes/array.d.ts @@ -0,0 +1,62 @@ +/** + * TypedArray utils and conversions. + * + * ```js + * import { typedView } from '@exodus/bytes/array.js' + * ``` + * + * @module @exodus/bytes/array.js + */ + +/// + +// >= TypeScript 5.9 made Uint8Array templated with <> and defaulted to ArrayBufferLike +// which would incorrectly accept SharedArrayBuffer instances. +// < TypeScript 5.7 doesn't support templates for Uint8Array. +// So this type is defined as a workaround to evaluate to Uint8Array on all versions of TypeScript. + +/** + * This is `Uint8Array` + * (as opposed to `Uint8Array` and `Uint8Array`) + * on TypeScript versions that support that distinction. + * + * On TypeScript < 5.7, this is just `Uint8Array`, as it's not a template there. + */ +export type Uint8ArrayBuffer = ReturnType; + +/** + * This is `Uint16Array` + * (as opposed to `Uint16Array` and `Uint16Array`) + * on TypeScript versions that support that distinction. + * + * On TypeScript < 5.7, this is just `Uint16Array`, as it's not a template there. + */ +export type Uint16ArrayBuffer = ReturnType; + +/** + * This is `Uint32Array` + * (as opposed to `Uint32Array` and `Uint32Array`) + * on TypeScript versions that support that distinction. + * + * On TypeScript < 5.7, this is just `Uint32Array`, as it's not a template there. + */ +export type Uint32ArrayBuffer = ReturnType; + +/** + * Output format for typed array conversions + */ +export type OutputFormat = 'uint8' | 'buffer'; + +/** + * Create a view of a TypedArray in the specified format (`'uint8'` or `'buffer'`) + * + * > [!IMPORTANT] + * > Does not copy data, returns a view on the same underlying buffer + * + * @param arr - The input TypedArray + * @param format - The desired output format (`'uint8'` or `'buffer'`) + * @returns A view on the same underlying buffer + */ +export function typedView(arr: ArrayBufferView, format: 'uint8'): Uint8Array; +export function typedView(arr: ArrayBufferView, format: 'buffer'): Buffer; +export function typedView(arr: ArrayBufferView, format: OutputFormat): Uint8Array | Buffer; -- cgit v1.2.3