Skip to content

Commit c58414c

Browse files
committed
Remove unneeded functions
1 parent 8e64a07 commit c58414c

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

src/api.js

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
173173
["number"]
174174
);
175175

176-
177-
function isNullOrUndefined(val) {
178-
return val === null || val === undefined;
179-
}
180-
function throwError(err) {
181-
throw err;
182-
}
183-
184-
/* Represents a prepared statement.
176+
/** Represents a prepared statement.
185177
186178
Prepared statements allow you to have a template sql string,
187179
that you can execute multiple times with different parameters.
@@ -194,11 +186,9 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
194186
195187
@see Database.html#prepare-dynamic
196188
@see https://en.wikipedia.org/wiki/Prepared_statement
197-
*/
198-
/*
189+
199190
Statements can't be created by the API user, only by Database::prepare
200191
@private
201-
@nodoc
202192
*/
203193
function Statement(stmt1, db) {
204194
this.stmt = stmt1;
@@ -288,15 +278,15 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
288278
that has been executed
289279
*/
290280
Statement.prototype.getNumber = function getNumber(pos) {
291-
if (isNullOrUndefined(pos)) {
281+
if (pos == null) {
292282
pos = this.pos;
293283
this.pos += 1;
294284
}
295285
return sqlite3_column_double(this.stmt, pos);
296286
};
297287

298288
Statement.prototype.getString = function getString(pos) {
299-
if (isNullOrUndefined(pos)) {
289+
if (pos == null) {
300290
pos = this.pos;
301291
this.pos += 1;
302292
}
@@ -308,7 +298,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
308298
var ptr;
309299
var result;
310300
var size;
311-
if (isNullOrUndefined(pos)) {
301+
if (pos == null) {
312302
pos = this.pos;
313303
this.pos += 1;
314304
}
@@ -338,7 +328,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
338328
var field;
339329
var ref;
340330
var results1;
341-
if (!isNullOrUndefined(params) && this["bind"](params)) {
331+
if (params != null && this["bind"](params)) {
342332
this["step"]();
343333
}
344334
results1 = [];
@@ -431,7 +421,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
431421
@param [Array,Object] Value to bind to the statement
432422
*/
433423
Statement.prototype["run"] = function run(values) {
434-
if (!isNullOrUndefined(values)) {
424+
if (values != null) {
435425
this["bind"](values);
436426
}
437427
this["step"]();
@@ -441,7 +431,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
441431
Statement.prototype.bindString = function bindString(string, pos) {
442432
var bytes;
443433
var strptr;
444-
if (isNullOrUndefined(pos)) {
434+
if (pos == null) {
445435
pos = this.pos;
446436
this.pos += 1;
447437
}
@@ -460,7 +450,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
460450

461451
Statement.prototype.bindBlob = function bindBlob(array, pos) {
462452
var blobptr;
463-
if (isNullOrUndefined(pos)) {
453+
if (pos == null) {
464454
pos = this.pos;
465455
this.pos += 1;
466456
}
@@ -478,7 +468,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
478468

479469
Statement.prototype.bindNumber = function bindNumber(num, pos) {
480470
var bindfunc;
481-
if (isNullOrUndefined(pos)) {
471+
if (pos == null) {
482472
pos = this.pos;
483473
this.pos += 1;
484474
}
@@ -492,15 +482,15 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
492482
};
493483

494484
Statement.prototype.bindNull = function bindNull(pos) {
495-
if (isNullOrUndefined(pos)) {
485+
if (pos == null) {
496486
pos = this.pos;
497487
this.pos += 1;
498488
}
499489
return sqlite3_bind_blob(this.stmt, pos, 0, 0, 0) === SQLITE_OK;
500490
};
501491

502492
Statement.prototype.bindValue = function bindValue(val, pos) {
503-
if (isNullOrUndefined(pos)) {
493+
if (pos == null) {
504494
pos = this.pos;
505495
this.pos += 1;
506496
}
@@ -514,7 +504,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
514504
if (val === null) {
515505
return this.bindNull(pos);
516506
}
517-
if (!isNullOrUndefined(val.length)) {
507+
if (val.length != null) {
518508
return this.bindBlob(val, pos);
519509
}
520510
break;
@@ -602,7 +592,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
602592
*/
603593
function Database(data) {
604594
this.filename = "dbfile_" + (0xffffffff * Math.random() >>> 0);
605-
if (!isNullOrUndefined(data)) {
595+
if (data != null) {
606596
FS.createDataFile("/", this.filename, data, true, true);
607597
}
608598
this.handleError(sqlite3_open(this.filename, apiTemp));
@@ -641,8 +631,6 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
641631
stmt = this["prepare"](sql, params);
642632
try {
643633
stmt["step"]();
644-
} catch (errCaught) {
645-
throwError(errCaught);
646634
} finally {
647635
stmt["free"]();
648636
}
@@ -805,7 +793,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
805793
throw "Nothing to prepare";
806794
}
807795
stmt = new Statement(pStmt, this);
808-
if (!isNullOrUndefined(params)) {
796+
if (params != null) {
809797
stmt.bind(params);
810798
}
811799
this.statements[pStmt] = stmt;
@@ -960,7 +948,7 @@ Module["onRuntimeInitialized"] = (function onRuntimeInitialized() {
960948
case "object":
961949
if (result === null) {
962950
sqlite3_result_null(cx);
963-
} else if (!isNullOrUndefined(result.length)) {
951+
} else if (result.length != null) {
964952
blobptr = allocate(result, "i8", ALLOC_NORMAL);
965953
sqlite3_result_blob(cx, blobptr, result.length, -1);
966954
_free(blobptr);

0 commit comments

Comments
 (0)