Socket
Socket
Sign inDemoInstall

ssb-conn-db

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssb-conn-db - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

.github/workflows/node.js.yml

1

lib/index.d.ts

@@ -14,2 +14,3 @@ import { AddressData, Opts } from './types';

constructor(opts: Partial<Opts>);
private _fileExists;
private _init;

@@ -16,0 +17,0 @@ private _load;

86

lib/index.js

@@ -75,44 +75,60 @@ "use strict";

}
ConnDB.prototype._fileExists = function (path, cb) {
if (typeof localStorage === 'undefined' || localStorage === null) {
cb(fs.existsSync(path));
}
else {
var file = AtomicFile(path);
file.get(function (err) {
if (err)
cb(false);
else
cb(true);
});
}
};
ConnDB.prototype._init = function (modernPath, legacyPath) {
var _this = this;
var modernExists = fs.existsSync(modernPath);
var legacyExists = fs.existsSync(legacyPath);
if (!modernExists && !legacyExists) {
this._stateFile.set({}, function () { });
this._loadedResolve(true);
debug('Created new conn.json because there was no existing ' +
'conn.json nor gossip.json');
return;
}
if (!modernExists && legacyExists) {
var legacyStateFile = AtomicFile(legacyPath);
legacyStateFile.get(function (err, oldVals) {
if (err) {
_this._loadedReject(err);
debug('Failed to load gossip.json, for creating conn.json');
this._fileExists(modernPath, function (modernExists) {
_this._fileExists(legacyPath, function (legacyExists) {
if (!modernExists && !legacyExists) {
_this._stateFile.set({}, function () { });
_this._loadedResolve(true);
debug('Created new conn.json because there was no existing ' +
'conn.json nor gossip.json');
return;
}
var newVals = migration_1.migrateMany(oldVals);
return _this._stateFile.set(newVals, function (err2) {
if (err2) {
_this._loadedReject(err2);
debug('Failed to create conn.json from an existing gossip.json');
return;
}
debug('Migrated gossip.json into conn.json');
_this._load(newVals);
});
});
return;
}
if (modernExists) {
this._stateFile.get(function (err, vals) {
if (err) {
_this._loadedReject(err);
debug('Failed to load conn.json');
if (!modernExists && legacyExists) {
var legacyStateFile = AtomicFile(legacyPath);
legacyStateFile.get(function (err, oldVals) {
if (err) {
_this._loadedReject(err);
debug('Failed to load gossip.json, for creating conn.json');
return;
}
var newVals = migration_1.migrateMany(oldVals);
return _this._stateFile.set(newVals, function (err2) {
if (err2) {
_this._loadedReject(err2);
debug('Failed to create conn.json from an existing gossip.json');
return;
}
debug('Migrated gossip.json into conn.json');
_this._load(newVals);
});
});
return;
}
_this._load(vals);
if (modernExists) {
_this._stateFile.get(function (err, vals) {
if (err) {
_this._loadedReject(err);
debug('Failed to load conn.json');
return;
}
_this._load(vals);
});
}
});
}
});
};

@@ -119,0 +135,0 @@ ConnDB.prototype._load = function (vals) {

{
"name": "ssb-conn-db",
"description": "Module that manages a local registry of connectable peers",
"version": "0.3.2",
"homepage": "https://github.com/staltz/ssb-conn-db",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/staltz/ssb-conn-db.git"
},
"dependencies": {
"atomic-file": "^1.1.5",
"debug": "~4.1.1",
"multiserver-address": "~1.0.1",
"pull-notify": "~0.1.1",
"ssb-ref": "~2.13.9"
},
"devDependencies": {
"@types/node": "^11.10.4",
"pull-stream": "^3.6.9",
"tape": "^4.9.2",
"typescript": "3.8.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-db",
"description": "Module that manages a local registry of connectable peers",
"version": "0.3.3",
"homepage": "https://github.com/staltz/ssb-conn-db",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "git://github.com/staltz/ssb-conn-db.git"
},
"dependencies": {
"atomic-file": "^2.1.1",
"debug": "~4.1.1",
"multiserver-address": "~1.0.1",
"pull-notify": "~0.1.1",
"ssb-ref": "~2.13.9"
},
"devDependencies": {
"@types/node": "^11.10.4",
"pull-stream": "^3.6.9",
"tape": "^4.9.2",
"typescript": "3.8.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"
}

@@ -52,48 +52,64 @@ import * as fs from 'fs';

private _init(modernPath: string, legacyPath: string) {
const modernExists = fs.existsSync(modernPath);
const legacyExists = fs.existsSync(legacyPath);
if (!modernExists && !legacyExists) {
this._stateFile!.set({}, () => {});
this._loadedResolve(true);
debug(
'Created new conn.json because there was no existing ' +
'conn.json nor gossip.json',
);
return;
private _fileExists(path: string, cb: (exists: boolean) => void) {
if (typeof localStorage === 'undefined' || localStorage === null) {
cb(fs.existsSync(path));
} else {
// in browser
const file = AtomicFile(path);
file.get((err: unknown) => {
if (err) cb(false);
else cb(true);
});
}
}
if (!modernExists && legacyExists) {
const legacyStateFile = AtomicFile(legacyPath);
legacyStateFile.get((err: unknown, oldVals: any) => {
if (err) {
this._loadedReject(err);
debug('Failed to load gossip.json, for creating conn.json');
private _init(modernPath: string, legacyPath: string) {
this._fileExists(modernPath, (modernExists: boolean) => {
this._fileExists(legacyPath, (legacyExists: boolean) => {
if (!modernExists && !legacyExists) {
this._stateFile!.set({}, () => {});
this._loadedResolve(true);
debug(
'Created new conn.json because there was no existing ' +
'conn.json nor gossip.json',
);
return;
}
const newVals = migrateMany(oldVals);
return this._stateFile!.set(newVals, (err2: any) => {
if (err2) {
this._loadedReject(err2);
debug('Failed to create conn.json from an existing gossip.json');
return;
}
debug('Migrated gossip.json into conn.json');
this._load(newVals);
});
});
return;
}
if (modernExists) {
this._stateFile!.get((err: unknown, vals: any) => {
if (err) {
this._loadedReject(err);
debug('Failed to load conn.json');
if (!modernExists && legacyExists) {
const legacyStateFile = AtomicFile(legacyPath);
legacyStateFile.get((err: unknown, oldVals: any) => {
if (err) {
this._loadedReject(err);
debug('Failed to load gossip.json, for creating conn.json');
return;
}
const newVals = migrateMany(oldVals);
return this._stateFile!.set(newVals, (err2: any) => {
if (err2) {
this._loadedReject(err2);
debug(
'Failed to create conn.json from an existing gossip.json',
);
return;
}
debug('Migrated gossip.json into conn.json');
this._load(newVals);
});
});
return;
}
this._load(vals);
if (modernExists) {
this._stateFile!.get((err: unknown, vals: any) => {
if (err) {
this._loadedReject(err);
debug('Failed to load conn.json');
return;
}
this._load(vals);
});
}
});
}
});
}

@@ -100,0 +116,0 @@

@@ -5,3 +5,3 @@ {

"module": "commonjs",
"lib": ["es5", "es2015", "es2016", "es2017"],
"lib": ["es5", "es2015", "es2016", "es2017", "dom"],
"skipLibCheck": true,

@@ -8,0 +8,0 @@ "declaration": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc