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,19 +1,15 @@
1
- // Generated by CoffeeScript 1.10.0
2
- var EventEmitter,
3
- Parser,
4
- StreamParser,
5
- extend = function (child, parent) {
6
- for (var key in parent) {
7
- if (hasProp.call(parent, key)) child[key] = parent[key];
8
- }function ctor() {
9
- this.constructor = child;
10
- }ctor.prototype = parent.prototype;child.prototype = new ctor();child.__super__ = parent.prototype;return child;
11
- },
12
- hasProp = ({}).hasOwnProperty;
13
-
14
- EventEmitter = require('events').EventEmitter;
15
-
16
- StreamParser = require("./stream-parser");
1
+ 'use strict';
2
+
3
+ var _get = require('babel-runtime/helpers/get')['default'];
4
+
5
+ var _inherits = require('babel-runtime/helpers/inherits')['default'];
6
+
7
+ var _createClass = require('babel-runtime/helpers/create-class')['default'];
8
+
9
+ var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
10
+
11
+ var EventEmitter = require('events').EventEmitter;
12
+ var StreamParser = require('./stream-parser');
17
13
 
18
14
  /*
19
15
  Buffers are thrown at the parser (by calling addBuffer).
@@ -26,32 +22,41 @@ StreamParser = require("./stream-parser");
26
22
  parsing resumes.
27
23
  */
28
24
 
