Skip to content

Commit

Permalink
typings: add types for internalBinding('serdes')
Browse files Browse the repository at this point in the history
PR-URL: #38204
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
targos committed Apr 18, 2021
1 parent d97787f commit 1c8b295
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"exclude": ["src","tools","out"],
"files": [
"./typings/internalBinding/fs.d.ts",
"./typings/internalBinding/serdes.d.ts",
"./typings/internalBinding/util.d.ts",
"./typings/internalBinding.d.ts",
"./typings/primordials.d.ts"
Expand Down
34 changes: 34 additions & 0 deletions typings/internalBinding/serdes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
declare namespace InternalSerdesBinding {
class Serializer {
_getDataCloneError: typeof Error;
constructor();
_setTreatArrayBufferViewsAsHostObjects(value: boolean): void;
releaseBuffer(): Buffer;
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
writeDouble(value: number): void;
writeHeader(): void;
writeRawBytes(value: ArrayBufferView): void;
writeUint32(value: number): void;
writeUint64(hi: number, lo: number): void;
writeValue(value: any): void;
}

class Deserializer {
buffer: ArrayBufferView;
constructor(buffer: ArrayBufferView);
_readRawBytes(length: number): number;
getWireFormatVersion(): number;
readDouble(): number;
readHeader(): boolean;
readRawBytes(length: number): Buffer;
readUint32(): number;
readUint64(): [hi: number, lo: number];
readValue(): unknown;
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer | SharedArrayBuffer): void;
}
}

declare function InternalBinding(binding: 'serdes'): {
Serializer: typeof InternalSerdesBinding.Serializer;
Deserializer: typeof InternalSerdesBinding.Deserializer;
};

0 comments on commit 1c8b295

Please sign in to comment.