Skip to content

Commit

Permalink
chromium-pickle-js typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
lafkpages committed Oct 30, 2023
1 parent ba10619 commit 8bcf3cd
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/types/chromium-pickle-js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
declare module "chromium-pickle-js" {
export declare function createEmpty(): IPickle;

export declare function createFromBuffer(buffer: Uint8Array): IPickle;

export declare interface IPickle {
header: Uint8Array;
headerSize: number;
initEmpty(): void;
initFromBuffer(buffer: Uint8Array): void;
createIterator(): IPickleIterator;
toBuffer(): Uint8Array;
writeBool(value: boolean): boolean;
writeInt(value: number): boolean;
writeUInt32(value: number): boolean;
writeInt64(value: bigint | number): boolean;
writeUInt64(value: bigint | number): boolean;
writeFloat(value: number): boolean;
writeDouble(value: number): boolean;
writeString(value: string): boolean;
setPayloadSize(payloadSize: number): number;
getPayloadSize(): number;
writeBytes(data: Uint8Array, length: number): boolean;
writeBytes<T extends number | bigint>(
data: T,
length: number,
method: (data: T, offset?: number) => number
): boolean;
resize(newCapacity: number): void;
}

export declare interface IPickleIterator {
readBool(): boolean;
readInt(): number;
readUInt32(): number;
readInt64(): bigint;
readUInt64(): bigint;
readFloat(): number;
readDouble(): number;
readString(): string;
readBytes(length: number): Uint8Array;
readBytes<T extends number | bigint>(
length: number,
method: (this: Uint8Array, offset: number) => T
): T;
getReadPayloadOffsetAndAdvance(length: number): number;
advance(size: number): void;
}

export {};

export as namespace chromiumPickle;
}

0 comments on commit 8bcf3cd

Please sign in to comment.