Skip to content

Commit d8258a1

Browse files
lneves12lneves
authored andcommitted
This makes mysqljs easier to minify and support minifier mangle
1 parent 283425b commit d8258a1

32 files changed

+70
-6
lines changed

lib/protocol/Protocol.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Protocol.prototype._enqueue = function(sequence) {
157157
self._emitPacket(packet);
158158
})
159159
.on('timeout', function() {
160-
var err = new Error(sequence.constructor.name + ' inactivity timeout');
160+
var err = new Error(sequence._id + ' inactivity timeout');
161161

162162
err.code = 'PROTOCOL_SEQUENCE_TIMEOUT';
163163
err.fatal = true;
@@ -206,7 +206,7 @@ Protocol.prototype._enqueue = function(sequence) {
206206

207207
Protocol.prototype._validateEnqueue = function _validateEnqueue(sequence) {
208208
var err;
209-
var prefix = 'Cannot enqueue ' + sequence.constructor.name;
209+
var prefix = 'Cannot enqueue ' + sequence._id;
210210

211211
if (this._fatalError) {
212212
err = new Error(prefix + ' after fatal error.');
@@ -253,7 +253,7 @@ Protocol.prototype._parsePacket = function() {
253253

254254
var Packet = this._determinePacket(sequence);
255255
var packet = new Packet({protocol41: this._config.protocol41});
256-
var packetName = Packet.name;
256+
var packetName = packet._id;
257257

258258
// Special case: Faster dispatch, and parsing done inside sequence
259259
if (Packet === Packets.RowDataPacket) {
@@ -447,7 +447,7 @@ Protocol.prototype._debugPacket = function(incoming, packet) {
447447
var direction = incoming
448448
? '<--'
449449
: '-->';
450-
var packetName = packet.constructor.name;
450+
var packetName = packet._id;
451451
var threadId = connection && connection.threadId !== null
452452
? ' (' + connection.threadId + ')'
453453
: '';

lib/protocol/packets/AuthSwitchRequestPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ function AuthSwitchRequestPacket(options) {
77
this.authMethodData = options.authMethodData;
88
}
99

10+
AuthSwitchRequestPacket.prototype._id = 'AuthSwitchRequestPacket';
11+
1012
AuthSwitchRequestPacket.prototype.parse = function parse(parser) {
1113
this.status = parser.parseUnsignedNumber(1);
1214
this.authMethodName = parser.parseNullTerminatedString();

lib/protocol/packets/AuthSwitchResponsePacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ function AuthSwitchResponsePacket(options) {
55
this.data = options.data;
66
}
77

8+
AuthSwitchResponsePacket.prototype._id = 'AuthSwitchResponsePacket';
9+
810
AuthSwitchResponsePacket.prototype.parse = function parse(parser) {
911
this.data = parser.parsePacketTerminatedBuffer();
1012
};

lib/protocol/packets/ClientAuthenticationPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function ClientAuthenticationPacket(options) {
1414
this.protocol41 = options.protocol41;
1515
}
1616

17+
ClientAuthenticationPacket.prototype._id = 'ClientAuthenticationPacket';
18+
1719
ClientAuthenticationPacket.prototype.parse = function(parser) {
1820
if (this.protocol41) {
1921
this.clientFlags = parser.parseUnsignedNumber(4);

lib/protocol/packets/ComChangeUserPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function ComChangeUserPacket(options) {
99
this.charsetNumber = options.charsetNumber;
1010
}
1111

12+
ComChangeUserPacket.prototype._id = 'ComChangeUserPacket';
13+
1214
ComChangeUserPacket.prototype.parse = function(parser) {
1315
this.command = parser.parseUnsignedNumber(1);
1416
this.user = parser.parseNullTerminatedString();

lib/protocol/packets/ComPingPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ function ComPingPacket() {
33
this.command = 0x0e;
44
}
55

6+
ComPingPacket.prototype._id = 'ComPingPacket';
7+
68
ComPingPacket.prototype.write = function(writer) {
79
writer.writeUnsignedNumber(1, this.command);
810
};

lib/protocol/packets/ComQueryPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ function ComQueryPacket(sql) {
44
this.sql = sql;
55
}
66

7+
ComQueryPacket.prototype._id = 'ComQueryPacket';
8+
79
ComQueryPacket.prototype.write = function(writer) {
810
writer.writeUnsignedNumber(1, this.command);
911
writer.writeString(this.sql);

lib/protocol/packets/ComQuitPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ function ComQuitPacket() {
33
this.command = 0x01;
44
}
55

6+
ComQuitPacket.prototype._id = 'ComQuitPacket';
7+
68
ComQuitPacket.prototype.parse = function parse(parser) {
79
this.command = parser.parseUnsignedNumber(1);
810
};

lib/protocol/packets/ComStatisticsPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ function ComStatisticsPacket() {
33
this.command = 0x09;
44
}
55

6+
ComStatisticsPacket.prototype._id = 'ComStatisticsPacket';
7+
68
ComStatisticsPacket.prototype.write = function(writer) {
79
writer.writeUnsignedNumber(1, this.command);
810
};

lib/protocol/packets/EmptyPacket.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module.exports = EmptyPacket;
22
function EmptyPacket() {
33
}
44

5+
EmptyPacket.prototype._id = 'EmptyPacket';
6+
57
EmptyPacket.prototype.parse = function parse() {
68
};
79

0 commit comments

Comments
 (0)