Skip to content

Commit 4b22adf

Browse files
dryganetsandpor
authored andcommitted
small javascript code cleanup (#138)
* small javascript code cleanup * formatting fixes. mycbmap renamed to callbacks.
1 parent dc0a8eb commit 4b22adf

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/sqlite.core.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ SQLitePluginTransaction.prototype.handleStatementFailure = function(handler, res
550550
};
551551

552552
SQLitePluginTransaction.prototype.run = function() {
553-
var batchExecutes, handlerFor, i, mycbmap, request, tropts, tx, txFailure, waiting;
553+
var batchExecutes, handlerFor, i, callbacks, request, tropts, tx, txFailure, waiting;
554554
txFailure = null;
555555
tropts = [];
556556
batchExecutes = this.executes;
@@ -588,39 +588,42 @@ SQLitePluginTransaction.prototype.run = function() {
588588
}
589589
};
590590
};
591+
591592
i = 0;
592-
mycbmap = {};
593+
callbacks = [];
593594
while (i < batchExecutes.length) {
594595
request = batchExecutes[i];
595-
mycbmap[i] = {
596+
callbacks.push({
596597
success: handlerFor(i, true),
597598
error: handlerFor(i, false)
598-
};
599+
});
599600
tropts.push({
600601
qid: 1111,
601602
sql: request.sql,
602603
params: request.params
603604
});
604605
i++;
605606
}
607+
606608
let mysuccess = function(result) {
607-
var j, last, q, r, ref, res, type;
609+
var j, last, q, r, res, type;
608610
if (result.length == 0){
609611
return;
610612
}
611613
last = result.length - 1;
612-
for (i = j = 0, ref = last; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
613-
r = result[i];
614+
for (j = 0; j <= last; ++j) {
615+
r = result[j];
614616
type = r.type;
615617
res = r.result;
616-
q = mycbmap[i];
618+
q = callbacks[j];
617619
if (q) {
618620
if (q[type]) {
619621
q[type](res);
620622
}
621623
}
622624
}
623625
};
626+
624627
var myerror = function(error) {
625628
console.log("batch execution error: ",error);
626629
};
@@ -630,7 +633,7 @@ SQLitePluginTransaction.prototype.run = function() {
630633
dbname: this.db.dbname
631634
},
632635
executes: tropts
633-
},mysuccess, myerror);
636+
}, mysuccess, myerror);
634637
};
635638

636639
SQLitePluginTransaction.prototype.abort = function(txFailure) {

0 commit comments

Comments
 (0)