tedious 1.12.3 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +1 -1
  2. package/appveyor.yml +9 -5
  3. package/benchmarks/README.md +33 -0
  4. package/benchmarks/common.js +82 -0
  5. package/benchmarks/index.js +34 -0
  6. package/benchmarks/query/many-result-rows.js +49 -0
  7. package/benchmarks/query/nvarchar-large.js +44 -0
  8. package/benchmarks/query/nvarchar-small.js +44 -0
  9. package/benchmarks/query/varbinary-4.js +42 -0
  10. package/benchmarks/query/varbinary-huge.js +46 -0
  11. package/benchmarks/query/varbinary-large.js +46 -0
  12. package/benchmarks/query/varbinary-small.js +42 -0
  13. package/benchmarks/token-parser/colmetadata-token.js +42 -0
  14. package/benchmarks/token-parser/done-token.js +42 -0
  15. package/benchmarks/token-parser/simple-tokens.js +366 -0
  16. package/lib/all-headers.js +9 -11
  17. package/lib/buffertools.js +17 -13
  18. package/lib/bulk-load.js +196 -169
  19. package/lib/collation.js +80 -2
  20. package/lib/connection.js +1086 -1060
  21. package/lib/data-type.js +450 -253
  22. package/lib/debug.js +57 -51
  23. package/lib/errors.js +40 -55
  24. package/lib/guid-parser.js +12 -36
  25. package/lib/instance-lookup.js +57 -54
  26. package/lib/library.js +3 -2
  27. package/lib/login7-payload.js +187 -180
  28. package/lib/message-io.js +169 -199
  29. package/lib/metadata-parser.js +169 -255
  30. package/lib/ntlm-payload.js +173 -160
  31. package/lib/packet.js +166 -152
  32. package/lib/prelogin-payload.js +170 -160
  33. package/lib/request.js +122 -122
  34. package/lib/rpcrequest-payload.js +64 -38
  35. package/lib/special-stored-procedure.js +3 -2
  36. package/lib/sqlbatch-payload.js +20 -16
  37. package/lib/stream-parser.js +116 -104
  38. package/lib/tds-versions.js +5 -8
  39. package/lib/tedious.js +8 -14
  40. package/lib/token/colmetadata-token-parser.js +79 -125
  41. package/lib/token/done-token-parser.js +47 -129
  42. package/lib/token/env-change-token-parser.js +90 -126
  43. package/lib/token/infoerror-token-parser.js +47 -125
  44. package/lib/token/loginack-token-parser.js +36 -74
  45. package/lib/token/nbcrow-token-parser.js +40 -64
  46. package/lib/token/order-token-parser.js +26 -43
  47. package/lib/token/returnstatus-token-parser.js +11 -23
  48. package/lib/token/returnvalue-token-parser.js +31 -54
  49. package/lib/token/row-token-parser.js +39 -52
  50. package/lib/token/sspi-token-parser.js +14 -32
  51. package/lib/token/stream-parser.js +424 -304
  52. package/lib/token/token-stream-parser.js +39 -34
  53. package/lib/token/token.js +3 -6
  54. package/lib/tracking-buffer/bigint.js +45 -48
  55. package/lib/tracking-buffer/readable-tracking-buffer.js +238 -223
  56. package/lib/tracking-buffer/tracking-buffer.js +3 -9
  57. package/lib/tracking-buffer/writable-tracking-buffer.js +272 -244
  58. package/lib/transaction.js +112 -102
  59. package/lib/value-parser.js +559 -1154
  60. package/package.json +10 -9
  61. package/benchmarks/benchmarks.coffee +0 -122
  62. package/benchmarks/query.coffee +0 -57
@@ -1,118 +1,59 @@
1
- var _regeneratorRuntime = require('babel-runtime/regenerator').default;
1
+ 'use strict';
2
2
 
3
- // Generated by CoffeeScript 1.10.0
4
- var metadataParse;
3
+ var metadataParse = require('../metadata-parser');
5
4
 
