123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- type ValueOf<T> = T[keyof T];
- // Add constructor options type
- export interface NpyjsOptions {
- convertFloat16?: boolean;
- }
- export type Dtypes = {
- "<u1": {
- name: "uint8";
- size: 8;
- arrayConstructor: typeof Uint8Array;
- };
- "|u1": {
- name: "uint8";
- size: 8;
- arrayConstructor: typeof Uint8Array;
- };
- "<u2": {
- name: "uint16";
- size: 16;
- arrayConstructor: typeof Uint16Array;
- };
- "|i1": {
- name: "int8";
- size: 8;
- arrayConstructor: typeof Int8Array;
- };
- "<i2": {
- name: "int16";
- size: 16;
- arrayConstructor: typeof Int16Array;
- };
- "<u4": {
- name: "uint32";
- size: 32;
- arrayConstructor: typeof Int32Array;
- };
- "<i4": {
- name: "int32";
- size: 32;
- arrayConstructor: typeof Int32Array;
- };
- "<u8": {
- name: "uint64";
- size: 64;
- arrayConstructor: typeof BigUint64Array;
- };
- "<i8": {
- name: "int64";
- size: 64;
- arrayConstructor: typeof BigInt64Array;
- };
- "<f4": {
- name: "float32";
- size: 32;
- arrayConstructor: typeof Float32Array;
- };
- "<f8": {
- name: "float64";
- size: 64;
- arrayConstructor: typeof Float64Array;
- };
- "<f2": {
- name: "float16";
- size: 16;
- arrayConstructor: typeof Uint16Array;
- converter?: (array: Uint16Array) => Float32Array;
- };
- };
- export type Parsed = ValueOf<{
- [K in keyof Dtypes]: {
- dtype: Dtypes[K]["name"];
- data: K extends "<f2" ? Float32Array : InstanceType<Dtypes[K]["arrayConstructor"]>;
- shape: number[];
- fortranOrder: boolean;
- };
- }>;
- declare class npyjs {
- constructor(opts?: NpyjsOptions);
- dtypes: Dtypes;
- parse(arrayBufferContents: ArrayBuffer): Parsed;
- load(
- filename: RequestInfo | URL | ArrayBuffer,
- callback?: (result?: Parsed) => any,
- fetchArgs?: RequestInit
- ): Promise<Parsed>;
- float16ToFloat32Array(float16Array: Uint16Array): Float32Array;
- static float16ToFloat32(float16: number): number;
- }
- export default npyjs;
|