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,344 +1,464 @@
1
- var _regeneratorRuntime = require('babel-runtime/regenerator').default;
1
+ 'use strict';
2
2
 
3
- // Generated by CoffeeScript 1.10.0
4
- var Parser,
5
- StreamParser,
6
- TYPE,
7
- tokenParsers,
8
- extend = function (child, parent) {
9
- for (var key in parent) {
10
- if (hasProp.call(parent, key)) child[key] = parent[key];
11
- }function ctor() {
12
- this.constructor = child;
13
- }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
14
- },
15
- hasProp = ({}).hasOwnProperty;
3
+ var _get = require('babel-runtime/helpers/get')['default'];
16
4
 
17
- StreamParser = require("../stream-parser");
5
+ var _inherits = require('babel-runtime/helpers/inherits')['default'];
18
6
 
19
- TYPE = require('./token').TYPE;
7
+ var _createClass = require('babel-runtime/helpers/create-class')['default'];
20
8
 
21
- tokenParsers = {};
9
+ var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
22
10
 
23
- tokenParsers[TYPE.COLMETADATA] = require('./colmetadata-token-parser');
11
+ var Transform = require('readable-stream').Transform;
12
+ var TYPE = require('./token').TYPE;
24
13
 
14
+ var tokenParsers = {};
15
+ tokenParsers[TYPE.COLMETADATA] = require('./colmetadata-token-parser');
25
16
  tokenParsers[TYPE.DONE] = require('./done-token-parser').doneParser;
26
-
27
17
  tokenParsers[TYPE.DONEINPROC] = require('./done-token-parser').doneInProcParser;
28
-
29
18
  tokenParsers[TYPE.DONEPROC] = require('./done-token-parser').doneProcParser;
30
-
31
19
  tokenParsers[TYPE.ENVCHANGE] = require('./env-change-token-parser');
32
-
33
20
  tokenParsers[TYPE.ERROR] = require('./infoerror-token-parser').errorParser;
34
-
35
21
  tokenParsers[TYPE.INFO] = require('./infoerror-token-parser').infoParser;
36
-
37
22
  tokenParsers[TYPE.LOGINACK] = require('./loginack-token-parser');
38
-
39
23
  tokenParsers[TYPE.ORDER] = require('./order-token-parser');
40
-
41
24
  tokenParsers[TYPE.RETURNSTATUS] = require('./returnstatus-token-parser');
42
-
43
25
  tokenParsers[TYPE.RETURNVALUE] = require('./returnvalue-token-parser');
44
-
45
26
  tokenParsers[TYPE.ROW] = require('./row-token-parser');
46
-
47
27
  tokenParsers[TYPE.NBCROW] = require('./nbcrow-token-parser');
48
-
49
28
  tokenParsers[TYPE.SSPI] = require('./sspi-token-parser');
50
29
 
