-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
small javascript code cleanup #138
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -588,39 +588,42 @@ SQLitePluginTransaction.prototype.run = function() { | |
} | ||
}; | ||
}; | ||
|
||
i = 0; | ||
mycbmap = {}; | ||
mycbmap = []; | ||
while (i < batchExecutes.length) { | ||
request = batchExecutes[i]; | ||
mycbmap[i] = { | ||
mycbmap.push({ | ||
success: handlerFor(i, true), | ||
error: handlerFor(i, false) | ||
}; | ||
}); | ||
tropts.push({ | ||
qid: 1111, | ||
sql: request.sql, | ||
params: request.params | ||
}); | ||
i++; | ||
} | ||
|
||
let mysuccess = function(result) { | ||
var j, last, q, r, ref, res, type; | ||
var j, last, q, r, res, type; | ||
if (result.length == 0){ | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I don't understand the reason behind such complexity. for (i = j = 0, ref = last; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { the ref could be == -1 only in case the map is empty. In all other cases, the ref is >= 0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the reason for this is that it is translated from a coffee script. I keep it in sync with Cordova plugin. |
||
last = result.length - 1; | ||
for (i = j = 0, ref = last; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { | ||
r = result[i]; | ||
for (j = 0; j <= last; ++j) { | ||
r = result[j]; | ||
type = r.type; | ||
res = r.result; | ||
q = mycbmap[i]; | ||
q = mycbmap[j]; | ||
if (q) { | ||
if (q[type]) { | ||
q[type](res); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
var myerror = function(error) { | ||
console.log("batch execution error: ",error); | ||
}; | ||
|
@@ -630,7 +633,7 @@ SQLitePluginTransaction.prototype.run = function() { | |
dbname: this.db.dbname | ||
}, | ||
executes: tropts | ||
},mysuccess, myerror); | ||
}, mysuccess, myerror); | ||
}; | ||
|
||
SQLitePluginTransaction.prototype.abort = function(txFailure) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why do we need to have an array here