From d0869fbebc5228783fec169bb62c60e86023e36a Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 21 Jun 2018 15:49:53 +0200 Subject: [PATCH] Add pull-{pushable,streams}, cleanup commonjs exports --- README.md | 2 ++ interface-connection/index.d.ts | 4 ++-- interface-transport/index.d.ts | 2 +- libp2p-kad-dht/index.d.ts | 2 +- libp2p-mdns/index.d.ts | 4 ++-- libp2p-mplex/index.d.ts | 2 +- libp2p-railing/index.d.ts | 6 +++--- libp2p-secio/index.d.ts | 4 ++-- libp2p-spdy/index.d.ts | 2 +- libp2p-tcp/index.d.ts | 4 ++-- libp2p-webrtc-direct/index.d.ts | 4 ++-- libp2p-webrtc-star/index.d.ts | 4 ++-- libp2p-websockets/index.d.ts | 4 ++-- libp2p/index.d.ts | 22 +++++++++++----------- multiaddr/index.d.ts | 4 ++-- peer-book/index.d.ts | 6 +++--- peer-id/index.d.ts | 2 +- peer-info/index.d.ts | 6 +++--- pull-pushable/index.d.ts | 14 ++++++++++++++ pull-pushable/pull-pushable-tests.ts | 0 pull-pushable/tsconfig.json | 16 ++++++++++++++++ pull-pushable/tslint.json | 1 + pull-stream/index.d.ts | 16 ++++++++++++++++ pull-stream/pull-stream-tests.ts | 0 pull-stream/tsconfig.json | 16 ++++++++++++++++ pull-stream/tslint.json | 1 + 26 files changed, 107 insertions(+), 41 deletions(-) create mode 100644 pull-pushable/index.d.ts create mode 100644 pull-pushable/pull-pushable-tests.ts create mode 100644 pull-pushable/tsconfig.json create mode 100644 pull-pushable/tslint.json create mode 100644 pull-stream/index.d.ts create mode 100644 pull-stream/pull-stream-tests.ts create mode 100644 pull-stream/tsconfig.json create mode 100644 pull-stream/tslint.json diff --git a/README.md b/README.md index c9beade..1df7a31 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,5 @@ This following libraries are currently included. Where possible add the relevant - [peer-book](https://github.com/libp2p/js-peer-book) - [peer-id](https://github.com/libp2p/js-peer-id) - [peer-info](https://github.com/libp2p/js-peer-info) +- [pull-pushable](https://github.com/pull-stream/pull-pushable) +- [pull-stream](https://github.com/pull-stream/pull-stream) diff --git a/interface-connection/index.d.ts b/interface-connection/index.d.ts index ae7b712..a4c16e3 100644 --- a/interface-connection/index.d.ts +++ b/interface-connection/index.d.ts @@ -3,10 +3,10 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import PeerInfo from 'peer-info'; +import PeerInfo = require('peer-info'); declare interface Connection { getPeerInfo (cb: (error: Error | null, peerInfo?: PeerInfo) => any): void; } -export default Connection; +export = Connection; diff --git a/interface-transport/index.d.ts b/interface-transport/index.d.ts index 1fec965..0567dc8 100644 --- a/interface-transport/index.d.ts +++ b/interface-transport/index.d.ts @@ -6,4 +6,4 @@ declare interface Transport { } -export default Transport; +export = Transport; diff --git a/libp2p-kad-dht/index.d.ts b/libp2p-kad-dht/index.d.ts index 23bca5e..1a87e64 100644 --- a/libp2p-kad-dht/index.d.ts +++ b/libp2p-kad-dht/index.d.ts @@ -6,4 +6,4 @@ declare class LibP2pKadDht { } -export default LibP2pKadDht; +export = LibP2pKadDht; diff --git a/libp2p-mdns/index.d.ts b/libp2p-mdns/index.d.ts index 68cde83..43466f3 100644 --- a/libp2p-mdns/index.d.ts +++ b/libp2p-mdns/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import PeerInfo from 'peer-info'; +import PeerInfo = require('peer-info'); type Options = { broadcast?: boolean, @@ -21,4 +21,4 @@ declare class LibP2pMdns { on (event: Events, cb: (peerInfo: PeerInfo) => any): void; } -export default LibP2pMdns; +export = LibP2pMdns; diff --git a/libp2p-mplex/index.d.ts b/libp2p-mplex/index.d.ts index e98df54..67e45ec 100644 --- a/libp2p-mplex/index.d.ts +++ b/libp2p-mplex/index.d.ts @@ -14,4 +14,4 @@ declare type LibP2pMplex = { muticodec: string; } -export default LibP2pMplex; +export = LibP2pMplex; diff --git a/libp2p-railing/index.d.ts b/libp2p-railing/index.d.ts index e6db9c3..43d8ad6 100644 --- a/libp2p-railing/index.d.ts +++ b/libp2p-railing/index.d.ts @@ -3,8 +3,8 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import MultiAddr from 'multiaddr'; -import PeerInfo from 'peer-info'; +import MultiAddr = require('multiaddr'); +import PeerInfo = require('peer-info'); type Options = { list: Array, @@ -19,4 +19,4 @@ declare class LibP2pRailing { on (event: Events, cb: (peerInfo: PeerInfo) => any): void; } -export default LibP2pRailing; +export = LibP2pRailing; diff --git a/libp2p-secio/index.d.ts b/libp2p-secio/index.d.ts index b16da3d..fa05df4 100644 --- a/libp2p-secio/index.d.ts +++ b/libp2p-secio/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import PeerId from 'peer-id'; +import PeerId = require('peer-id'); declare type LibP2pSecio = { tag: '/secio/1.0.0', @@ -11,4 +11,4 @@ declare type LibP2pSecio = { encrypt (localId: PeerId, conn: any, remoteId: PeerId, callback: () => any): void } -export default LibP2pSecio; +export = LibP2pSecio; diff --git a/libp2p-spdy/index.d.ts b/libp2p-spdy/index.d.ts index 69567b5..570015a 100644 --- a/libp2p-spdy/index.d.ts +++ b/libp2p-spdy/index.d.ts @@ -14,4 +14,4 @@ declare type LibP2pSpdy = { muticodec: string; } -export default LibP2pSpdy; +export = LibP2pSpdy; diff --git a/libp2p-tcp/index.d.ts b/libp2p-tcp/index.d.ts index 0c78fb4..0a7df9d 100644 --- a/libp2p-tcp/index.d.ts +++ b/libp2p-tcp/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import Transport from 'interface-transport'; +import Transport = require('interface-transport'); declare class LibP2pTcp implements Transport { } -export default LibP2pTcp; +export = LibP2pTcp; diff --git a/libp2p-webrtc-direct/index.d.ts b/libp2p-webrtc-direct/index.d.ts index 5801a54..5077f4c 100644 --- a/libp2p-webrtc-direct/index.d.ts +++ b/libp2p-webrtc-direct/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import Transport from 'interface-transport'; +import Transport = require('interface-transport'); declare class LibP2pWebRtcDirect implements Transport { } -export default LibP2pWebRtcDirect; +export = LibP2pWebRtcDirect; diff --git a/libp2p-webrtc-star/index.d.ts b/libp2p-webrtc-star/index.d.ts index 264eaef..f90dae9 100644 --- a/libp2p-webrtc-star/index.d.ts +++ b/libp2p-webrtc-star/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import Transport from 'interface-transport'; +import Transport = require('interface-transport'); declare class LibP2pWebRtcStar implements Transport { } -export default LibP2pWebRtcStar; +export = LibP2pWebRtcStar; diff --git a/libp2p-websockets/index.d.ts b/libp2p-websockets/index.d.ts index cca719f..7cfcfa1 100644 --- a/libp2p-websockets/index.d.ts +++ b/libp2p-websockets/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import Transport from 'interface-transport'; +import Transport = require('interface-transport'); declare class LibP2pWebsockets implements Transport { } -export default LibP2pWebsockets; +export = LibP2pWebsockets; diff --git a/libp2p/index.d.ts b/libp2p/index.d.ts index e310b36..bb8dc22 100644 --- a/libp2p/index.d.ts +++ b/libp2p/index.d.ts @@ -3,16 +3,16 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import Connection from 'interface-connection'; -import Transport from 'interface-transport'; -import Libp2pKadDHT from 'libp2p-kad-dht'; -import LibP2pMdns from 'libp2p-mdns'; -import LibP2pMplex from 'libp2p-mplex'; -import LibP2pRailing from 'libp2p-railing'; -import LibP2pSecio from 'libp2p-secio'; -import LibP2pSpdy from 'libp2p-spdy'; -import PeerBook from 'peer-book'; -import PeerInfo from 'peer-info'; +import Connection = require('interface-connection'); +import Transport = require('interface-transport'); +import Libp2pKadDHT = require('libp2p-kad-dht'); +import LibP2pMdns = require('libp2p-mdns'); +import LibP2pMplex = require('libp2p-mplex'); +import LibP2pRailing = require('libp2p-railing'); +import LibP2pSecio = require('libp2p-secio'); +import LibP2pSpdy = require('libp2p-spdy'); +import PeerBook = require('peer-book'); +import PeerInfo = require('peer-info'); type CreateOptions = { DHT: typeof Libp2pKadDHT, @@ -38,4 +38,4 @@ declare class LibP2p { stop (cb: (error: Error | null) => any): void; } -export default LibP2p; +export = LibP2p; diff --git a/multiaddr/index.d.ts b/multiaddr/index.d.ts index e6ba047..b9b9116 100644 --- a/multiaddr/index.d.ts +++ b/multiaddr/index.d.ts @@ -5,7 +5,7 @@ /// -import PeerId from 'peer-id'; +import PeerId = require('peer-id'); type Address = { family: string, @@ -50,4 +50,4 @@ declare class MultiAddr { toString (): string; } -export default MultiAddr; +export = MultiAddr; diff --git a/peer-book/index.d.ts b/peer-book/index.d.ts index 938a9f1..30ab90d 100644 --- a/peer-book/index.d.ts +++ b/peer-book/index.d.ts @@ -3,8 +3,8 @@ // Definitions by: Jaco Greeff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import PeerId from 'peer-id'; -import PeerInfo from 'peer-info'; +import PeerId = require('peer-id'); +import PeerInfo = require('peer-info'); declare class PeerBook { constructor (); @@ -18,4 +18,4 @@ declare class PeerBook { remove (peerInfo: PeerInfo, replace?: boolean): void; } -export default PeerBook; +export = PeerBook; diff --git a/peer-id/index.d.ts b/peer-id/index.d.ts index 4e26402..60ab1ef 100644 --- a/peer-id/index.d.ts +++ b/peer-id/index.d.ts @@ -35,4 +35,4 @@ declare class PeerId { toJSON (): JSON; } -export default PeerId; +export = PeerId; diff --git a/peer-info/index.d.ts b/peer-info/index.d.ts index b276c7f..9c0f8b9 100644 --- a/peer-info/index.d.ts +++ b/peer-info/index.d.ts @@ -5,8 +5,8 @@ /// -import MultiAddr from 'multiaddr'; -import PeerId from 'peer-id'; +import MultiAddr = require('multiaddr'); +import PeerId = require('peer-id'); type CreateCb = (error: Error | null, peerId?: PeerId) => any; @@ -45,4 +45,4 @@ declare class PeerInfo { isConnected (): boolean; } -export default PeerInfo; +export = PeerInfo; diff --git a/pull-pushable/index.d.ts b/pull-pushable/index.d.ts new file mode 100644 index 0000000..9097132 --- /dev/null +++ b/pull-pushable/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for pull-pushable 2.0.0 +// Project: https://github.com/pull-stream/pull-pushable +// Definitions by: Jaco Greeff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +type Pushable = { + push: (buffer: Buffer) => void +}; + +declare type PullPushable = () => Pushable; + +export = PullPushable; diff --git a/pull-pushable/pull-pushable-tests.ts b/pull-pushable/pull-pushable-tests.ts new file mode 100644 index 0000000..e69de29 diff --git a/pull-pushable/tsconfig.json b/pull-pushable/tsconfig.json new file mode 100644 index 0000000..932e246 --- /dev/null +++ b/pull-pushable/tsconfig.json @@ -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"] +} diff --git a/pull-pushable/tslint.json b/pull-pushable/tslint.json new file mode 100644 index 0000000..3db14f8 --- /dev/null +++ b/pull-pushable/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/pull-stream/index.d.ts b/pull-stream/index.d.ts new file mode 100644 index 0000000..a464237 --- /dev/null +++ b/pull-stream/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for pull-stream 3.6.8 +// Project: https://github.com/pull-stream/pull-stream +// Definitions by: Jaco Greeff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +type Pull = { + (source: any, sink: any): void; + + collect: (cb: (error: Error | null, values: Array) => any) => void, + drain: (handler: (message: Buffer) => void, errorHandler?: () => boolean) => void; + values: (values: Array) => void; +}; + +export = Pull; diff --git a/pull-stream/pull-stream-tests.ts b/pull-stream/pull-stream-tests.ts new file mode 100644 index 0000000..e69de29 diff --git a/pull-stream/tsconfig.json b/pull-stream/tsconfig.json new file mode 100644 index 0000000..932e246 --- /dev/null +++ b/pull-stream/tsconfig.json @@ -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"] +} diff --git a/pull-stream/tslint.json b/pull-stream/tslint.json new file mode 100644 index 0000000..3db14f8 --- /dev/null +++ b/pull-stream/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }