mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-06-11 20:31:37 +00:00
add it-length-prefixed types
This commit is contained in:
39
src/@types/it-length-prefixed/index.d.ts
vendored
Normal file
39
src/@types/it-length-prefixed/index.d.ts
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
declare module "it-length-prefixed" {
|
||||||
|
/* eslint-disable @typescript-eslint/interface-name-prefix */
|
||||||
|
import BufferList from "bl";
|
||||||
|
import {Buffer} from "buffer"
|
||||||
|
|
||||||
|
interface LengthDecoderFunction {
|
||||||
|
(data: Buffer | BufferList): number;
|
||||||
|
bytes: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LengthEncoderFunction {
|
||||||
|
(value: Buffer, target: number, offset: number): number|Buffer;
|
||||||
|
bytes: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Encoder {
|
||||||
|
(options?: Partial<{lengthEncoder: LengthEncoderFunction}>): AsyncGenerator<BufferList, Buffer>;
|
||||||
|
single: (chunk: Buffer, options?: Partial<{lengthEncoder: LengthEncoderFunction}>) => BufferList;
|
||||||
|
MIN_POOL_SIZE: number;
|
||||||
|
DEFAULT_POOL_SIZE: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DecoderOptions {
|
||||||
|
lengthDecoder: LengthDecoderFunction;
|
||||||
|
maxLengthLength: number;
|
||||||
|
maxDataLength: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Decoder {
|
||||||
|
(options?: Partial<DecoderOptions>): AsyncGenerator<BufferList, BufferList>;
|
||||||
|
fromReader: (reader: any, options?: Partial<DecoderOptions>) => BufferList;
|
||||||
|
MAX_LENGTH_LENGTH: number;
|
||||||
|
MAX_DATA_LENGTH: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const encode: Encoder;
|
||||||
|
export const decode: Decoder;
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user