29
- Parser = (function (superClass) {
30
- extend(Parser, superClass);
25
+ var Parser = (function (_EventEmitter) {
26
+ _inherits(Parser, _EventEmitter);
31
27
 
32
28
  function Parser(debug, colMetadata, options) {
29
+ var _this = this;
30
+
31
+ _classCallCheck(this, Parser);
32
+
33
+ _get(Object.getPrototypeOf(Parser.prototype), 'constructor', this).call(this);
34
+
33
35
  this.debug = debug;
34
- this.colMetadata = colMetadata;
36
+ this.colMetadata = this.colMetadata;
35
37
  this.options = options;
38
+
36
39
  this.parser = new StreamParser(this.debug, this.colMetadata, this.options);
37
- this.parser.on("data", (function (_this) {
38
- return function (token) {
39
- if (token.event) {
40
- return _this.emit(token.event, token);
41
- }
42
- };
43
- })(this));
40
+ this.parser.on('data', function (token) {
41
+ if (token.event) {
42
+ _this.emit(token.event, token);
43
+ }
44
+ });
44
45
  }
45
46
 
46
- Parser.prototype.addBuffer = function (buffer) {
47
- return this.parser.write(buffer);
48
- };
49
-
50
- Parser.prototype.isEnd = function () {
51
- return this.parser.buffer.length === 0;
52
- };
47
+ _createClass(Parser, [{
48
+ key: 'addBuffer',
49
+ value: function addBuffer(buffer) {
50
+ return this.parser.write(buffer);
51
+ }
52
+ }, {
53
+ key: 'isEnd',
54
+ value: function isEnd() {
55
+ return this.parser.buffer.length === this.parser.position;
56
+ }
57
+ }]);
53
58
 
54
59
  return Parser;
55
60
  })(EventEmitter);
56
61
 
57
- exports.Parser = Parser;
62
+ module.exports.Parser = Parser;
@@ -1,7 +1,6 @@
1
- // Generated by CoffeeScript 1.10.0
2
- var TYPE;
1
+ 'use strict';
3
2
 
4
- TYPE = {
3
+ module.exports.TYPE = {
5
4
  ALTMETADATA: 0x88,
6
5
  ALTROW: 0xD3,
7
6
  COLMETADATA: 0x81,
@@ -21,6 +20,4 @@ TYPE = {
21
20
  ROW: 0xD1,
22
21
  SSPI: 0xED,
23
22
  TABNAME: 0xA4
24
- };
25
-
26
- exports.TYPE = TYPE;
23
+ };
@@ -1,90 +1,87 @@
1
- // Generated by CoffeeScript 1.10.0
2
- var convertLEBytesToString, getNextRemainder, invert, isZero, numberToInt64LE;
1
+ 'use strict';
3
2
 
4
- isZero = function (array) {
5
- var byte, j, len;
6
- for (j = 0, len = array.length; j < len; j++) {
7
- byte = array[j];
3
+ function isZero(array) {
4
+ for (var j = 0, len = array.length; j < len; j++) {
5
+ var byte = array[j];
8
6
  if (byte !== 0) {
9
7
  return false;
10
8
  }
11
9
  }
12
10
  return true;
13
- };
11
+ }
14
12
 
15
- getNextRemainder = function (array) {
16
- var index, j, ref, remainder, s;
17
- remainder = 0;
18
- for (index = j = ref = array.length - 1; j >= 0; index = j += -1) {
19
- s = remainder * 256 + array[index];
20
- array[index] = Math.floor(s / 10);
13
+ function getNextRemainder(array) {
14
+ var remainder = 0;
15
+
16
+ for (var i = array.length - 1; i >= 0; i--) {
17
+ var s = remainder * 256 + array[i];
18
+ array[i] = Math.floor(s / 10);
21
19
  remainder = s % 10;
22
20
  }
21
+
23
22
  return remainder;
24
- };
23
+ }
24
+
25
+ function invert(array) {
26
+ // Invert bits
27
+ var len = array.length;
25
28
 
26
- invert = function (array) {
27
- var byte, index, j, k, len, len1, results;
28
- for (index = j = 0, len = array.length; j < len; index = ++j) {
29
- byte = array[index];
30
- array[index] = array[index] ^ 0xFF;
29
+ for (var i = 0; i < len; i++) {
30
+ array[i] = array[i] ^ 0xFF;
31
31
  }
32
- results = [];
33
- for (index = k = 0, len1 = array.length; k < len1; index = ++k) {
34
- byte = array[index];
35
- array[index] = array[index] + 1;
36
- if (array[index] > 255) {
37
- results.push(array[index] = 0);
32
+
33
+ for (var i = 0; i < len; i++) {
34
+ array[i] = array[i] + 1;
35
+
36
+ if (array[i] > 255) {
37
+ array[i] = 0;
38
38
  } else {
39
39
  break;
40
40
  }
41
41
  }
42
- return results;
43
- };
42
+ }
44
43
 
45
- convertLEBytesToString = function (buffer) {
46
- var array, result, sign, t;
47
- array = Array.prototype.slice.call(buffer, 0, buffer.length);
44
+ module.exports.convertLEBytesToString = convertLEBytesToString;
45
+ function convertLEBytesToString(buffer) {
46
+ var array = Array.prototype.slice.call(buffer, 0, buffer.length);
48
47
  if (isZero(array)) {
49
48
  return '0';
50
49
  } else {
50
+ var sign = undefined;
51
51
  if (array[array.length - 1] & 0x80) {
52
52
  sign = '-';
53
53
  invert(array);
54
54
  } else {
55
55
  sign = '';
56
56
  }
57
- result = '';
57
+ var result = '';
58
58
  while (!isZero(array)) {
59
- t = getNextRemainder(array);
59
+ var t = getNextRemainder(array);
60
60
  result = t + result;
61
61
  }
62
62
  return sign + result;
63
63
  }
64
- };
64
+ }
65
65
 
66
- numberToInt64LE = function (num) {
67
- var buf, carry, hi, i, j, k, lo, negate, v;
68
- negate = num < 0;
69
- hi = Math.abs(num);
70
- lo = hi % 0x100000000;
66
+ module.exports.numberToInt64LE = numberToInt64LE;
67
+ function numberToInt64LE(num) {
68
+ // adapted from https://github.com/broofa/node-int64
69
+ var negate = num < 0;
70
+ var hi = Math.abs(num);
71
+ var lo = hi % 0x100000000;
71
72
  hi = hi / 0x100000000 | 0;
72
- buf = new Buffer(8);
73
- for (i = j = 0; j <= 7; i = ++j) {
73
+ var buf = new Buffer(8);
74
+ for (var i = 0; i <= 7; i++) {
74
75
  buf[i] = lo & 0xff;
75
76
  lo = i === 3 ? hi : lo >>> 8;
76
77
  }
77
78
  if (negate) {
78
- carry = 1;
79
- for (i = k = 0; k <= 7; i = ++k) {
80
- v = (buf[i] ^ 0xff) + carry;
79
+ var carry = 1;
80
+ for (var i = 0; i <= 7; i++) {
81
+ var v = (buf[i] ^ 0xff) + carry;
81
82
  buf[i] = v & 0xff;
82
83
  carry = v >> 8;
83
84
  }
84
85
  }
85
86
  return buf;
86
- };
87
-
88
- module.exports.convertLEBytesToString = convertLEBytesToString;
89
-
90
- module.exports.numberToInt64LE = numberToInt64LE;
87
+ }