Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

push up openDbs check and fix actionQueue slice arguments, tests fail

  • Loading branch information...
commit 7b2e1257eb9969ffdd2d97e2df0ca01043f66666 1 parent e794ce7
James Halliday substack authored
Showing with 19 additions and 19 deletions.
  1. +19 −19 lib/store.js
38 lib/store.js
View
@@ -29,7 +29,13 @@ function Store(opts, cb) {
opts.filename = normalize(opts.filename);
}
-
+
+ if (openDbs[opts.filename]) {
+ var db = openDbs[opts.filename];
+ cb(undefined, db);
+ return;
+ }
+
opts.json = opts.json || false;
self.on('ready', function () {
@@ -40,23 +46,17 @@ function Store(opts, cb) {
delete actionQueue;
});
- if (openDbs[opts.filename]) {
- var db = openDbs[opts.filename];
- cb(undefined, db);
- }
- else {
- var db = new SQLite();
- db.open(opts.filename, function (error) {
- if (error) {
- self.emit('error', error);
- delete openDbs[opts.filename];
- cb(error);
- }
- initStoreTable();
- });
- openDbs[opts.filename] = self;
- }
-
+ var db = new SQLite();
+ db.open(opts.filename, function (error) {
+ if (error) {
+ self.emit('error', error);
+ delete openDbs[opts.filename];
+ cb(error);
+ }
+ initStoreTable();
+ });
+ openDbs[opts.filename] = self;
+
function initStoreTable() {
var hadRow = false;
db.query(
@@ -95,7 +95,7 @@ function Store(opts, cb) {
}
function queue(action, args) {
- actionQueue.push({ action : action, args : [].slice.call([], args) });
+ actionQueue.push({ action : action, args : [].slice.call(args) });
}
self.set = function (key, value, cb) {
Please sign in to comment.
Something went wrong with that request. Please try again.