Add multiaddr

This commit is contained in:
Jaco Greeff 2018-06-21 13:29:23 +02:00
parent e18b84e220
commit a52b3e4c99
5 changed files with 73 additions and 1 deletions

View File

@ -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
View 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;

View File

16
multiaddr/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
multiaddr/tslint.json Normal file
View File

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