Skip to content

Commit 97040c3

Browse files
committed
Added small change to simplify logic of createConnection
1 parent 22c2812 commit 97040c3

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

mysql-libmysqlclient.js

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,10 @@ Copyright (C) 2010, Oleg Efimov <efimovov@gmail.com>
44
See license text in LICENSE file
55
*/
66

7-
var
8-
binding = require("./mysql_bindings"),
9-
sys = require("sys");
7+
var binding = require("./mysql_bindings");
108

11-
function createConnection(servername, user, password, dbname, port, socket)
12-
{
9+
exports.createConnection = function () {
1310
var db = new binding.MysqlConn();
14-
15-
if (typeof socket !== "undefined") {
16-
db.connect(servername, user, password, dbname, port, socket);
17-
} else {
18-
if (typeof port !== "undefined") {
19-
db.connect(servername, user, password, dbname, port);
20-
} else {
21-
if (typeof dbname !== "undefined") {
22-
db.connect(servername, user, password, dbname);
23-
} else {
24-
if (typeof password !== "undefined") {
25-
db.connect(servername, user, password);
26-
} else {
27-
if (typeof user !== "undefined") {
28-
db.connect(servername, user);
29-
} else {
30-
if (typeof servername !== "undefined") {
31-
db.connect(servername);
32-
}
33-
}
34-
}
35-
}
36-
}
37-
}
38-
11+
db.connect.apply(this, Array.prototype.slice.call(arguments, 0, 5));
3912
return db;
40-
}
41-
42-
exports.createConnection = createConnection;
43-
13+
};

0 commit comments

Comments
 (0)