6
- metadataParse = require('../metadata-parser');
5
+ function readTableName(parser, options, metadata, callback) {
6
+ if (metadata.type.hasTableName) {
7
+ if (options.tdsVersion >= '7_2') {
8
+ parser.readUInt8(function (numberOfTableNameParts) {
9
+ var tableName = [];
7
10
 
8
- module.exports = _regeneratorRuntime.mark(function callee$0$0(parser, colMetadata, options) {
9
- var c, colName, columnCount, columns, i, metadata, numberOfTableNameParts, part, ref, tableName;
10
- return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
11
- while (1) switch (context$1$0.prev = context$1$0.next) {
12
- case 0:
13
- context$1$0.next = 2;
14
- return parser.readUInt16LE();
11
+ var i = 0;
12
+ function next(done) {
13
+ if (numberOfTableNameParts === i) {
14
+ return done();
15
+ }
15
16
 
16
- case 2:
17
- columnCount = context$1$0.sent;
17
+ parser.readUsVarChar(function (part) {
18
+ tableName.push(part);
18
19
 
19
- columns = [];
20
- c = i = 0, ref = columnCount;
20
+ i++;
21
21
 
22
- case 5:
23
- if (!(0 <= ref ? i < ref : i > ref)) {
24
- context$1$0.next = 29;
25
- break;
26
- }
27
-
28
- return context$1$0.delegateYield(metadataParse(parser, options), 't0', 7);
29
-
30
- case 7:
31
- metadata = context$1$0.t0;
32
-
33
- if (!metadata.type.hasTableName) {
34
- context$1$0.next = 21;
35
- break;
36
- }
37
-
38
- if (!(options.tdsVersion >= '7_2')) {
39
- context$1$0.next = 17;
40
- break;
41
- }
42
-
43
- context$1$0.next = 12;
44
- return parser.readUInt8();
45
-
46
- case 12:
47
- numberOfTableNameParts = context$1$0.sent;
48
- return context$1$0.delegateYield(_regeneratorRuntime.mark(function callee$1$0() {
49
- var j, ref1, results;
50
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
51
- while (1) switch (context$2$0.prev = context$2$0.next) {
52
- case 0:
53
- results = [];
54
- part = j = 1, ref1 = numberOfTableNameParts;
55
-
56
- case 2:
57
- if (!(1 <= ref1 ? j <= ref1 : j >= ref1)) {
58
- context$2$0.next = 10;
59
- break;
60
- }
61
-
62
- context$2$0.t0 = results;
63
- return context$2$0.delegateYield(parser.readUsVarChar(), 't1', 5);
64
-
65
- case 5:
66
- context$2$0.t2 = context$2$0.t1;
67
- context$2$0.t0.push.call(context$2$0.t0, context$2$0.t2);
68
-
69
- case 7:
70
- part = 1 <= ref1 ? ++j : --j;
71
- context$2$0.next = 2;
72
- break;
73
-
74
- case 10:
75
- return context$2$0.abrupt('return', results);
76
-
77
- case 11:
78
- case 'end':
79
- return context$2$0.stop();
80
- }
81
- }, callee$1$0, this);
82
- })(), 't1', 14);
83
-
84
- case 14:
85
- tableName = context$1$0.t1;
86
- context$1$0.next = 19;
87
- break;
88
-
89
- case 17:
90
- return context$1$0.delegateYield(parser.readUsVarChar(), 't2', 18);
91
-
92
- case 18:
93
- tableName = context$1$0.t2;
94
-
95
- case 19:
96
- context$1$0.next = 22;
97
- break;
98
-
99
- case 21:
100
- tableName = void 0;
101
-
102
- case 22:
103
- return context$1$0.delegateYield(parser.readBVarChar(), 't3', 23);
104
-
105
- case 23:
106
- colName = context$1$0.t3;
107
-
108
- if (options.columnNameReplacer) {
109
- colName = options.columnNameReplacer(colName, c, metadata);
110
- } else if (options.camelCaseColumns) {
111
- colName = colName.replace(/^[A-Z]/, function (s) {
112
- return s.toLowerCase();
22
+ next(done);
113
23
  });
114
24
  }
115
- columns.push({
25
+
26
+ next(function () {
27
+ callback(tableName);
28
+ });
29
+ });
30
+ } else {
31
+ parser.readUsVarChar(callback);
32
+ }
33
+ } else {
34
+ callback(undefined);
35
+ }
36
+ }
37
+
38
+ function readColumnName(parser, options, index, metadata, callback) {
39
+ parser.readBVarChar(function (colName) {
40
+ if (options.columnNameReplacer) {
41
+ callback(options.columnNameReplacer(colName, index, metadata));
42
+ } else if (options.camelCaseColumns) {
43
+ callback(colName.replace(/^[A-Z]/, function (s) {
44
+ return s.toLowerCase();
45
+ }));
46
+ } else {
47
+ callback(colName);
48
+ }
49
+ });
50
+ }
51
+
52
+ function readColumn(parser, options, index, callback) {
53
+ metadataParse(parser, options, function (metadata) {
54
+ readTableName(parser, options, metadata, function (tableName) {
55
+ readColumnName(parser, options, index, metadata, function (colName) {
56
+ callback({
116
57
  userType: metadata.userType,
117
58
  flags: metadata.flags,
118
59
  type: metadata.type,
@@ -124,22 +65,35 @@ module.exports = _regeneratorRuntime.mark(function callee$0$0(parser, colMetadat
124
65
  dataLength: metadata.dataLength,
125
66
  tableName: tableName
126
67
  });
127
-
128
- case 26:
129
- c = 0 <= ref ? ++i : --i;
130
- context$1$0.next = 5;
131
- break;
132
-
133
- case 29:
134
- return context$1$0.abrupt('return', {
135
- name: 'COLMETADATA',
136
- event: 'columnMetadata',
137
- columns: columns
138
- });
139
-
140
- case 30:
141
- case 'end':
142
- return context$1$0.stop();
68
+ });
69
+ });
70
+ });
71
+ }
72
+
73
+ module.exports = function (parser, colMetadata, options, callback) {
74
+ parser.readUInt16LE(function (columnCount) {
75
+ var columns = [];
76
+
77
+ var i = 0;
78
+ function next(done) {
79
+ if (i === columnCount) {
80
+ return done();
81
+ }
82
+
83
+ readColumn(parser, options, i, function (column) {
84
+ columns.push(column);
85
+
86
+ i++;
87
+ next(done);
88
+ });
143
89
  }
144
- }, callee$0$0, this);
145
- });
90
+
91
+ next(function () {
92
+ callback({
93
+ name: 'COLMETADATA',
94
+ event: 'columnMetadata',
95
+ columns: columns
96
+ });
97
+ });
98
+ });
99
+ };
@@ -1,147 +1,65 @@
1
- var _regeneratorRuntime = require('babel-runtime/regenerator').default;
1
+ 'use strict';
2
2
 
3
- // Generated by CoffeeScript 1.10.0
4
- var STATUS, doneInProcParser, doneParser, doneProcParser, parseToken;
3
+ // s2.2.7.5/6/7
5
4
 
6
- STATUS = {
5
+ var STATUS = {
7
6
  MORE: 0x0001,
8
7
  ERROR: 0x0002,
8
+ // This bit is not yet in use by SQL Server, so is not exposed in the returned token
9
9
  INXACT: 0x0004,
10
10
  COUNT: 0x0010,
11
11
  ATTN: 0x0020,
12
12
  SRVERROR: 0x0100
13
13
  };
14
14
 
15
- parseToken = _regeneratorRuntime.mark(function callee$0$0(parser, options) {
16
- var attention, curCmd, inTxn, more, rowCount, rowCountValid, serverError, sqlError, status, token;
17
- return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
18
- while (1) switch (context$1$0.prev = context$1$0.next) {
19
- case 0:
20
- context$1$0.next = 2;
21
- return parser.readUInt16LE();
22
-
23
- case 2:
24
- status = context$1$0.sent;
25
-
26
- more = !!(status & STATUS.MORE);
27
- sqlError = !!(status & STATUS.ERROR);
28
- inTxn = !!(status & STATUS.INXACT);
29
- rowCountValid = !!(status & STATUS.COUNT);
30
- attention = !!(status & STATUS.ATTN);
31
- serverError = !!(status & STATUS.SRVERROR);
32
- context$1$0.next = 11;
33
- return parser.readUInt16LE();
34
-
35
- case 11:
36
- curCmd = context$1$0.sent;
37
-
38
- if (!(options.tdsVersion < "7_2")) {
39
- context$1$0.next = 18;
40
- break;
41
- }
42
-
43
- context$1$0.next = 15;
44
- return parser.readUInt32LE();
45
-
46
- case 15:
47
- rowCount = context$1$0.sent;
48
- context$1$0.next = 21;
49
- break;
50
-
51
- case 18:
52
- context$1$0.next = 20;
53
- return parser.readUInt64LE();
54
-
55
- case 20:
56
- rowCount = context$1$0.sent;
57
-
58
- case 21:
59
- if (!rowCountValid) {
60
- rowCount = void 0;
61
- }
62
- return context$1$0.abrupt('return', token = {
15
+ function parseToken(parser, options, callback) {
16
+ parser.readUInt16LE(function (status) {
17
+ var more = !!(status & STATUS.MORE);
18
+ var sqlError = !!(status & STATUS.ERROR);
19
+ var rowCountValid = !!(status & STATUS.COUNT);
20
+ var attention = !!(status & STATUS.ATTN);
21
+ var serverError = !!(status & STATUS.SRVERROR);
22
+
23
+ parser.readUInt16LE(function (curCmd) {
24
+ (options.tdsVersion < '7_2' ? parser.readUInt32LE : parser.readUInt64LE).call(parser, function (rowCount) {
25
+ callback({
63
26
  name: 'DONE',
64
27
  event: 'done',
65
28
  more: more,
66
29
  sqlError: sqlError,
67
30
  attention: attention,
68
31
  serverError: serverError,
69
- rowCount: rowCount,
32
+ rowCount: rowCountValid ? rowCount : undefined,
70
33
  curCmd: curCmd
71
34
  });
72
-
73
- case 23:
74
- case 'end':
75
- return context$1$0.stop();
76
- }
77
- }, callee$0$0, this);
78
- });
79
-
80
- doneParser = _regeneratorRuntime.mark(function callee$0$0(parser, colMetadata, options) {
81
- var token;
82
- return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
83
- while (1) switch (context$1$0.prev = context$1$0.next) {
84
- case 0:
85
- return context$1$0.delegateYield(parseToken(parser, options), 't0', 1);
86
-
87
- case 1:
88
- token = context$1$0.t0;
89
-
90
- token.name = 'DONE';
91
- token.event = 'done';
92
- return context$1$0.abrupt('return', token);
93
-
94
- case 5:
95
- case 'end':
96
- return context$1$0.stop();
97
- }
98
- }, callee$0$0, this);
99
- });
100
-
101
- doneInProcParser = _regeneratorRuntime.mark(function callee$0$0(parser, colMetadata, options) {
102
- var token;
103
- return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
104
- while (1) switch (context$1$0.prev = context$1$0.next) {
105
- case 0:
106
- return context$1$0.delegateYield(parseToken(parser, options), 't0', 1);
107
-
108
- case 1:
109
- token = context$1$0.t0;
110
-
111
- token.name = 'DONEINPROC';
112
- token.event = 'doneInProc';
113
- return context$1$0.abrupt('return', token);
114
-
115
- case 5:
116
- case 'end':
117
- return context$1$0.stop();
118
- }
119
- }, callee$0$0, this);
120
- });
121
-
122
- doneProcParser = _regeneratorRuntime.mark(function callee$0$0(parser, colMetadata, options) {
123
- var token;
124
- return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
125
- while (1) switch (context$1$0.prev = context$1$0.next) {
126
- case 0:
127
- return context$1$0.delegateYield(parseToken(parser, options), 't0', 1);
128
-
129
- case 1:
130
- token = context$1$0.t0;
131
-
132
- token.name = 'DONEPROC';
133
- token.event = 'doneProc';
134
- return context$1$0.abrupt('return', token);
135
-
136
- case 5:
137
- case 'end':
138
- return context$1$0.stop();
139
- }
140
- }, callee$0$0, this);
141
- });
142
-
143
- exports.doneParser = doneParser;
144
-
145
- exports.doneInProcParser = doneInProcParser;
146
-
147
- exports.doneProcParser = doneProcParser;
35
+ });
36
+ });
37
+ });
38
+ }
39
+
40
+ module.exports.doneParser = doneParser;
41
+ function doneParser(parser, colMetadata, options, callback) {
42
+ parseToken(parser, options, function (token) {
43
+ token.name = 'DONE';
44
+ token.event = 'done';
45
+ callback(token);
46
+ });
47
+ }
48
+
49
+ module.exports.doneInProcParser = doneInProcParser;
50
+ function doneInProcParser(parser, colMetadata, options, callback) {
51
+ parseToken(parser, options, function (token) {
52
+ token.name = 'DONEINPROC';
53
+ token.event = 'doneInProc';
54
+ callback(token);
55
+ });
56
+ }
57
+
58
+ module.exports.doneProcParser = doneProcParser;
59
+ function doneProcParser(parser, colMetadata, options, callback) {
60
+ parseToken(parser, options, function (token) {
61
+ token.name = 'DONEPROC';
62
+ token.event = 'doneProc';
63
+ callback(token);
64
+ });
65
+ }
@@ -1,9 +1,6 @@
1
- var _regeneratorRuntime = require('babel-runtime/regenerator').default;
1
+ 'use strict';
2
2
 
