libp2p-ts/multiaddr/index.d.ts

57 lines
1.3 KiB
TypeScript
Raw Normal View History

2018-06-21 13:29:23 +02:00
// Type definitions for multiaddr 5.0.0
// Project: https://github.com/multiformats/js-multiaddr
// Definitions by: Jaco Greeff <https://github.com/jacogr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
2018-06-22 15:43:18 +02:00
// @ts-ignore
import PeerId from 'peer-id';
2018-06-21 13:29:23 +02:00
2018-06-22 15:43:18 +02:00
declare module 'multiaddr' {
2018-06-21 13:29:23 +02:00
type Address = {
family: string,
host: string,
port: string
};
type Options = Address & {
transport: string
};
type Proto = {
code: number,
name: string,
size: number
};
type Tuple = [ number, Buffer ];
type TupleString = [ number, string ];
2018-06-22 15:43:18 +02:00
class MultiAddr {
2018-06-21 13:43:06 +02:00
constructor (addr: MultiAddr | Buffer | string);
2018-06-21 13:29:23 +02:00
2018-06-21 13:43:06 +02:00
static isMultiAddr (addr: any): addr is MultiAddr;
static isName (other: MultiAddr): boolean;
static fromNodeAddress (addr: { address: string, port: string }, transport: string): MultiAddr;
2018-06-21 13:29:23 +02:00
2018-06-21 13:43:06 +02:00
decapsulate (other: MultiAddr): MultiAddr;
encapsulate (other: MultiAddr): MultiAddr;
equals (other: MultiAddr): boolean;
2018-06-21 13:29:23 +02:00
getPeerId (): PeerId;
inspect (): string;
2018-06-21 13:43:06 +02:00
isThinWaistAddress (other?: MultiAddr): boolean;
2018-06-21 13:29:23 +02:00
nodeAddress (): Address;
protos (): Proto[];
protoCodes (): number[];
protoNames (): string[];
stringTuples (): TupleString[];
tuples (): Tuple[];
toOptions (): Options;
toString (): string;
}
export = MultiAddr;
2018-06-22 15:43:18 +02:00
}