mirror of
https://github.com/fluencelabs/libp2p-ts
synced 2025-04-25 05:42:12 +00:00
Add multiaddr
This commit is contained in:
parent
e18b84e220
commit
a52b3e4c99
@ -9,5 +9,7 @@ In general, updates here should have corrsponding PRs on the DefinitelyTyped rep
|
|||||||
This following libraries are currently included. Where possible add the relevant DT PRs as there are included - may not be applicable initially if definitions are not expansive enough or fully tested internally.
|
This following libraries are currently included. Where possible add the relevant DT PRs as there are included - may not be applicable initially if definitions are not expansive enough or fully tested internally.
|
||||||
|
|
||||||
- [blakejs](https://github.com/dcposch/blakejs)
|
- [blakejs](https://github.com/dcposch/blakejs)
|
||||||
- [bn.js](https://github.com/indutny/bn.js/) [@types PR #26717](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26717)
|
- [bn.js](https://github.com/indutny/bn.js) [@types PR #26717](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26717)
|
||||||
- [keccak](https://github.com/cryptocoinjs/keccak)
|
- [keccak](https://github.com/cryptocoinjs/keccak)
|
||||||
|
- [multiaddr](https://github.com/multiformats/js-multiaddr)
|
||||||
|
- [peer-id](https://github.com/libp2p/js-peer-id)
|
||||||
|
53
multiaddr/index.d.ts
vendored
Normal file
53
multiaddr/index.d.ts
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// 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"/>
|
||||||
|
|
||||||
|
import PeerId from 'peer-id';
|
||||||
|
|
||||||
|
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 ];
|
||||||
|
|
||||||
|
declare class Multiaddr {
|
||||||
|
constructor (addr: Multiaddr | Buffer | string);
|
||||||
|
|
||||||
|
static isMultiaddr (addr: Multiaddr): addr is Multiaddr;
|
||||||
|
static isName (other: Multiaddr): boolean;
|
||||||
|
static fromNodeAddress (addr: { address: string, port: string }, transport: string): Multiaddr;
|
||||||
|
|
||||||
|
decapsulate (other: Multiaddr): Multiaddr;
|
||||||
|
encapsulate (other: Multiaddr): Multiaddr;
|
||||||
|
equals (other: Multiaddr): boolean;
|
||||||
|
getPeerId (): PeerId;
|
||||||
|
inspect (): string;
|
||||||
|
isThinWaistAddress (other?: Multiaddr): boolean;
|
||||||
|
nodeAddress (): Address;
|
||||||
|
protos (): Proto[];
|
||||||
|
protoCodes (): number[];
|
||||||
|
protoNames (): string[];
|
||||||
|
stringTuples (): TupleString[];
|
||||||
|
tuples (): Tuple[];
|
||||||
|
toOptions (): Options;
|
||||||
|
toString (): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Multiaddr;
|
0
multiaddr/multiaddr-tests.ts
Normal file
0
multiaddr/multiaddr-tests.ts
Normal file
16
multiaddr/tsconfig.json
Normal file
16
multiaddr/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
multiaddr/tslint.json
Normal file
1
multiaddr/tslint.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{ "extends": "dtslint/dt.json" }
|
Loading…
x
Reference in New Issue
Block a user