cborkit
Version:
A modern, extensible CBOR (Concise Binary Object Representation) library for TypeScript and JavaScript.
56 lines (54 loc) • 1.4 kB
TypeScript
declare const MajorType: {
readonly PosInt: 0;
readonly NegInt: 1;
readonly Bytes: 2;
readonly Text: 3;
readonly Array: 4;
readonly Map: 5;
readonly Tag: 6;
readonly Special: 7;
};
type MajorTypeValue = (typeof MajorType)[keyof typeof MajorType];
type CborHeader = {
major: MajorTypeValue;
shortCount: number;
extendedCount?: number | bigint;
headerLength: number;
itemLength: bigint | number | null;
};
type CborType = CborItem["type"];
type CborItem = CborInt | CborBytes | CborText | CborArray | CborMap | CborTag | CborSimple | CborFloat;
type CborInt = {
type: "int";
value: number | bigint;
};
type CborBytes = {
type: "bytes";
value: Uint8Array;
};
type CborText = {
type: "text";
value: string;
};
type CborArray = {
type: "array";
value: CborItem[];
};
type CborMap = {
type: "map";
value: [CborItem, CborItem][];
};
type CborSimple = {
type: "simple";
value: number;
};
type CborFloat = {
type: "float";
value: number;
};
type CborTag = {
type: "tag";
value: number | bigint;
item: CborItem;
};
export { type CborHeader as C, MajorType as M, type MajorTypeValue as a, type CborType as b, type CborItem as c, type CborInt as d, type CborBytes as e, type CborText as f, type CborArray as g, type CborMap as h, type CborSimple as i, type CborFloat as j, type CborTag as k };