ssb-conn-staging
Advanced tools
Comparing version 0.0.8 to 0.1.0
@@ -13,2 +13,3 @@ import { Address, StagedData } from './types'; | ||
unstage(address: Address): boolean; | ||
get(address: Address): StagedData | undefined; | ||
entries(): IterableIterator<[string, Readonly<{ | ||
@@ -15,0 +16,0 @@ [misc: string]: any; |
@@ -67,2 +67,7 @@ "use strict"; | ||
}; | ||
ConnStaging.prototype.get = function (address) { | ||
this._assertNotClosed(); | ||
this._assertValidAddress(address); | ||
return this._peers.get(address); | ||
}; | ||
ConnStaging.prototype.entries = function () { | ||
@@ -69,0 +74,0 @@ this._assertNotClosed(); |
{ | ||
"name": "ssb-conn-staging", | ||
"description": "Module that manages potential and optional SSB peer connections", | ||
"version": "0.0.8", | ||
"homepage": "https://github.com/staltz/ssb-conn-staging", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/staltz/ssb-conn-staging.git" | ||
}, | ||
"dependencies": { | ||
"multiserver-address": "~1.0.1", | ||
"debug": "^4.1.1", | ||
"pull-cat": "~1.1.11", | ||
"pull-notify": "~0.1.1", | ||
"pull-stream": "^3.6.9" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^11.10.4", | ||
"tape": "^4.9.2", | ||
"typescript": "3.3.x" | ||
}, | ||
"scripts": { | ||
"typescript": "tsc", | ||
"tape": "set -e; for t in test/*.js; do node $t; done", | ||
"test": "npm run typescript && npm run tape" | ||
}, | ||
"author": "Andre Staltz <contact@staltz.com> (http://staltz.com)", | ||
"license": "MIT" | ||
} | ||
"name": "ssb-conn-staging", | ||
"description": "Module that manages potential and optional SSB peer connections", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/staltz/ssb-conn-staging", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/staltz/ssb-conn-staging.git" | ||
}, | ||
"dependencies": { | ||
"multiserver-address": "~1.0.1", | ||
"debug": "^4.1.1", | ||
"pull-cat": "~1.1.11", | ||
"pull-notify": "~0.1.1", | ||
"pull-stream": "^3.6.9" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^11.10.4", | ||
"tape": "^4.9.2", | ||
"typescript": "3.3.x" | ||
}, | ||
"scripts": { | ||
"typescript": "tsc", | ||
"tape": "set -e; for t in test/*.js; do node $t; done", | ||
"test": "npm run typescript && npm run tape" | ||
}, | ||
"author": "Andre Staltz <contact@staltz.com> (http://staltz.com)", | ||
"license": "MIT" | ||
} |
@@ -37,2 +37,3 @@ # ssb-conn-staging | ||
* `connStaging.unstage(address)`: remove the potential peer from the staging database, by its `address` (string, must conform to the multiserver address convention). Returns a boolean indicating whether unstage() succeeded or not (it fails if the entry we are trying to unstage was not staged in the first place) | ||
* `connStaging.get(address)`: returns the staged data for an existing peer with the given `address`, or `undefined` if the address was not staged | ||
* `connStaging.entries()`: returns a new `Iterator` object that gives `[address, data]` pairs of the peers currently in staging | ||
@@ -39,0 +40,0 @@ * `connStaging.liveEntries()`: returns a pull-stream that emits an array of entries (like `connStaging.entries()`, but an array instead of an `Iterator`) everytime there are updates to the staging. |
@@ -79,2 +79,9 @@ const pull = require('pull-stream'); | ||
public get(address: Address): StagedData | undefined { | ||
this._assertNotClosed(); | ||
this._assertValidAddress(address); | ||
return this._peers.get(address); | ||
} | ||
public entries() { | ||
@@ -81,0 +88,0 @@ this._assertNotClosed(); |
@@ -29,2 +29,16 @@ const tape = require('tape'); | ||
tape('stage(), get()', t => { | ||
const connStaging = new ConnStaging(); | ||
const address = TEST_ADDR; | ||
const result1 = connStaging.stage(address, {mode: 'internet', address}); | ||
t.equals(result1, true, 'stage() succeeds'); | ||
const result2 = connStaging.get(address); | ||
t.ok(result2, 'there is a result from get()'); | ||
t.equals(result2.mode, 'internet'); | ||
t.end(); | ||
}); | ||
tape('liveEntries() emits all entries as they update', t => { | ||
@@ -31,0 +45,0 @@ const connStaging = new ConnStaging(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119749
391
47