forked from geckosio/typed-array-buffer-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
35 lines (29 loc) · 811 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type {Model} from './model';
import type {Schema} from './schema';
/* eslint-disable @typescript-eslint/consistent-indexed-object-style */
/**
* Defines a TypedArray.
*/
export type TypedArrayView = {
_type: string;
_bytes: number;
};
/**
* Specify the TypedArray and the number of digits to truncate.
*/
export type TypedArrayDefinition = {
type: TypedArrayView;
digits?: number;
length?: number;
};
/**
* A TypedArray, TypedArrayDefinition, or Schema.
*/
export type TypedArrayOrSchema = TypedArrayView | TypedArrayDefinition | Schema | [Schema];
/**
* Defines a BufferSchema.
*/
export type SchemaDefinition<T extends Record<string, any>> = {
[K in keyof T]: SchemaDefinition<T[K]> | TypedArrayOrSchema;
};
export type ExtractModel<P> = P extends Model<infer T> ? T : never;