ssb-conn
Advanced tools
Comparing version 0.8.4 to 0.8.5
@@ -23,3 +23,3 @@ import ConnDB = require('ssb-conn-db'); | ||
dbPeers: () => Iterable<[string, AddressData]>; | ||
connect: (address: string, second: Record<string, any> | Callback<any> | null | undefined, third?: Callback<any> | undefined) => void; | ||
connect: (address: string, b?: Record<string, any> | Callback<any> | null | undefined, c?: Callback<any> | undefined) => void; | ||
disconnect: (address: string, cb?: Callback<any> | undefined) => void; | ||
@@ -26,0 +26,0 @@ peers: () => any; |
@@ -33,8 +33,9 @@ "use strict"; | ||
this.dbPeers = () => this.db.entries(); | ||
this.connect = (address, second, third) => { | ||
if (typeof second === 'function' && typeof third === 'function') { | ||
this.connect = (address, b, c) => { | ||
if (c && (typeof b === 'function' || !b)) { | ||
throw new Error('CONN.connect() received incorrect arguments'); | ||
} | ||
const cb = (typeof third === 'function' ? third : second); | ||
const data = (typeof third === 'function' ? second : undefined); | ||
const last = !!c ? c : b; | ||
const cb = (typeof last === 'function' ? last : null); | ||
const data = (typeof b === 'object' ? b : {}); | ||
this.hub | ||
@@ -41,0 +42,0 @@ .connect(address, data) |
{ | ||
"name": "ssb-conn", | ||
"description": "SSB plugin for establishing and managing peer connections", | ||
"version": "0.8.4", | ||
"version": "0.8.5", | ||
"homepage": "https://github.com/staltz/ssb-conn", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -105,10 +105,11 @@ import ConnDB = require('ssb-conn-db'); | ||
address: string, | ||
second: Record<string, any> | null | undefined | Callback<any>, | ||
third?: Callback<any>, | ||
b?: Record<string, any> | null | undefined | Callback<any>, | ||
c?: Callback<any>, | ||
) => { | ||
if (typeof second === 'function' && typeof third === 'function') { | ||
if (c && (typeof b === 'function' || !b)) { | ||
throw new Error('CONN.connect() received incorrect arguments'); | ||
} | ||
const cb = (typeof third === 'function' ? third : second) as Callback<any>; | ||
const data = (typeof third === 'function' ? second : undefined) as any; | ||
const last = !!c ? c : b; | ||
const cb = (typeof last === 'function' ? last : null) as Callback<any>; | ||
const data = (typeof b === 'object' ? b : {}) as any; | ||
@@ -115,0 +116,0 @@ this.hub |
2260
127323