mirror of
https://github.com/fluencelabs/libp2p-ts
synced 2025-03-16 10:10:51 +00:00
Add PeerInfo
This commit is contained in:
parent
a52b3e4c99
commit
c5042735b3
2
peer-id/index.d.ts
vendored
2
peer-id/index.d.ts
vendored
@ -35,4 +35,4 @@ declare class PeerId {
|
||||
toJSON (): JSON;
|
||||
}
|
||||
|
||||
export = PeerId;
|
||||
export default PeerId;
|
||||
|
48
peer-info/index.d.ts
vendored
Normal file
48
peer-info/index.d.ts
vendored
Normal 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;
|
0
peer-info/peer-info-tests.ts
Normal file
0
peer-info/peer-info-tests.ts
Normal file
16
peer-info/tsconfig.json
Normal file
16
peer-info/tsconfig.json
Normal 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
1
peer-info/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
Loading…
x
Reference in New Issue
Block a user