UNPKG

struffer

Version:
64 lines (63 loc) 1.8 kB
export declare type BinaryValue = 0 | 1; export declare type ByteBit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; export declare enum MemberEndianness { LittleEndian = 0, BigEndian = 1 } export declare enum MemberSignature { Signed = 0, Unsigned = 1 } export interface MemberDictionary { [x: string]: number | undefined; } export interface MemberPresenceTable { [x: string]: boolean; } export interface MemberInfo { /** * The byte where the member starts. * Relative to the buffer. */ startByteOffset: number; /** * The bit where the member starts. * Relative to the starting byte. */ startBitOffset: ByteBit; /** * The byte where the member ends. * Relative to the buffer. * Inclusive. */ endByteOffset: number; /** * The bit where the member ends. * Relative to the ending byte. * Inclusive. */ endBitOffset: ByteBit; /** * The endianness of the member (i.e. whether it's big or little endian) */ endianness: MemberEndianness; /** * The signature of the member (i.e. whether it's signed or unsigned) */ signature: MemberSignature; /** * The size of the member in bits */ bitSize: number; } export interface TypeInfo { endianness: MemberEndianness; signature: MemberSignature; bitSize: number; } export declare function totalBits(num: number): number; export declare function splitIntoBits(num: number, includeSign?: boolean): BinaryValue[]; export declare function unsignedSplit(n: number, bitCount?: number): BinaryValue[]; export declare function joinBits(bits: BinaryValue[]): number; export declare function joinSignedBits(_bits: BinaryValue[]): number; export declare function parseType(_type: string): TypeInfo;