3
- // Generated by CoffeeScript 1.10.0
4
- var types;
5
-
6
- types = {
3
+ var types = {
7
4
  1: {
8
5
  name: 'DATABASE',
9
6
  event: 'databaseChange'
@@ -53,133 +50,100 @@ types = {
53
50
  }
54
51
  };
55
52
 
56
- module.exports = _regeneratorRuntime.mark(function callee$0$0(parser) {
57
- var length, newValue, oldValue, port, protocol, routePacket, server, serverLen, type, typeNumber, valueLength;
58
- return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
59
- while (1) switch (context$1$0.prev = context$1$0.next) {
60
- case 0:
61
- context$1$0.next = 2;
62
- return parser.readUInt16LE();
63
-
64
- case 2:
65
- length = context$1$0.sent;
66
- context$1$0.next = 5;
67
- return parser.readUInt8();
68
-
69
- case 5:
70
- typeNumber = context$1$0.sent;
71
-
72
- type = types[typeNumber];
73
-
74
- if (!type) {
75
- context$1$0.next = 48;
76
- break;
77
- }
78
-
79
- context$1$0.t0 = type.name;
80
- context$1$0.next = context$1$0.t0 === 'DATABASE' ? 11 : context$1$0.t0 === 'LANGUAGE' ? 11 : context$1$0.t0 === 'CHARSET' ? 11 : context$1$0.t0 === 'PACKET_SIZE' ? 11 : context$1$0.t0 === 'DATABASE_MIRRORING_PARTNER' ? 11 : context$1$0.t0 === 'SQL_COLLATION' ? 16 : context$1$0.t0 === 'BEGIN_TXN' ? 16 : context$1$0.t0 === 'COMMIT_TXN' ? 16 : context$1$0.t0 === 'ROLLBACK_TXN' ? 16 : context$1$0.t0 === 'RESET_CONNECTION' ? 16 : context$1$0.t0 === 'ROUTING_CHANGE' ? 21 : 41;
81
- break;
82
-
83
- case 11:
84
- return context$1$0.delegateYield(parser.readBVarChar(), 't1', 12);
85
-
86
- case 12:
87
- newValue = context$1$0.t1;
88
- return context$1$0.delegateYield(parser.readBVarChar(), 't2', 14);
89
-
90
- case 14:
91
- oldValue = context$1$0.t2;
92
- return context$1$0.abrupt('break', 45);
93
-
94
- case 16:
95
- return context$1$0.delegateYield(parser.readBVarByte(), 't3', 17);
96
-
97
- case 17:
98
- newValue = context$1$0.t3;
99
- return context$1$0.delegateYield(parser.readBVarByte(), 't4', 19);
100
-
101
- case 19:
102
- oldValue = context$1$0.t4;
103
- return context$1$0.abrupt('break', 45);
104
-
105
- case 21:
106
- context$1$0.next = 23;
107
- return parser.readUInt16LE();
108
-
109
- case 23:
110
- valueLength = context$1$0.sent;
111
- context$1$0.next = 26;
112
- return parser.readBuffer(valueLength);
113
-
114
- case 26:
115
- routePacket = context$1$0.sent;
116
-
117
- protocol = routePacket.readUInt8(0);
118
-
119
- if (!(protocol !== 0)) {
120
- context$1$0.next = 30;
121
- break;
122
- }
123
-
124
- throw new Error('Unknown protocol byte in routing change event');
125
-
126
- case 30:
127
- port = routePacket.readUInt16LE(1);
128
- serverLen = routePacket.readUInt16LE(3);
129
- server = routePacket.toString('ucs2', 5, 5 + serverLen * 2);
130
- newValue = {
131
- protocol: protocol,
132
- port: port,
133
- server: server
134
- };
135
- context$1$0.next = 36;
136
- return parser.readUInt16LE();
137
-
138
- case 36:
139
- valueLength = context$1$0.sent;
140
- context$1$0.next = 39;
141
- return parser.readBuffer(valueLength);
142
-
143
- case 39:
144
- oldValue = context$1$0.sent;
145
- return context$1$0.abrupt('break', 45);
146
-
147
- case 41:
148
- console.error("Tedious > Unsupported ENVCHANGE type " + typeNumber);
149
- context$1$0.next = 44;
150
- return parser.readBuffer(length - 1);
151
-
152
- case 44:
153
- return context$1$0.abrupt('return');
154
-
155
- case 45:
156
- if (type.name === 'PACKET_SIZE') {
157
- newValue = parseInt(newValue);
158
- oldValue = parseInt(oldValue);
159
- }
160
- context$1$0.next = 52;
161
- break;
53
+ function readNewAndOldValue(parser, length, type, callback) {
54
+ switch (type.name) {
55
+ case 'DATABASE':
56
+ case 'LANGUAGE':
57
+ case 'CHARSET':
58
+ case 'PACKET_SIZE':
59
+ case 'DATABASE_MIRRORING_PARTNER':
60
+ return parser.readBVarChar(function (newValue) {
61
+ parser.readBVarChar(function (oldValue) {
62
+ if (type.name === 'PACKET_SIZE') {
63
+ callback(parseInt(newValue), parseInt(oldValue));
64
+ } else {
65
+ callback(newValue, oldValue);
66
+ }
67
+ });
68
+ });
69
+
70
+ case 'SQL_COLLATION':
71
+ case 'BEGIN_TXN':
72
+ case 'COMMIT_TXN':
73
+ case 'ROLLBACK_TXN':
74
+ case 'RESET_CONNECTION':
75
+ return parser.readBVarByte(function (newValue) {
76
+ parser.readBVarByte(function (oldValue) {
77
+ callback(newValue, oldValue);
78
+ });
79
+ });
80
+
81
+ case 'ROUTING_CHANGE':
82
+ parser.readUInt16LE(function (valueLength) {
83
+ // Routing Change:
84
+ // Byte 1: Protocol (must be 0)
85
+ // Bytes 2-3 (USHORT): Port number
86
+ // Bytes 4-5 (USHORT): Length of server data in unicode (2byte chars)
87
+ // Bytes 6-*: Server name in unicode characters
88
+ parser.readBuffer(valueLength, function (routePacket) {
89
+ var protocol = routePacket.readUInt8(0);
90
+
91
+ if (protocol !== 0) {
92
+ return parser.emit('error', new Error('Unknown protocol byte in routing change event'));
93
+ }
94
+
95
+ var port = routePacket.readUInt16LE(1);
96
+ var serverLen = routePacket.readUInt16LE(3);
97
+ // 2 bytes per char, starting at offset 5
98
+ var server = routePacket.toString('ucs2', 5, 5 + serverLen * 2);
99
+
100
+ var newValue = {
101
+ protocol: protocol,
102
+ port: port,
103
+ server: server
104
+ };
105
+
106
+ parser.readUInt16LE(function (oldValueLength) {
107
+ parser.readBuffer(oldValueLength, function (oldValue) {
108
+ callback(newValue, oldValue);
109
+ });
110
+ });
111
+ });
112
+ });
162
113
 
163
- case 48:
164
- console.error("Tedious > Unsupported ENVCHANGE type " + typeNumber);
165
- context$1$0.next = 51;
166
- return parser.readBuffer(length - 1);
114
+ break;
167
115
 
168
- case 51:
169
- return context$1$0.abrupt('return');
116
+ default:
117
+ console.error('Tedious > Unsupported ENVCHANGE type ' + type.name);
118
+ // skip unknown bytes
119
+ parser.readBuffer(length - 1, function () {
120
+ callback(undefined, undefined);
121
+ });
122
+ }
123
+ }
124
+
125
+ module.exports = function (parser, colMetadata, options, callback) {
126
+ parser.readUInt16LE(function (length) {
127
+ parser.readUInt8(function (typeNumber) {
128
+ var type = types[typeNumber];
129
+
130
+ if (!type) {
131
+ console.error('Tedious > Unsupported ENVCHANGE type ' + typeNumber);
132
+ // skip unknown bytes
133
+ return parser.readBuffer(length - 1, function () {
134
+ callback();
135
+ });
136
+ }
170
137
 
171
- case 52:
172
- return context$1$0.abrupt('return', {
138
+ readNewAndOldValue(parser, length, type, function (newValue, oldValue) {
139
+ callback({
173
140
  name: 'ENVCHANGE',
174
141
  type: type.name,
175
142
  event: type.event,
176
143
  oldValue: oldValue,
177
144
  newValue: newValue
178
145
  });
179
-
180
- case 53:
181
- case 'end':
182
- return context$1$0.stop();
183
- }
184
- }, callee$0$0, this);
185
- });
146
+ });
147
+ });
148
+ });
149
+ };