Add PeerInfo

This commit is contained in:
Jaco Greeff 2018-06-21 13:40:56 +02:00
parent a52b3e4c99
commit c5042735b3
5 changed files with 66 additions and 1 deletions

2
peer-id/index.d.ts vendored
View File

@ -35,4 +35,4 @@ declare class PeerId {
toJSON (): JSON;
}
export = PeerId;
export default PeerId;

48
peer-info/index.d.ts vendored Normal file
View File

@ -0,0 +1,48 @@
// Type definitions for peer-id 0.10.7
// Project: https://github.com/libp2p/js-peer-id
// Definitions by: Jaco Greeff <https://github.com/jacogr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
import MultiAddr from 'multiaddr';
import PeerId from 'peer-id';
type CreateCb = (error: Error | null, peerId?: PeerId) => any;
type CreateOptions = {
bits: number
};
type JSON = {
id: string,
pubKey: string,
privKey: string
};
type MultiAddrSet = {
size: number;
add (addr: MultiAddr): void;
addSafe (add: MultiAddr): void;
delete (addr: MultiAddr): void;
forEach (cb: (addr: MultiAddr, index: number) => any): void;
has (addr: MultiAddr): boolean;
replace (addr: MultiAddr, other: MultiAddr): void;
toArray (): MultiAddr[];
};
declare class PeerInfo {
constructor (id?: PeerId);
static create (optsOrCb: CreateOptions | CreateCb, cb?: CreateCb): PeerInfo;
static isPeerInfo (info: any): info is PeerInfo;
multiaddrs: MultiAddrSet;
connect (addr: MultiAddr): void;
disconnect (): void;
isConnected (): boolean;
}
export default PeerInfo;

View File

16
peer-info/tsconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "bn.js-tests.ts"]
}

1
peer-info/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }