libp2p-ts/multiaddr/index.d.ts

57 lines
1.5 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-24 10:16:29 +02:00
/// <reference types="../peer-id"/>
2018-06-21 13:29:23 +02:00
2018-06-24 10:16:29 +02:00
declare namespace MultiAddr {
type Address = {
family: string,
host: string,
port: string
};
2018-06-21 13:29:23 +02:00
2018-06-24 10:16:29 +02:00
type Options = Address & {
transport: string
};
2018-06-21 13:29:23 +02:00
2018-06-24 10:16:29 +02:00
type Proto = {
code: number,
name: string,
size: number
};
2018-06-21 13:29:23 +02:00
2018-06-24 10:16:29 +02:00
type Tuple = [ number, Buffer ];
2018-06-21 13:29:23 +02:00
2018-06-24 10:16:29 +02:00
type TupleString = [ number, string ];
}
2018-06-21 13:29:23 +02:00
2018-06-24 10:16:29 +02:00
declare 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-24 10:16:29 +02:00
nodeAddress (): MultiAddr.Address;
protos (): MultiAddr.Proto[];
2018-06-21 13:29:23 +02:00
protoCodes (): number[];
protoNames (): string[];
2018-06-24 10:16:29 +02:00
stringTuples (): MultiAddr.TupleString[];
tuples (): MultiAddr.Tuple[];
toOptions (): MultiAddr.Options;
2018-06-21 13:29:23 +02:00
toString (): string;
}
2018-06-24 10:16:29 +02:00
declare module 'multiaddr' {
export default MultiAddr;
2018-06-22 15:43:18 +02:00
}