import type { ArrayMetadata, ArrayMetadataV2, BigintDataType, Bool, CodecMetadata, DataType, GroupMetadata, NumberDataType, ObjectType, Scalar, StringDataType, TypedArrayConstructor } from "./metadata.js"; export declare function jsonEncodeObject(o: Record): Uint8Array; export declare function assertSharedArrayBufferAvailable(): void; export declare function createBuffer(byteLength: number, useShared?: boolean): ArrayBufferLike; export declare function jsonDecodeObject(bytes: Uint8Array): any; export declare function byteswapInplace(view: Uint8Array, bytesPerElement: number): void; export declare function getCtr(dataType: D): TypedArrayConstructor; /** Compute strides for 'C' or 'F' ordered array from shape */ export declare function getStrides(shape: readonly number[], order: "C" | "F" | Array): Array; export declare function createChunkKeyEncoder({ name, configuration, }: ArrayMetadata["chunk_key_encoding"]): (chunkCoords: number[]) => string; export declare function v2ToV3ArrayMetadata(meta: ArrayMetadataV2, attributes?: Record): ArrayMetadata; export declare function v2ToV3GroupMetadata(_meta: unknown, attributes?: Record): GroupMetadata; export type DataTypeQuery = DataType | "boolean" | "number" | "bigint" | "object" | "string"; export type NarrowDataType = Query extends "number" ? NumberDataType : Query extends "bigint" ? BigintDataType : Query extends "boolean" ? Bool : Query extends "string" ? StringDataType : Query extends "object" ? ObjectType : Extract; export declare function isDataType(dtype: DataType, query: Query): dtype is NarrowDataType; export type ShardingCodecMetadata = { name: "sharding_indexed"; configuration: { chunk_shape: number[]; codecs: CodecMetadata[]; index_codecs: CodecMetadata[]; }; }; export declare function isShardingCodec(codec: CodecMetadata): codec is ShardingCodecMetadata; export declare function ensureCorrectScalar(metadata: ArrayMetadata): Scalar | null; type InstanceType = T extends new (...args: any[]) => infer R ? R : never; type ErrorConstructor = new (...args: any[]) => Error; /** * Ensures an error matches expected type(s), otherwise rethrows. * * Unmatched errors bubble up, like Python's `except`. Narrows error types for * type-safe property access. * * @see {@link https://gist.github.com/manzt/3702f19abb714e21c22ce48851c75abf} * * @example * ```ts * class DatabaseError extends Error { } * class NetworkError extends Error { } * * try { * await db.query(); * } catch (err) { * rethrowUnless(err, DatabaseError, NetworkError); * err // DatabaseError | NetworkError * } * ``` * * @param error - The error to check * @param errors - Expected error type(s) * @throws The original error if it doesn't match expected type(s) */ /** * Merge a first-class `signal` with the deprecated `opts.signal` shim. * If both are set, the signals are combined via `AbortSignal.any` so that * aborting either cancels the request. */ export declare function resolveSignal(opts: { signal?: AbortSignal; opts?: { signal?: AbortSignal; }; }): AbortSignal | undefined; export declare function rethrowUnless>(error: unknown, ...errors: E): asserts error is InstanceType; /** * Make an assertion. * * Usage * @example * ```ts * const value: boolean = Math.random() <= 0.5; * assert(value, "value is greater than than 0.5!"); * value // true * ``` * * @param expression - The expression to test. * @param msg - The optional message to display if the assertion fails. * @throws an {@link Error} if `expression` is not truthy. */ export declare function assert(expression: unknown, msg?: string | undefined): asserts expression; /** * Decompress data using the given format via the Web Streams API. * Views backed by a SharedArrayBuffer are copied into a regular ArrayBuffer * since the Response constructor does not accept shared memory. */ export declare function decompress(data: ArrayBuffer | ArrayBufferView, { format, signal }: { format: CompressionFormat; signal?: AbortSignal; }): Promise; export {}; //# sourceMappingURL=util.d.ts.map