mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 22:52:19 +00:00
fix type errors
This commit is contained in:
parent
e16e25cbef
commit
153f51ae5a
13
src/@types/it-length-prefixed/index.d.ts
vendored
13
src/@types/it-length-prefixed/index.d.ts
vendored
@ -1,7 +1,6 @@
|
|||||||
declare module "it-length-prefixed" {
|
declare module 'it-length-prefixed' {
|
||||||
/* eslint-disable @typescript-eslint/interface-name-prefix */
|
import BufferList from 'bl'
|
||||||
import BufferList from "bl";
|
import { Buffer } from 'buffer'
|
||||||
import {Buffer} from "buffer"
|
|
||||||
|
|
||||||
interface LengthDecoderFunction {
|
interface LengthDecoderFunction {
|
||||||
(data: Buffer | BufferList): number;
|
(data: Buffer | BufferList): number;
|
||||||
@ -9,7 +8,7 @@ declare module "it-length-prefixed" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface LengthEncoderFunction {
|
interface LengthEncoderFunction {
|
||||||
(value: Buffer, target: number, offset: number): number|Buffer;
|
(value: number, target: Buffer, offset: number): number|Buffer;
|
||||||
bytes: number;
|
bytes: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ declare module "it-length-prefixed" {
|
|||||||
MAX_DATA_LENGTH: number;
|
MAX_DATA_LENGTH: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const encode: Encoder;
|
export const encode: Encoder
|
||||||
export const decode: Decoder;
|
export const decode: Decoder
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
import { Buffer } from 'buffer'
|
import { Buffer } from 'buffer'
|
||||||
import { bytes } from './@types/basic'
|
import { bytes } from './@types/basic'
|
||||||
import { MessageBuffer } from './@types/handshake'
|
import { MessageBuffer } from './@types/handshake'
|
||||||
|
import BufferList from 'bl'
|
||||||
|
|
||||||
export const uint16BEEncode = (value: number, target: bytes, offset: number): bytes => {
|
export const uint16BEEncode = (value: number, target: Buffer, offset: number): Buffer => {
|
||||||
target = target || Buffer.allocUnsafe(2)
|
target = target || Buffer.allocUnsafe(2)
|
||||||
target.writeUInt16BE(value, offset)
|
target.writeUInt16BE(value, offset)
|
||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
uint16BEEncode.bytes = 2
|
uint16BEEncode.bytes = 2
|
||||||
|
|
||||||
export const uint16BEDecode = (data: bytes): number => {
|
export const uint16BEDecode = (data: Buffer | BufferList): number => {
|
||||||
if (data.length < 2) throw RangeError('Could not decode int16BE')
|
if (data.length < 2) throw RangeError('Could not decode int16BE')
|
||||||
return data.readUInt16BE(0)
|
return data.readUInt16BE(0)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
export class FailedIKError extends Error {
|
import BufferList from 'bl'
|
||||||
public initialMsg: string;
|
|
||||||
|
|
||||||
constructor (initialMsg: string, message?: string) {
|
export class FailedIKError extends Error {
|
||||||
|
public initialMsg: string|BufferList|Buffer;
|
||||||
|
|
||||||
|
constructor (initialMsg: string|BufferList|Buffer, message?: string) {
|
||||||
super(message)
|
super(message)
|
||||||
|
|
||||||
this.initialMsg = initialMsg
|
this.initialMsg = initialMsg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user