From 1c8b2956d1120666ba8ef9a7caa01c5512cef42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 11 Apr 2021 18:11:27 +0200 Subject: [PATCH] typings: add types for internalBinding('serdes') PR-URL: https://github.com/nodejs/node/pull/38204 Reviewed-By: Bradley Farias Reviewed-By: James M Snell --- tsconfig.json | 1 + typings/internalBinding/serdes.d.ts | 34 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 typings/internalBinding/serdes.d.ts diff --git a/tsconfig.json b/tsconfig.json index 80189489b6c02f..81b736a5fdc4fb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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" diff --git a/typings/internalBinding/serdes.d.ts b/typings/internalBinding/serdes.d.ts new file mode 100644 index 00000000000000..d328123e25ade4 --- /dev/null +++ b/typings/internalBinding/serdes.d.ts @@ -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; +};