51
- module.exports = Parser = (function (superClass) {
52
- extend(Parser, superClass);
30
+ module.exports = (function (_Transform) {
31
+ _inherits(Parser, _Transform);
53
32
 
54
33
  function Parser(debug, colMetadata, options) {
34
+ _classCallCheck(this, Parser);
35
+
36
+ _get(Object.getPrototypeOf(Parser.prototype), 'constructor', this).call(this, { objectMode: true });
37
+
55
38
  this.debug = debug;
56
39
  this.colMetadata = colMetadata;
57
40
  this.options = options;
58
- Parser.__super__.constructor.call(this);
59
- }
60
41
 
61
- Parser.prototype.parser = _regeneratorRuntime.mark(function callee$1$0() {
62
- var token, type;
63
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
64
- while (1) switch (context$2$0.prev = context$2$0.next) {
65
- case 0:
66
- if (!true) {
67
- context$2$0.next = 13;
68
- break;
69
- }
70
-
71
- context$2$0.next = 3;
72
- return this.readUInt8();
73
-
74
- case 3:
75
- type = context$2$0.sent;
42
+ this.buffer = new Buffer(0);
43
+ this.position = 0;
44
+ this.suspended = false;
45
+ this.await = undefined;
46
+ this.next = undefined;
47
+ }
76
48
 
77
- if (!tokenParsers[type]) {
78
- context$2$0.next = 10;
79
- break;
80
- }
49
+ _createClass(Parser, [{
50
+ key: '_transform',
51
+ value: function _transform(input, encoding, done) {
52
+ if (this.position === this.buffer.length) {
53
+ this.buffer = input;
54
+ } else {
55
+ this.buffer = Buffer.concat([this.buffer.slice(this.position), input]);
56
+ }
57
+ this.position = 0;
81
58
 
82
- return context$2$0.delegateYield(tokenParsers[type](this, this.colMetadata, this.options), 't0', 6);
59
+ // This will be called once we need to wait for more data to
60
+ // become available
61
+ this.await = done;
83
62
 
84
- case 6:
85
- token = context$2$0.t0;
63
+ if (this.suspended) {
64
+ // Unsuspend and continue from where ever we left off.
65
+ this.suspended = false;
66
+ this.next.call(null);
67
+ }
86
68
 
87
- if (token) {
88
- switch (token.name) {
89
- case 'COLMETADATA':
90
- this.colMetadata = token.columns;
91
- }
92
- this.push(token);
69
+ // If we're no longer suspended, parse new tokens
70
+ if (!this.suspended) {
71
+ // Start the parser
72
+ this.parseTokens();
73
+ }
74
+ }
75
+ }, {
76
+ key: 'parseTokens',
77
+ value: function parseTokens() {
78
+ var _this = this;
79
+
80
+ var doneParsing = function doneParsing(token) {
81
+ if (token) {
82
+ switch (token.name) {
83
+ case 'COLMETADATA':
84
+ _this.colMetadata = token.columns;
93
85
  }
94
- context$2$0.next = 11;
95
- break;
96
86
 
97
- case 10:
98
- throw new Error("Token type " + type + " not implemented");
87
+ _this.push(token);
88
+ }
89
+ };
99
90
 
100
- case 11:
101
- context$2$0.next = 0;
102
- break;
91
+ while (!this.suspended && this.position + 1 <= this.buffer.length) {
92
+ var type = this.buffer.readUInt8(this.position, true);
103
93
 
104
- case 13:
105
- return context$2$0.abrupt('return', void 0);
94
+ this.position += 1;
106
95
 
107
- case 14:
108
- case 'end':
109
- return context$2$0.stop();
96
+ if (tokenParsers[type]) {
97
+ tokenParsers[type](this, this.colMetadata, this.options, doneParsing);
98
+ } else {
99
+ this.emit('error', new Error('Unknown type: ' + type));
100
+ }
110
101
  }
111
- }, callee$1$0, this);
112
- });
113
-
114
- Parser.prototype.readBVarChar = _regeneratorRuntime.mark(function callee$1$0(name) {
115
- var data, length;
116
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
117
- while (1) switch (context$2$0.prev = context$2$0.next) {
118
- case 0:
119
- context$2$0.next = 2;
120
- return this.readUInt8();
121
-
122
- case 2:
123
- length = context$2$0.sent;
124
- context$2$0.next = 5;
125
- return this.readBuffer(length * 2);
126
-
127
- case 5:
128
- data = context$2$0.sent;
129
- return context$2$0.abrupt('return', data.toString("ucs2"));
130
-
131
- case 7:
132
- case 'end':
133
- return context$2$0.stop();
134
- }
135
- }, callee$1$0, this);
136
- });
137
-
138
- Parser.prototype.readUsVarChar = _regeneratorRuntime.mark(function callee$1$0(name) {
139
- var data, length;
140
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
141
- while (1) switch (context$2$0.prev = context$2$0.next) {
142
- case 0:
143
- context$2$0.next = 2;
144
- return this.readUInt16LE();
145
-
146
- case 2:
147
- length = context$2$0.sent;
148
- context$2$0.next = 5;
149
- return this.readBuffer(length * 2);
150
-
151
- case 5:
152
- data = context$2$0.sent;
153
- return context$2$0.abrupt('return', data.toString("ucs2"));
154
-
155
- case 7:
156
- case 'end':
157
- return context$2$0.stop();
158
- }
159
- }, callee$1$0, this);
160
- });
161
-
162
- Parser.prototype.readBVarByte = _regeneratorRuntime.mark(function callee$1$0(name) {
163
- var length;
164
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
165
- while (1) switch (context$2$0.prev = context$2$0.next) {
166
- case 0:
167
- context$2$0.next = 2;
168
- return this.readUInt8();
169
-
170
- case 2:
171
- length = context$2$0.sent;
172
- context$2$0.next = 5;
173
- return this.readBuffer(length);
174
-
175
- case 5:
176
- return context$2$0.abrupt('return', context$2$0.sent);
177
-
178
- case 6:
179
- case 'end':
180
- return context$2$0.stop();
181
- }
182
- }, callee$1$0, this);
183
- });
184
-
185
- Parser.prototype.readUsVarByte = _regeneratorRuntime.mark(function callee$1$0(name) {
186
- var length;
187
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
188
- while (1) switch (context$2$0.prev = context$2$0.next) {
189
- case 0:
190
- context$2$0.next = 2;
191
- return this.readUInt16LE();
192
-
193
- case 2:
194
- length = context$2$0.sent;
195
- context$2$0.next = 5;
196
- return this.readBuffer(length);
197
-
198
- case 5:
199
- return context$2$0.abrupt('return', context$2$0.sent);
200
-
201
- case 6:
202
- case 'end':
203
- return context$2$0.stop();
204
- }
205
- }, callee$1$0, this);
206
- });
207
-
208
- Parser.prototype.readUInt24LE = _regeneratorRuntime.mark(function callee$1$0(name) {
209
- var high, low;
210
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
211
- while (1) switch (context$2$0.prev = context$2$0.next) {
212
- case 0:
213
- context$2$0.next = 2;
214
- return this.readUInt16LE();
215
-
216
- case 2:
217
- low = context$2$0.sent;
218
- context$2$0.next = 5;
219
- return this.readUInt8();
220
-
221
- case 5:
222
- high = context$2$0.sent;
223
- return context$2$0.abrupt('return', low | high << 16);
224
-
225
- case 7:
226
- case 'end':
227
- return context$2$0.stop();
228
- }
229
- }, callee$1$0, this);
230
- });
231
-
232
- Parser.prototype.readUInt40LE = _regeneratorRuntime.mark(function callee$1$0(name) {
233
- var high, low;
234
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
235
- while (1) switch (context$2$0.prev = context$2$0.next) {
236
- case 0:
237
- context$2$0.next = 2;
238
- return this.readUInt32LE();
239
-
240
- case 2:
241
- low = context$2$0.sent;
242
- context$2$0.next = 5;
243
- return this.readUInt8();
244
-
245
- case 5:
246
- high = context$2$0.sent;
247
- return context$2$0.abrupt('return', 0x100000000 * high + low);
248
-
249
- case 7:
250
- case 'end':
251
- return context$2$0.stop();
252
- }
253
- }, callee$1$0, this);
254
- });
255
-
256
- Parser.prototype.readUNumeric64LE = _regeneratorRuntime.mark(function callee$1$0(name) {
257
- var high, low;
258
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
259
- while (1) switch (context$2$0.prev = context$2$0.next) {
260
- case 0:
261
- context$2$0.next = 2;
262
- return this.readUInt32LE();
263
-
264
- case 2:
265
- low = context$2$0.sent;
266
- context$2$0.next = 5;
267
- return this.readUInt32LE();
268
-
269
- case 5:
270
- high = context$2$0.sent;
271
- return context$2$0.abrupt('return', 0x100000000 * high + low);
272
-
273
- case 7:
274
- case 'end':
275
- return context$2$0.stop();
276
- }
277
- }, callee$1$0, this);
278
- });
279
-
280
- Parser.prototype.readUNumeric96LE = _regeneratorRuntime.mark(function callee$1$0(name) {
281
- var dword1, dword2, dword3;
282
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
283
- while (1) switch (context$2$0.prev = context$2$0.next) {
284
- case 0:
285
- context$2$0.next = 2;
286
- return this.readUInt32LE();
287
-
288
- case 2:
289
- dword1 = context$2$0.sent;
290
- context$2$0.next = 5;
291
- return this.readUInt32LE();
292
-
293
- case 5:
294
- dword2 = context$2$0.sent;
295
- context$2$0.next = 8;
296
- return this.readUInt32LE();
297
-
298
- case 8:
299
- dword3 = context$2$0.sent;
300
- return context$2$0.abrupt('return', dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3);
301
-
302
- case 10:
303
- case 'end':
304
- return context$2$0.stop();
102
+
103
+ if (!this.suspended && this.position === this.buffer.length) {
104
+ // If we reached the end of the buffer, we can stop parsing now.
105
+ return this.await.call(null);
305
106
  }
306
- }, callee$1$0, this);
307
- });
308
-
309
- Parser.prototype.readUNumeric128LE = _regeneratorRuntime.mark(function callee$1$0(name) {
310
- var dword1, dword2, dword3, dword4;
311
- return _regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
312
- while (1) switch (context$2$0.prev = context$2$0.next) {
313
- case 0:
314
- context$2$0.next = 2;
315
- return this.readUInt32LE();
316
-
317
- case 2:
318
- dword1 = context$2$0.sent;
319
- context$2$0.next = 5;
320
- return this.readUInt32LE();
321
-
322
- case 5:
323
- dword2 = context$2$0.sent;
324
- context$2$0.next = 8;
325
- return this.readUInt32LE();
326
-
327
- case 8:
328
- dword3 = context$2$0.sent;
329
- context$2$0.next = 11;
330
- return this.readUInt32LE();
331
-
332
- case 11:
333
- dword4 = context$2$0.sent;
334
- return context$2$0.abrupt('return', dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3 + 0x100000000 * 0x100000000 * 0x100000000 * dword4);
335
-
336
- case 13:
337
- case 'end':
338
- return context$2$0.stop();
107
+ }
108
+ }, {
109
+ key: 'suspend',
110
+ value: function suspend(next) {
111
+ this.suspended = true;
112
+ this.next = next;
113
+ this.await.call(null);
114
+ }
115
+ }, {
116
+ key: 'awaitData',
117
+ value: function awaitData(length, callback) {
118
+ var _this2 = this;
119
+
120
+ if (this.position + length <= this.buffer.length) {
121
+ callback();
122
+ } else {
123
+ this.suspend(function () {
124
+ _this2.awaitData(length, callback);
125
+ });
339
126
  }
340
- }, callee$1$0, this);
341
- });
127
+ }
128
+ }, {
129
+ key: 'readInt8',
130
+ value: function readInt8(callback) {
131
+ var _this3 = this;
132
+
133
+ this.awaitData(1, function () {
134
+ var data = _this3.buffer.readInt8(_this3.position);
135
+ _this3.position += 1;
136
+ callback(data);
137
+ });
138
+ }
139
+ }, {
140
+ key: 'readUInt8',
141
+ value: function readUInt8(callback) {
142
+ var _this4 = this;
143
+
144
+ this.awaitData(1, function () {
145
+ var data = _this4.buffer.readUInt8(_this4.position);
146
+ _this4.position += 1;
147
+ callback(data);
148
+ });
149
+ }
150
+ }, {
151
+ key: 'readInt16LE',
152
+ value: function readInt16LE(callback) {
153
+ var _this5 = this;
154
+
155
+ this.awaitData(2, function () {
156
+ var data = _this5.buffer.readInt16LE(_this5.position);
157
+ _this5.position += 2;
158
+ callback(data);
159
+ });
160
+ }
161
+ }, {
162
+ key: 'readInt16BE',
163
+ value: function readInt16BE(callback) {
164
+ var _this6 = this;
165
+
166
+ this.awaitData(2, function () {
167
+ var data = _this6.buffer.readInt16BE(_this6.position);
168
+ _this6.position += 2;
169
+ callback(data);
170
+ });
171
+ }
172
+ }, {
173
+ key: 'readUInt16LE',
174
+ value: function readUInt16LE(callback) {
175
+ var _this7 = this;
176
+
177
+ this.awaitData(2, function () {
178
+ var data = _this7.buffer.readUInt16LE(_this7.position);
179
+ _this7.position += 2;
180
+ callback(data);
181
+ });
182
+ }
183
+ }, {
184
+ key: 'readUInt16BE',
185
+ value: function readUInt16BE(callback) {
186
+ var _this8 = this;
187
+
188
+ this.awaitData(2, function () {
189
+ var data = _this8.buffer.readUInt16BE(_this8.position);
190
+ _this8.position += 2;
191
+ callback(data);
192
+ });
193
+ }
194
+ }, {
195
+ key: 'readInt32LE',
196
+ value: function readInt32LE(callback) {
197
+ var _this9 = this;
198
+
199
+ this.awaitData(4, function () {
200
+ var data = _this9.buffer.readInt32LE(_this9.position);
201
+ _this9.position += 4;
202
+ callback(data);
203
+ });
204
+ }
205
+ }, {
206
+ key: 'readInt32BE',
207
+ value: function readInt32BE(callback) {
208
+ var _this10 = this;
209
+
210
+ this.awaitData(4, function () {
211
+ var data = _this10.buffer.readInt32BE(_this10.position);
212
+ _this10.position += 4;
213
+ callback(data);
214
+ });
215
+ }
216
+ }, {
217
+ key: 'readUInt32LE',
218
+ value: function readUInt32LE(callback) {
219
+ var _this11 = this;
220
+
221
+ this.awaitData(4, function () {
222
+ var data = _this11.buffer.readUInt32LE(_this11.position);
223
+ _this11.position += 4;
224
+ callback(data);
225
+ });
226
+ }
227
+ }, {
228
+ key: 'readUInt32BE',
229
+ value: function readUInt32BE(callback) {
230
+ var _this12 = this;
231
+
232
+ this.awaitData(4, function () {
233
+ var data = _this12.buffer.readUInt32BE(_this12.position);
234
+ _this12.position += 4;
235
+ callback(data);
236
+ });
237
+ }
238
+ }, {
239
+ key: 'readInt64LE',
240
+ value: function readInt64LE(callback) {
241
+ var _this13 = this;
242
+
243
+ this.awaitData(8, function () {
244
+ var data = Math.pow(2, 32) * _this13.buffer.readInt32LE(_this13.position + 4) + (_this13.buffer[_this13.position + 4] & 0x80 === 0x80 ? 1 : -1) * _this13.buffer.readUInt32LE(_this13.position);
245
+ _this13.position += 8;
246
+ callback(data);
247
+ });
248
+ }
249
+ }, {
250
+ key: 'readInt64BE',
251
+ value: function readInt64BE(callback) {
252
+ var _this14 = this;
253
+
254
+ this.awaitData(8, function () {
255
+ var data = Math.pow(2, 32) * _this14.buffer.readInt32BE(_this14.position) + (_this14.buffer[_this14.position] & 0x80 === 0x80 ? 1 : -1) * _this14.buffer.readUInt32BE(_this14.position + 4);
256
+ _this14.position += 8;
257
+ callback(data);
258
+ });
259
+ }
260
+ }, {
261
+ key: 'readUInt64LE',
262
+ value: function readUInt64LE(callback) {
263
+ var _this15 = this;
264
+
265
+ this.awaitData(8, function () {
266
+ var data = Math.pow(2, 32) * _this15.buffer.readUInt32LE(_this15.position + 4) + _this15.buffer.readUInt32LE(_this15.position);
267
+ _this15.position += 8;
268
+ callback(data);
269
+ });
270
+ }
271
+ }, {
272
+ key: 'readUInt64BE',
273
+ value: function readUInt64BE(callback) {
274
+ var _this16 = this;
275
+
276
+ this.awaitData(8, function () {
277
+ var data = Math.pow(2, 32) * _this16.buffer.readUInt32BE(_this16.position) + _this16.buffer.readUInt32BE(_this16.position + 4);
278
+ _this16.position += 8;
279
+ callback(data);
280
+ });
281
+ }
282
+ }, {
283
+ key: 'readFloatLE',
284
+ value: function readFloatLE(callback) {
285
+ var _this17 = this;
286
+
287
+ this.awaitData(4, function () {
288
+ var data = _this17.buffer.readFloatLE(_this17.position);
289
+ _this17.position += 4;
290
+ callback(data);
291
+ });
292
+ }
293
+ }, {
294
+ key: 'readFloatBE',
295
+ value: function readFloatBE(callback) {
296
+ var _this18 = this;
297
+
298
+ this.awaitData(4, function () {
299
+ var data = _this18.buffer.readFloatBE(_this18.position);
300
+ _this18.position += 4;
301
+ callback(data);
302
+ });
303
+ }
304
+ }, {
305
+ key: 'readDoubleLE',
306
+ value: function readDoubleLE(callback) {
307
+ var _this19 = this;
308
+
309
+ this.awaitData(8, function () {
310
+ var data = _this19.buffer.readDoubleLE(_this19.position);
311
+ _this19.position += 8;
312
+ callback(data);
313
+ });
314
+ }
315
+ }, {
316
+ key: 'readDoubleBE',
317
+ value: function readDoubleBE(callback) {
318
+ var _this20 = this;
319
+
320
+ this.awaitData(8, function () {
321
+ var data = _this20.buffer.readDoubleBE(_this20.position);
322
+ _this20.position += 8;
323
+ callback(data);
324
+ });
325
+ }
326
+ }, {
327
+ key: 'readUInt24LE',
328
+ value: function readUInt24LE(callback) {
329
+ var _this21 = this;
330
+
331
+ this.awaitData(3, function () {
332
+ var low = _this21.buffer.readUInt16LE(_this21.position);
333
+ var high = _this21.buffer.readUInt8(_this21.position + 2);
334
+
335
+ _this21.position += 3;
336
+
337
+ callback(low | high << 16);
338
+ });
339
+ }
340
+ }, {
341
+ key: 'readUInt40LE',
342
+ value: function readUInt40LE(callback) {
343
+ var _this22 = this;
344
+
345
+ this.awaitData(5, function () {
346
+ var low = _this22.buffer.readUInt32LE(_this22.position);
347
+ var high = _this22.buffer.readUInt8(_this22.position + 4);
348
+
349
+ _this22.position += 5;
350
+
351
+ callback(0x100000000 * high + low);
352
+ });
353
+ }
354
+ }, {
355
+ key: 'readUNumeric64LE',
356
+ value: function readUNumeric64LE(callback) {
357
+ var _this23 = this;
358
+
359
+ this.awaitData(8, function () {
360
+ var low = _this23.buffer.readUInt32LE(_this23.position);
361
+ var high = _this23.buffer.readUInt32LE(_this23.position + 4);
362
+
363
+ _this23.position += 8;
364
+
365
+ callback(0x100000000 * high + low);
366
+ });
367
+ }
368
+ }, {
369
+ key: 'readUNumeric96LE',
370
+ value: function readUNumeric96LE(callback) {
371
+ var _this24 = this;
372
+
373
+ this.awaitData(12, function () {
374
+ var dword1 = _this24.buffer.readUInt32LE(_this24.position);
375
+ var dword2 = _this24.buffer.readUInt32LE(_this24.position + 4);
376
+ var dword3 = _this24.buffer.readUInt32LE(_this24.position + 8);
377
+
378
+ _this24.position += 12;
379
+
380
+ callback(dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3);
381
+ });
382
+ }
383
+ }, {
384
+ key: 'readUNumeric128LE',
385
+ value: function readUNumeric128LE(callback) {
386
+ var _this25 = this;
387
+
388
+ this.awaitData(16, function () {
389
+ var dword1 = _this25.buffer.readUInt32LE(_this25.position);
390
+ var dword2 = _this25.buffer.readUInt32LE(_this25.position + 4);
391
+ var dword3 = _this25.buffer.readUInt32LE(_this25.position + 8);
392
+ var dword4 = _this25.buffer.readUInt32LE(_this25.position + 12);
393
+
394
+ _this25.position += 16;
395
+
396
+ callback(dword1 + 0x100000000 * dword2 + 0x100000000 * 0x100000000 * dword3 + 0x100000000 * 0x100000000 * 0x100000000 * dword4);
397
+ });
398
+ }
399
+
400
+ // Variable length data
401
+
402
+ }, {
403
+ key: 'readBuffer',
404
+ value: function readBuffer(length, callback) {
405
+ var _this26 = this;
406
+
407
+ this.awaitData(length, function () {
408
+ var data = _this26.buffer.slice(_this26.position, _this26.position + length);
409
+ _this26.position += length;
410
+ callback(data);
411
+ });
412
+ }
413
+
414
+ // Read a Unicode String (BVARCHAR)
415
+ }, {
416
+ key: 'readBVarChar',
417
+ value: function readBVarChar(callback) {
418
+ var _this27 = this;
419
+
420
+ this.readUInt8(function (length) {
421
+ _this27.readBuffer(length * 2, function (data) {
422
+ callback(data.toString('ucs2'));
423
+ });
424
+ });
425
+ }
426
+
427
+ // Read a Unicode String (USVARCHAR)
428
+ }, {
429
+ key: 'readUsVarChar',
430
+ value: function readUsVarChar(callback) {
431
+ var _this28 = this;
432
+
433
+ this.readUInt16LE(function (length) {
434
+ _this28.readBuffer(length * 2, function (data) {
435
+ callback(data.toString('ucs2'));
436
+ });
437
+ });
438
+ }
439
+
440
+ // Read binary data (BVARBYTE)
441
+ }, {
442
+ key: 'readBVarByte',
443
+ value: function readBVarByte(callback) {
444
+ var _this29 = this;
445
+
446
+ this.readUInt8(function (length) {
447
+ _this29.readBuffer(length, callback);
448
+ });
449
+ }
450
+
451
+ // Read binary data (USVARBYTE)
452
+ }, {
453
+ key: 'readUsVarByte',
454
+ value: function readUsVarByte(callback) {
455
+ var _this30 = this;
456
+
457
+ this.readUInt16LE(function (length) {
458
+ _this30.readBuffer(length, callback);
459
+ });
460
+ }
461
+ }]);
342
462
 
343
463
  return Parser;
344
- })(StreamParser);
464
+ })(Transform);