Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

any-db

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-db - npm Package Compare versions

Comparing version 1.0.0-alpha2 to 1.0.0-rc1

5

CONTRIBUTING.md

@@ -35,6 +35,7 @@ # Contributing to Any-DB development

I'm not terribly picky about code-formatting, but please try to avoid mixing
tabs and spaces, and keep lines under 80 characters long if you can help it.
I'm not terribly picky about code-formatting, but please try to match the style
of the code around your change. In particular, use two-space tabs, and keep
lines under 80 characters long if you can help it.
If a patch you're working on is getting hairy, don't be afraid to refactor
existing code.

@@ -30,2 +30,14 @@ var ConnectionPool = require('any-db-pool')

var adapterConfig = parseDbUrl(dbUrl);
if (adapterConfig.adapter === 'sqlite3' && /:memory:$/i.test(adapterConfig.database)) {
if (poolConfig.min > 1 || poolConfig.max > 1) {
console.warn(
"Pools of more than 1 connection do not work for in-memory SQLite3 databases\n" +
"The specified minimum (%d) and maximum (%d) connections have been overridden"
)
}
if (poolConfig.min) poolConfig.min = 1;
poolConfig.max = 1;
}
var adapter = getAdapter(adapterConfig.adapter);

@@ -32,0 +44,0 @@

28

lib/parse-url.js

@@ -7,8 +7,8 @@ var url = require('url');

}
var parsed = url.parse(dbUrl, true)
if (parsed.auth) {
var auth = parsed.auth.split(':')
parsed.user = auth[0];
parsed.password = auth[1];
}
var parsed = url.parse(dbUrl, true)
if (parsed.auth) {
var auth = parsed.auth.split(':')
parsed.user = auth[0];
parsed.password = auth[1];
}
var adapter = parsed.protocol.replace(':', '')

@@ -22,10 +22,10 @@ var database = parsed.pathname;

var config = {
adapter: adapter,
host: parsed.hostname,
port: parsed.port,
database: database,
user: parsed.user,
password: parsed.password
}
var config = {
adapter: adapter,
host: parsed.hostname,
port: parsed.port,
database: database,
user: parsed.user,
password: parsed.password
}

@@ -32,0 +32,0 @@ for (var k in parsed.query) config[k] = parsed.query[k]

@@ -10,59 +10,59 @@ var EventEmitter = require('events').EventEmitter

function StateMachine (initialState, methods, transitions, onError) {
EventEmitter.call(this)
EventEmitter.call(this)
var currentState = initialState;
var currentState = initialState;
var self = this;
var self = this;
this.state = function (to) {
if (!to) return currentState;
this.state = function (to) {
if (!to) return currentState;
if (to === currentState) return true;
if (to === currentState) return true;
var extra = Array.prototype.slice.call(arguments, 1)
, legal = transitions[currentState]
var extra = Array.prototype.slice.call(arguments, 1)
, legal = transitions[currentState]
if (to === 'errored' || legal && legal.indexOf(to) > -1) {
if (this.log) {
this.log("Transition from:'" + currentState + "' to:'" + to + "'");
}
removeMethods();
currentState = to;
assignMethods();
this.emit(currentState)
return true
} else {
extra.unshift(new IllegalTransitionError(currentState, to))
onError.apply(this, extra)
return false
}
}
if (to === 'errored' || legal && legal.indexOf(to) > -1) {
if (this.log) {
this.log("Transition from:'" + currentState + "' to:'" + to + "'");
}
removeMethods();
currentState = to;
assignMethods();
this.emit(currentState)
return true
} else {
extra.unshift(new IllegalTransitionError(currentState, to))
onError.apply(this, extra)
return false
}
}
function assignMethods () {
for (var methodName in methods) {
if (currentState in methods[methodName]) {
self[methodName] = methods[methodName][currentState]
}
}
}
function assignMethods () {
for (var methodName in methods) {
if (currentState in methods[methodName]) {
self[methodName] = methods[methodName][currentState]
}
}
}
function removeMethods () {
for (var methodName in methods) {
if (currentState in methods[methodName]) {
self[methodName] = methods[methodName][null] || nullImpl(methodName);
}
}
}
function removeMethods () {
for (var methodName in methods) {
if (currentState in methods[methodName]) {
self[methodName] = methods[methodName][null] || nullImpl(methodName);
}
}
}
function nullImpl (methodName) {
return function () {
var lastArg = [].slice.call(arguments).pop();
var error = new UndefinedMethodError(methodName, currentState)
if (typeof lastArg == 'function') {
lastArg(error);
} else {
this.emit('error', error);
}
}
}
function nullImpl (methodName) {
return function () {
var lastArg = [].slice.call(arguments).pop();
var error = new UndefinedMethodError(methodName, currentState)
if (typeof lastArg == 'function') {
lastArg(error);
} else {
this.emit('error', error);
}
}
}
}

@@ -72,5 +72,5 @@

function UndefinedMethodError(method, state) {
Error.captureStackTrace(this, UndefinedMethodError);
this.name = 'Undefined Method';
this.message = "method '" + method + "' unavailable in state '" + state + "'";
Error.captureStackTrace(this, UndefinedMethodError);
this.name = 'Undefined Method';
this.message = "method '" + method + "' unavailable in state '" + state + "'";
}

@@ -80,5 +80,5 @@

function IllegalTransitionError(from, to) {
Error.captureStackTrace(this, IllegalTransitionError);
this.name = 'Illegal Transition';
this.message = "Transition from '" + from + "' to '" + to + "' not allowed";
Error.captureStackTrace(this, IllegalTransitionError);
this.name = 'Illegal Transition';
this.message = "Transition from '" + from + "' to '" + to + "' not allowed";
}
{
"name": "any-db",
"version": "1.0.0-alpha2",
"version": "1.0.0-rc1",
"description": "Database-agnostic connection pooling, querying, and result sets",

@@ -5,0 +5,0 @@ "main": "index.js",

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