UNPKG

quick-struct

Version:

C like style to write struct layout, and it can convert variable length array or string automatically. It can be used in Node.js and Browser

25 lines (24 loc) 1.14 kB
export declare type StructBlocks = Array<[structName: string, fieldNames: string[], fields: FieldRecordArray]>; export interface StructRawBlockItem { [0]: string; [1]: string; } export interface StructAttribute { [idx: string]: number | string | boolean | undefined; ver: number; autoflush: boolean; endian: "big" | "little"; } export declare type StructRawBlockArray = Array<StructRawBlockItem>; export interface FieldRecord { [0]: number; [1]: number; [2]: number; } export declare type FieldRecordArray = Array<FieldRecord>; export declare const findStructBlocks: (descriptor: string, fromIndex?: number) => StructRawBlockArray; export declare const parseStructAttribute: (description: string) => Partial<StructAttribute>; export declare const parseAttribute: (typeCode: number, length: undefined | string, expand?: string | undefined) => 0 | 2 | 3 | 6 | 7; export declare const parseArrayLength: (length: string | undefined, names: string[]) => number; export declare const parseBody: (body: string) => (string[] | FieldRecordArray)[]; export declare const compile: (descriptor: string) => StructBlocks;