Преглед на файлове

上傳檔案到 'test_two_list'

fatwolf преди 3 години
родител
ревизия
9c77c43f1a
променени са 100 файла, в които са добавени 24602 реда и са изтрити 0 реда
  1. 60 0
      test_two_list/2015-01-30.md
  2. 2237 0
      test_two_list/API.html
  3. 168 0
      test_two_list/Auth.js
  4. 20 0
      test_two_list/AuthSwitchRequestPacket.js
  5. 14 0
      test_two_list/AuthSwitchResponsePacket.js
  6. 79 0
      test_two_list/BufferList.js
  7. 266 0
      test_two_list/CHANGELOG.md
  8. 38 0
      test_two_list/CONTRIBUTING.md
  9. 67 0
      test_two_list/ChangeUser.js
  10. 569 0
      test_two_list/Changes.md
  11. 54 0
      test_two_list/ClientAuthenticationPacket.js
  12. 26 0
      test_two_list/ComChangeUserPacket.js
  13. 12 0
      test_two_list/ComPingPacket.js
  14. 15 0
      test_two_list/ComQueryPacket.js
  15. 12 0
      test_two_list/ComQuitPacket.js
  16. 12 0
      test_two_list/ComStatisticsPacket.js
  17. 529 0
      test_two_list/Connection.js
  18. 209 0
      test_two_list/ConnectionConfig.js
  19. 9 0
      test_two_list/EmptyPacket.js
  20. 25 0
      test_two_list/EofPacket.js
  21. 35 0
      test_two_list/ErrorPacket.js
  22. 26 0
      test_two_list/Field.js
  23. 93 0
      test_two_list/FieldPacket.js
  24. 136 0
      test_two_list/GOVERNANCE.md
  25. 43 0
      test_two_list/HISTORY.md
  26. 126 0
      test_two_list/Handshake.js
  27. 103 0
      test_two_list/HandshakeInitializationPacket.js
  28. 16 0
      test_two_list/History.md
  29. 89 0
      test_two_list/Inquire1.html
  30. 23 0
      test_two_list/LICENCE
  31. 24 0
      test_two_list/LICENSE
  32. 19 0
      test_two_list/License
  33. 15 0
      test_two_list/LocalDataFilePacket.js
  34. 21 0
      test_two_list/LocalInfileRequestPacket.js
  35. 6 0
      test_two_list/Makefile
  36. 44 0
      test_two_list/OkPacket.js
  37. 14 0
      test_two_list/OldPasswordPacket.js
  38. 5 0
      test_two_list/PacketHeader.js
  39. 211 0
      test_two_list/PacketWriter.js
  40. 491 0
      test_two_list/Parser.js
  41. 19 0
      test_two_list/Ping.js
  42. 294 0
      test_two_list/Pool.js
  43. 288 0
      test_two_list/PoolCluster.js
  44. 32 0
      test_two_list/PoolConfig.js
  45. 65 0
      test_two_list/PoolConnection.js
  46. 136 0
      test_two_list/PoolNamespace.js
  47. 31 0
      test_two_list/PoolSelector.js
  48. 463 0
      test_two_list/Protocol.js
  49. 228 0
      test_two_list/Query.js
  50. 40 0
      test_two_list/Quit.js
  51. 53 0
      test_two_list/README.md
  52. 1548 0
      test_two_list/Readme.md
  53. 7 0
      test_two_list/ResultSet.js
  54. 14 0
      test_two_list/ResultSetHeaderPacket.js
  55. 130 0
      test_two_list/RowDataPacket.js
  56. 27 0
      test_two_list/SSLRequestPacket.js
  57. 125 0
      test_two_list/Sequence.js
  58. 1 0
      test_two_list/SqlString.js
  59. 30 0
      test_two_list/Statistics.js
  60. 20 0
      test_two_list/StatisticsPacket.js
  61. 33 0
      test_two_list/Timer.js
  62. 14 0
      test_two_list/UseOldPasswordPacket.js
  63. 131 0
      test_two_list/_stream_duplex.js
  64. 47 0
      test_two_list/_stream_passthrough.js
  65. 1019 0
      test_two_list/_stream_readable.js
  66. 214 0
      test_two_list/_stream_transform.js
  67. 687 0
      test_two_list/_stream_writable.js
  68. 128 0
      test_two_list/app.py
  69. 1829 0
      test_two_list/bignumber.d.ts
  70. 2902 0
      test_two_list/bignumber.js
  71. 1 0
      test_two_list/bignumber.min.js
  72. 1 0
      test_two_list/bignumber.min.js.map
  73. 2888 0
      test_two_list/bignumber.mjs
  74. 67 0
      test_two_list/browser.js
  75. 262 0
      test_two_list/charsets.js
  76. 26 0
      test_two_list/client.js
  77. 19 0
      test_two_list/component.json
  78. 74 0
      test_two_list/destroy.js
  79. 1 0
      test_two_list/duplex-browser.js
  80. 1 0
      test_two_list/duplex.js
  81. 2476 0
      test_two_list/errors.js
  82. 18 0
      test_two_list/field_flags.js
  83. 187 0
      test_two_list/index.d.ts
  84. 7 0
      test_two_list/index.js
  85. 9 0
      test_two_list/inherits.js
  86. 27 0
      test_two_list/inherits_browser.js
  87. 19 0
      test_two_list/license.md
  88. 6 0
      test_two_list/node.js
  89. 79 0
      test_two_list/package-lock.json
  90. 56 0
      test_two_list/package.json
  91. 1 0
      test_two_list/passthrough.js
  92. 7 0
      test_two_list/readable-browser.js
  93. 19 0
      test_two_list/readable.js
  94. 18 0
      test_two_list/readme.md
  95. 39 0
      test_two_list/server_status.js
  96. 1480 0
      test_two_list/ssl_profiles.js
  97. 1 0
      test_two_list/stream-browser.js
  98. 1 0
      test_two_list/stream.js
  99. 296 0
      test_two_list/string_decoder.js
  100. 0 0
      test_two_list/test.html

+ 60 - 0
test_two_list/2015-01-30.md

@@ -0,0 +1,60 @@
+# streams WG Meeting 2015-01-30
+
+## Links
+
+* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
+* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
+* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
+
+## Agenda
+
+Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
+
+* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
+* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
+* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
+* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
+
+## Minutes
+
+### adopt a charter
+
+* group: +1's all around
+
+### What versioning scheme should be adopted?
+* group: +1’s 3.0.0
+* domenic+group: pulling in patches from other sources where appropriate
+* mikeal: version independently, suggesting versions for io.js
+* mikeal+domenic: work with TC to notify in advance of changes
+simpler stream creation
+
+### streamline creation of streams
+* sam: streamline creation of streams
+* domenic: nice simple solution posted
+  but, we lose the opportunity to change the model
+  may not be backwards incompatible (double check keys)
+
+  **action item:** domenic will check
+
+### remove implicit flowing of streams on(‘data’)
+* add isFlowing / isPaused
+* mikeal: worrying that we’re documenting polyfill methods – confuses users
+* domenic: more reflective API is probably good, with warning labels for users
+* new section for mad scientists (reflective stream access)
+* calvin: name the “third state”
+* mikeal: maybe borrow the name from whatwg?
+* domenic: we’re missing the “third state”
+* consensus: kind of difficult to name the third state
+* mikeal: figure out differences in states / compat
+* mathias: always flow on data – eliminates third state
+  * explore what it breaks
+
+**action items:**
+* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
+* ask rod/build for infrastructure
+* **chris**: explore the “flow on data” approach
+* add isPaused/isFlowing
+* add new docs section
+* move isPaused to that section
+
+

Файловите разлики са ограничени, защото са твърде много
+ 2237 - 0
test_two_list/API.html


+ 168 - 0
test_two_list/Auth.js

@@ -0,0 +1,168 @@
+var Buffer = require('safe-buffer').Buffer;
+var Crypto = require('crypto');
+var Auth   = exports;
+
+function auth(name, data, options) {
+  options = options || {};
+
+  switch (name) {
+    case 'mysql_native_password':
+      return Auth.token(options.password, data.slice(0, 20));
+    default:
+      return undefined;
+  }
+}
+Auth.auth = auth;
+
+function sha1(msg) {
+  var hash = Crypto.createHash('sha1');
+  hash.update(msg, 'binary');
+  return hash.digest('binary');
+}
+Auth.sha1 = sha1;
+
+function xor(a, b) {
+  a = Buffer.from(a, 'binary');
+  b = Buffer.from(b, 'binary');
+  var result = Buffer.allocUnsafe(a.length);
+  for (var i = 0; i < a.length; i++) {
+    result[i] = (a[i] ^ b[i]);
+  }
+  return result;
+}
+Auth.xor = xor;
+
+Auth.token = function(password, scramble) {
+  if (!password) {
+    return Buffer.alloc(0);
+  }
+
+  // password must be in binary format, not utf8
+  var stage1 = sha1((Buffer.from(password, 'utf8')).toString('binary'));
+  var stage2 = sha1(stage1);
+  var stage3 = sha1(scramble.toString('binary') + stage2);
+  return xor(stage3, stage1);
+};
+
+// This is a port of sql/password.c:hash_password which needs to be used for
+// pre-4.1 passwords.
+Auth.hashPassword = function(password) {
+  var nr     = [0x5030, 0x5735];
+  var add    = 7;
+  var nr2    = [0x1234, 0x5671];
+  var result = Buffer.alloc(8);
+
+  if (typeof password === 'string'){
+    password = Buffer.from(password);
+  }
+
+  for (var i = 0; i < password.length; i++) {
+    var c = password[i];
+    if (c === 32 || c === 9) {
+      // skip space in password
+      continue;
+    }
+
+    // nr^= (((nr & 63)+add)*c)+ (nr << 8);
+    // nr = xor(nr, add(mul(add(and(nr, 63), add), c), shl(nr, 8)))
+    nr = this.xor32(nr, this.add32(this.mul32(this.add32(this.and32(nr, [0, 63]), [0, add]), [0, c]), this.shl32(nr, 8)));
+
+    // nr2+=(nr2 << 8) ^ nr;
+    // nr2 = add(nr2, xor(shl(nr2, 8), nr))
+    nr2 = this.add32(nr2, this.xor32(this.shl32(nr2, 8), nr));
+
+    // add+=tmp;
+    add += c;
+  }
+
+  this.int31Write(result, nr, 0);
+  this.int31Write(result, nr2, 4);
+
+  return result;
+};
+
+Auth.randomInit = function(seed1, seed2) {
+  return {
+    max_value     : 0x3FFFFFFF,
+    max_value_dbl : 0x3FFFFFFF,
+    seed1         : seed1 % 0x3FFFFFFF,
+    seed2         : seed2 % 0x3FFFFFFF
+  };
+};
+
+Auth.myRnd = function(r){
+  r.seed1 = (r.seed1 * 3 + r.seed2) % r.max_value;
+  r.seed2 = (r.seed1 + r.seed2 + 33) % r.max_value;
+
+  return r.seed1 / r.max_value_dbl;
+};
+
+Auth.scramble323 = function(message, password) {
+  if (!password) {
+    return Buffer.alloc(0);
+  }
+
+  var to          = Buffer.allocUnsafe(8);
+  var hashPass    = this.hashPassword(password);
+  var hashMessage = this.hashPassword(message.slice(0, 8));
+  var seed1       = this.int32Read(hashPass, 0) ^ this.int32Read(hashMessage, 0);
+  var seed2       = this.int32Read(hashPass, 4) ^ this.int32Read(hashMessage, 4);
+  var r           = this.randomInit(seed1, seed2);
+
+  for (var i = 0; i < 8; i++){
+    to[i] = Math.floor(this.myRnd(r) * 31) + 64;
+  }
+  var extra = (Math.floor(this.myRnd(r) * 31));
+
+  for (var i = 0; i < 8; i++){
+    to[i] ^= extra;
+  }
+
+  return to;
+};
+
+Auth.xor32 = function(a, b){
+  return [a[0] ^ b[0], a[1] ^ b[1]];
+};
+
+Auth.add32 = function(a, b){
+  var w1 = a[1] + b[1];
+  var w2 = a[0] + b[0] + ((w1 & 0xFFFF0000) >> 16);
+
+  return [w2 & 0xFFFF, w1 & 0xFFFF];
+};
+
+Auth.mul32 = function(a, b){
+  // based on this example of multiplying 32b ints using 16b
+  // http://www.dsprelated.com/showmessage/89790/1.php
+  var w1 = a[1] * b[1];
+  var w2 = (((a[1] * b[1]) >> 16) & 0xFFFF) + ((a[0] * b[1]) & 0xFFFF) + (a[1] * b[0] & 0xFFFF);
+
+  return [w2 & 0xFFFF, w1 & 0xFFFF];
+};
+
+Auth.and32 = function(a, b){
+  return [a[0] & b[0], a[1] & b[1]];
+};
+
+Auth.shl32 = function(a, b){
+  // assume b is 16 or less
+  var w1 = a[1] << b;
+  var w2 = (a[0] << b) | ((w1 & 0xFFFF0000) >> 16);
+
+  return [w2 & 0xFFFF, w1 & 0xFFFF];
+};
+
+Auth.int31Write = function(buffer, number, offset) {
+  buffer[offset] = (number[0] >> 8) & 0x7F;
+  buffer[offset + 1] = (number[0]) & 0xFF;
+  buffer[offset + 2] = (number[1] >> 8) & 0xFF;
+  buffer[offset + 3] = (number[1]) & 0xFF;
+};
+
+Auth.int32Read = function(buffer, offset){
+  return (buffer[offset] << 24)
+       + (buffer[offset + 1] << 16)
+       + (buffer[offset + 2] << 8)
+       + (buffer[offset + 3]);
+};

+ 20 - 0
test_two_list/AuthSwitchRequestPacket.js

@@ -0,0 +1,20 @@
+module.exports = AuthSwitchRequestPacket;
+function AuthSwitchRequestPacket(options) {
+  options = options || {};
+
+  this.status         = 0xfe;
+  this.authMethodName = options.authMethodName;
+  this.authMethodData = options.authMethodData;
+}
+
+AuthSwitchRequestPacket.prototype.parse = function parse(parser) {
+  this.status         = parser.parseUnsignedNumber(1);
+  this.authMethodName = parser.parseNullTerminatedString();
+  this.authMethodData = parser.parsePacketTerminatedBuffer();
+};
+
+AuthSwitchRequestPacket.prototype.write = function write(writer) {
+  writer.writeUnsignedNumber(1, this.status);
+  writer.writeNullTerminatedString(this.authMethodName);
+  writer.writeBuffer(this.authMethodData);
+};

+ 14 - 0
test_two_list/AuthSwitchResponsePacket.js

@@ -0,0 +1,14 @@
+module.exports = AuthSwitchResponsePacket;
+function AuthSwitchResponsePacket(options) {
+  options = options || {};
+
+  this.data = options.data;
+}
+
+AuthSwitchResponsePacket.prototype.parse = function parse(parser) {
+  this.data = parser.parsePacketTerminatedBuffer();
+};
+
+AuthSwitchResponsePacket.prototype.write = function write(writer) {
+  writer.writeBuffer(this.data);
+};

+ 79 - 0
test_two_list/BufferList.js

@@ -0,0 +1,79 @@
+'use strict';
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Buffer = require('safe-buffer').Buffer;
+var util = require('util');
+
+function copyBuffer(src, target, offset) {
+  src.copy(target, offset);
+}
+
+module.exports = function () {
+  function BufferList() {
+    _classCallCheck(this, BufferList);
+
+    this.head = null;
+    this.tail = null;
+    this.length = 0;
+  }
+
+  BufferList.prototype.push = function push(v) {
+    var entry = { data: v, next: null };
+    if (this.length > 0) this.tail.next = entry;else this.head = entry;
+    this.tail = entry;
+    ++this.length;
+  };
+
+  BufferList.prototype.unshift = function unshift(v) {
+    var entry = { data: v, next: this.head };
+    if (this.length === 0) this.tail = entry;
+    this.head = entry;
+    ++this.length;
+  };
+
+  BufferList.prototype.shift = function shift() {
+    if (this.length === 0) return;
+    var ret = this.head.data;
+    if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
+    --this.length;
+    return ret;
+  };
+
+  BufferList.prototype.clear = function clear() {
+    this.head = this.tail = null;
+    this.length = 0;
+  };
+
+  BufferList.prototype.join = function join(s) {
+    if (this.length === 0) return '';
+    var p = this.head;
+    var ret = '' + p.data;
+    while (p = p.next) {
+      ret += s + p.data;
+    }return ret;
+  };
+
+  BufferList.prototype.concat = function concat(n) {
+    if (this.length === 0) return Buffer.alloc(0);
+    if (this.length === 1) return this.head.data;
+    var ret = Buffer.allocUnsafe(n >>> 0);
+    var p = this.head;
+    var i = 0;
+    while (p) {
+      copyBuffer(p.data, ret, i);
+      i += p.data.length;
+      p = p.next;
+    }
+    return ret;
+  };
+
+  return BufferList;
+}();
+
+if (util && util.inspect && util.inspect.custom) {
+  module.exports.prototype[util.inspect.custom] = function () {
+    var obj = util.inspect({ length: this.length });
+    return this.constructor.name + ' ' + obj;
+  };
+}

+ 266 - 0
test_two_list/CHANGELOG.md

@@ -0,0 +1,266 @@
+#### 9.0.0
+* 27/05/2019
+* For compatibility with legacy browsers, remove `Symbol` references.
+
+#### 8.1.1
+* 24/02/2019
+* [BUGFIX] #222 Restore missing `var` to `export BigNumber`.
+* Allow any key in BigNumber.Instance in *bignumber.d.ts*.
+
+#### 8.1.0
+* 23/02/2019
+* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`.
+* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed.
+* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance.
+* Add `_isBigNumber` to prototype in *bignumber.mjs*.
+* Add tests for BigNumber creation from object.
+* Update *API.html*.
+
+#### 8.0.2
+* 13/01/2019
+* #209 `toPrecision` without argument should follow `toString`.
+* Improve *Use* section of *README*.
+* Optimise `toString(10)`.
+* Add verson number to API doc.
+
+#### 8.0.1
+* 01/11/2018
+* Rest parameter must be array type in *bignumber.d.ts*.
+
+#### 8.0.0
+* 01/11/2018
+* [NEW FEATURE] Add `BigNumber.sum` method.
+* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options.
+* [NEW FEATURE] #178 Pass custom formatting to `toFormat`.
+* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings.
+* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string.
+* #183 Add Node.js `crypto` requirement to documentation.
+* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet.
+* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL.
+* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*.
+* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array.
+* Update *.travis.yml*.
+* Remove *bower.json*.
+
+#### 7.2.1
+* 24/05/2018
+* Add `browser` field to *package.json*.
+
+#### 7.2.0
+* 22/05/2018
+* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
+
+#### 7.1.0
+* 18/05/2018
+* Add `module` field to *package.json* for *bignumber.mjs*.
+
+#### 7.0.2
+* 17/05/2018
+* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
+* Add note to *README* regarding creating BigNumbers from Number values.
+
+#### 7.0.1
+* 26/04/2018
+* #158 Fix global object variable name typo.
+
+#### 7.0.0
+* 26/04/2018
+* #143 Remove global BigNumber from typings.
+* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
+* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
+* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
+* #154 `exponentiatedBy`: allow BigNumber exponent.
+* #156 Prevent Content Security Policy *unsafe-eval* issue.
+* `toFraction`: allow `Infinity` maximum denominator.
+* Comment-out some excess tests to reduce test time.
+* Amend indentation and other spacing.
+
+#### 6.0.0
+* 26/01/2018
+* #137 Implement `APLHABET` configuration option.
+* Remove `ERRORS` configuration option.
+* Remove `toDigits` method; extend `precision` method accordingly.
+* Remove s`round` method; extend `decimalPlaces` method accordingly.
+* Remove methods: `ceil`, `floor`, and `truncated`.
+* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
+* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
+* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
+* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
+* Refactor test suite.
+* Add *CHANGELOG.md*.
+* Rewrite *bignumber.d.ts*.
+* Redo API image.
+
+#### 5.0.0
+* 27/11/2017
+* #81 Don't throw on constructor call without `new`.
+
+#### 4.1.0
+* 26/09/2017
+* Remove node 0.6 from *.travis.yml*.
+* Add *bignumber.mjs*.
+
+#### 4.0.4
+* 03/09/2017
+* Add missing aliases to *bignumber.d.ts*.
+
+#### 4.0.3
+* 30/08/2017
+* Add types: *bignumber.d.ts*.
+
+#### 4.0.2
+* 03/05/2017
+* #120 Workaround Safari/Webkit bug.
+
+#### 4.0.1
+* 05/04/2017
+* #121 BigNumber.default to BigNumber['default'].
+
+#### 4.0.0
+* 09/01/2017
+* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
+
+#### 3.1.2
+* 08/01/2017
+* Minor documentation edit.
+
+#### 3.1.1
+* 08/01/2017
+* Uncomment `isBigNumber` tests.
+* Ignore dot files.
+
+#### 3.1.0
+* 08/01/2017
+* Add `isBigNumber` method.
+
+#### 3.0.2
+* 08/01/2017
+* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
+
+#### 3.0.1
+* 23/11/2016
+* Apply fix for old ipads with `%` issue, see #57 and #102.
+* Correct error message.
+
+#### 3.0.0
+* 09/11/2016
+* Remove `require('crypto')` - leave it to the user.
+* Add `BigNumber.set` as `BigNumber.config` alias.
+* Default `POW_PRECISION` to `0`.
+
+#### 2.4.0
+* 14/07/2016
+* #97 Add exports to support ES6 imports.
+
+#### 2.3.0
+* 07/03/2016
+* #86 Add modulus parameter to `toPower`.
+
+#### 2.2.0
+* 03/03/2016
+* #91 Permit larger JS integers.
+
+#### 2.1.4
+* 15/12/2015
+* Correct UMD.
+
+#### 2.1.3
+* 13/12/2015
+* Refactor re global object and crypto availability when bundling.
+
+#### 2.1.2
+* 10/12/2015
+* Bugfix: `window.crypto` not assigned to `crypto`.
+
+#### 2.1.1
+* 09/12/2015
+* Prevent code bundler from adding `crypto` shim.
+
+#### 2.1.0
+* 26/10/2015
+* For `valueOf` and `toJSON`, include the minus sign with negative zero.
+
+#### 2.0.8
+* 2/10/2015
+* Internal round function bugfix.
+
+#### 2.0.6
+* 31/03/2015
+* Add bower.json. Tweak division after in-depth review.
+
+#### 2.0.5
+* 25/03/2015
+* Amend README. Remove bitcoin address.
+
+#### 2.0.4
+* 25/03/2015
+* Critical bugfix #58: division.
+
+#### 2.0.3
+* 18/02/2015
+* Amend README. Add source map.
+
+#### 2.0.2
+* 18/02/2015
+* Correct links.
+
+#### 2.0.1
+* 18/02/2015
+* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
+* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
+* Add an `another` method to enable multiple independent constructors to be created.
+* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
+* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
+* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
+* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
+* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
+* Improve code quality.
+* Improve documentation.
+
+#### 2.0.0
+* 29/12/2014
+* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
+* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
+* Store a BigNumber's coefficient in base 1e14, rather than base 10.
+* Add fast path for integers to BigNumber constructor.
+* Incorporate the library into the online documentation.
+
+#### 1.5.0
+* 13/11/2014
+* Add `toJSON` and `decimalPlaces` methods.
+
+#### 1.4.1
+* 08/06/2014
+* Amend README.
+
+#### 1.4.0
+* 08/05/2014
+* Add `toNumber`.
+
+#### 1.3.0
+* 08/11/2013
+* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
+* Maximum radix to 64.
+
+#### 1.2.1
+* 17/10/2013
+* Sign of zero when x < 0 and x + (-x) = 0.
+
+#### 1.2.0
+* 19/9/2013
+* Throw Error objects for stack.
+
+#### 1.1.1
+* 22/8/2013
+* Show original value in constructor error message.
+
+#### 1.1.0
+* 1/8/2013
+* Allow numbers with trailing radix point.
+
+#### 1.0.1
+* Bugfix: error messages with incorrect method name
+
+#### 1.0.0
+* 8/11/2012
+* Initial release

+ 38 - 0
test_two_list/CONTRIBUTING.md

@@ -0,0 +1,38 @@
+# Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+* (a) The contribution was created in whole or in part by me and I
+  have the right to submit it under the open source license
+  indicated in the file; or
+
+* (b) The contribution is based upon previous work that, to the best
+  of my knowledge, is covered under an appropriate open source
+  license and I have the right under that license to submit that
+  work with modifications, whether created in whole or in part
+  by me, under the same open source license (unless I am
+  permitted to submit under a different license), as indicated
+  in the file; or
+
+* (c) The contribution was provided directly to me by some other
+  person who certified (a), (b) or (c) and I have not modified
+  it.
+
+* (d) I understand and agree that this project and the contribution
+  are public and that a record of the contribution (including all
+  personal information I submit with it, including my sign-off) is
+  maintained indefinitely and may be redistributed consistent with
+  this project or the open source license(s) involved.
+
+## Moderation Policy
+
+The [Node.js Moderation Policy] applies to this WG.
+
+## Code of Conduct
+
+The [Node.js Code of Conduct][] applies to this WG.
+
+[Node.js Code of Conduct]:
+https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
+[Node.js Moderation Policy]:
+https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md

+ 67 - 0
test_two_list/ChangeUser.js

@@ -0,0 +1,67 @@
+var Sequence = require('./Sequence');
+var Util     = require('util');
+var Packets  = require('../packets');
+var Auth     = require('../Auth');
+
+module.exports = ChangeUser;
+Util.inherits(ChangeUser, Sequence);
+function ChangeUser(options, callback) {
+  Sequence.call(this, options, callback);
+
+  this._user          = options.user;
+  this._password      = options.password;
+  this._database      = options.database;
+  this._charsetNumber = options.charsetNumber;
+  this._currentConfig = options.currentConfig;
+}
+
+ChangeUser.prototype.determinePacket = function determinePacket(firstByte) {
+  switch (firstByte) {
+    case 0xfe: return Packets.AuthSwitchRequestPacket;
+    case 0xff: return Packets.ErrorPacket;
+    default: return undefined;
+  }
+};
+
+ChangeUser.prototype.start = function(handshakeInitializationPacket) {
+  var scrambleBuff = handshakeInitializationPacket.scrambleBuff();
+  scrambleBuff     = Auth.token(this._password, scrambleBuff);
+
+  var packet = new Packets.ComChangeUserPacket({
+    user          : this._user,
+    scrambleBuff  : scrambleBuff,
+    database      : this._database,
+    charsetNumber : this._charsetNumber
+  });
+
+  this._currentConfig.user          = this._user;
+  this._currentConfig.password      = this._password;
+  this._currentConfig.database      = this._database;
+  this._currentConfig.charsetNumber = this._charsetNumber;
+
+  this.emit('packet', packet);
+};
+
+ChangeUser.prototype['AuthSwitchRequestPacket'] = function (packet) {
+  var name = packet.authMethodName;
+  var data = Auth.auth(name, packet.authMethodData, {
+    password: this._password
+  });
+
+  if (data !== undefined) {
+    this.emit('packet', new Packets.AuthSwitchResponsePacket({
+      data: data
+    }));
+  } else {
+    var err   = new Error('MySQL is requesting the ' + name + ' authentication method, which is not supported.');
+    err.code  = 'UNSUPPORTED_AUTH_METHOD';
+    err.fatal = true;
+    this.end(err);
+  }
+};
+
+ChangeUser.prototype['ErrorPacket'] = function(packet) {
+  var err = this._packetToError(packet);
+  err.fatal = true;
+  this.end(err);
+};

+ 569 - 0
test_two_list/Changes.md

@@ -0,0 +1,569 @@
+# Changes
+
+This file is a manually maintained list of changes for each release. Feel free
+to add your changes here when sending pull requests. Also send corrections if
+you spot any mistakes.
+
+## v2.18.1 (2020-01-23)
+
+* Fix Amazon RDS profile for yaSSL MySQL servers with 2019 CA #2292
+
+## v2.18.0 (2020-01-21)
+
+* Add `localInfile` option to control `LOAD DATA LOCAL INFILE`
+* Add new Amazon RDS Root 2019 CA to Amazon RDS SSL profile #2280
+* Add new error codes up to MySQL 5.7.29
+* Fix early detection of bad callback to `connection.query`
+* Support Node.js 12.x #2211
+* Support Node.js 13.x
+* Support non-enumerable properties in object argument to `connection.query` #2253
+* Update `bignumber.js` to 9.0.0
+* Update `readable-stream` to 2.3.7
+
+## v2.17.1 (2019-04-18)
+
+* Update `bignumber.js` to 7.2.1 #2206
+  - Fix npm deprecation warning
+
+## v2.17.0 (2019-04-17)
+
+* Add reverse type lookup for small performance gain #2170
+* Fix `connection.threadId` missing on handshake failure
+* Fix duplicate packet name in debug output
+* Fix no password support for old password protocol
+* Remove special case for handshake in determine packet code
+* Small performance improvement starting command sequence
+* Support auth switch in change user flow #1776
+* Support Node.js 11.x
+* Update `bignumber.js` to 6.0.0
+
+## v2.16.0 (2018-07-17)
+
+* Add Amazon RDS GovCloud SSL certificates #1876
+* Add new error codes up to MySQL 5.7.21
+* Include connection ID in debug output
+* Support Node.js 9.x
+* Support Node.js 10.x #2003 #2024 #2026 #2034
+* Update Amazon RDS SSL certificates
+* Update `bignumber.js` to 4.1.0
+* Update `readable-stream` to 2.3.6
+* Update `sqlstring` to 2.3.1
+  - Fix incorrectly replacing non-placeholders in SQL
+
+## v2.15.0 (2017-10-05)
+
+* Add new Amazon RDS ca-central-1 certificate CA to Amazon RDS SSL profile #1809
+* Add new error codes up to MySQL 5.7.19
+* Add `mysql.raw()` to generate pre-escaped values #877 #1821
+* Fix "changedRows" to work on non-English servers #1819
+* Fix error when server sends RST on `QUIT` #1811
+* Fix typo in insecure auth error message
+* Support `mysql_native_password` auth switch request for Azure #1396 #1729 #1730
+* Update `sqlstring` to 2.3.0
+  - Add `.toSqlString()` escape overriding
+  - Small performance improvement on `escapeId`
+* Update `bignumber.js` to 4.0.4
+
+## v2.14.1 (2017-08-01)
+
+* Fix holding first closure for lifetime of connection #1785
+
+## v2.14.0 (2017-07-25)
+
+* Add new Amazon RDS ap-south-1 certificate CA to Amazon RDS SSL profile #1780
+* Add new Amazon RDS eu-west-2 certificate CA to Amazon RDS SSL profile #1770
+* Add `sql` property to query `Error` objects #1462 #1628 #1629
+* Add `sqlMessage` property to `Error` objects #1714
+* Fix the MySQL 5.7.17 error codes
+* Support Node.js 8.x
+* Update `bignumber.js` to 4.0.2
+* Update `readable-stream` to 2.3.3
+* Use `safe-buffer` for improved Buffer API
+
+## v2.13.0 (2017-01-24)
+
+* Accept regular expression as pool cluster pattern #1572
+* Accept wildcard anywhere in pool cluster pattern #1570
+* Add `acquire` and `release` events to `Pool` for tracking #1366 #1449 #1528 #1625
+* Add new error codes up to MySQL 5.7.17
+* Fix edge cases when determing Query result packets #1547
+* Fix memory leak when using long-running domains #1619 #1620
+* Remove unnecessary buffer copies when receiving large packets
+* Update `bignumber.js` to 3.1.2
+* Use a simple buffer list to improve performance #566 #1590
+
+## v2.12.0 (2016-11-02)
+
+* Accept array of type names to `dateStrings` option #605 #1481
+* Add `query` method to `PoolNamespace` #1256 #1505 #1506
+  - Used as `cluster.of(...).query(...)`
+* Add new error codes up to MySQL 5.7.16
+* Fix edge cases writing certain length coded values
+* Fix typo in `HANDSHAKE_NO_SSL_SUPPORT` error message #1534
+* Support Node.js 7.x
+* Update `bignumber.js` to 2.4.0
+* Update `sqlstring` to 2.2.0
+  - Accept numbers and other value types in `escapeId`
+  - Escape invalid `Date` objects as `NULL`
+  - Run `buffer.toString()` through escaping
+
+## v2.11.1 (2016-06-07)
+
+* Fix writing truncated packets starting with large string/buffer #1438
+
+## v2.11.0 (2016-06-06)
+
+* Add `POOL_CLOSED` code to "Pool is closed." error
+* Add `POOL_CONNLIMIT` code to "No connections available." error #1332
+* Bind underlying connections in pool to same domain as pool #1242
+* Bind underlying socket to same domain as connection #1243
+* Fix allocation errors receiving many result rows #918 #1265 #1324 #1415
+* Fix edge cases constructing long stack traces #1387
+* Fix handshake inactivity timeout on Node.js v4.2.0 #1223 #1236 #1239 #1240 #1241 #1252
+* Fix Query stream to emit close after ending #1349 #1350
+* Fix type cast for BIGINT columns when number is negative #1376
+* Performance improvements for array/object escaping in SqlString #1331
+* Performance improvements for formatting in SqlString #1431
+* Performance improvements for string escaping in SqlString #1390
+* Performance improvements for writing packets to network
+* Support Node.js 6.x
+* Update `bignumber.js` to 2.3.0
+* Update `readable-stream` to 1.1.14
+* Use the `sqlstring` module for SQL escaping and formatting
+
+## v2.10.2 (2016-01-12)
+
+* Fix exception/hang from certain SSL connection errors #1153
+* Update `bignumber.js` to 2.1.4
+
+## v2.10.1 (2016-01-11)
+
+* Add new Amazon RDS ap-northeast-2 certificate CA to Amazon RDS SSL profile #1329
+
+## v2.10.0 (2015-12-15)
+
+* Add new error codes up to MySQL 5.7.9 #1294
+* Add new JSON type constant #1295
+* Add types for fractional seconds support
+* Fix `connection.destroy()` on pool connection creating sequences #1291
+* Fix error code 139 `HA_ERR_TO_BIG_ROW` to be `HA_ERR_TOO_BIG_ROW`
+* Fix error when call site error is missing stack #1179
+* Fix reading password from MySQL URL that has bare colon #1278
+* Handle MySQL servers not closing TCP connection after QUIT -> OK exchange #1277
+* Minor SqlString Date to string performance improvement #1233
+* Support Node.js 4.x
+* Support Node.js 5.x
+* Update `bignumber.js` to 2.1.2
+
+## v2.9.0 (2015-08-19)
+
+* Accept the `ciphers` property in connection `ssl` option #1185
+* Fix bad timezone conversion from `Date` to string for certain times #1045 #1155
+
+## v2.8.0 (2015-07-13)
+
+* Add `connect` event to `Connection` #1129
+* Default `timeout` for `connection.end` to 30 seconds #1057
+* Fix a sync callback when sequence enqueue fails #1147
+* Provide static require analysis
+* Re-use connection from pool after `conn.changeUser` is used #837 #1088
+
+## v2.7.0 (2015-05-27)
+
+* Destroy/end connections removed from the pool on error
+* Delay implied connect until after `.query` argument validation
+* Do not remove connections with non-fatal errors from the pool
+* Error early if `callback` argument to `.query` is not a function #1060
+* Lazy-load modules from many entry point; reduced memory use
+
+## v2.6.2 (2015-04-14)
+
+* Fix `Connection.createQuery` for no SQL #1058
+* Update `bignumber.js` to 2.0.7
+
+## v2.6.1 (2015-03-26)
+
+* Update `bignumber.js` to 2.0.5 #1037 #1038
+
+## v2.6.0 (2015-03-24)
+
+* Add `poolCluster.remove` to remove pools from the cluster #1006 #1007
+* Add optional callback to `poolCluster.end`
+* Add `restoreNodeTimeout` option to `PoolCluster` #880 #906
+* Fix LOAD DATA INFILE handling in multiple statements #1036
+* Fix `poolCluster.add` to throw if `PoolCluster` has been closed
+* Fix `poolCluster.add` to throw if `id` already defined
+* Fix un-catchable error from `PoolCluster` when MySQL server offline #1033
+* Improve speed formatting SQL #1019
+* Support io.js
+
+## v2.5.5 (2015-02-23)
+
+* Store SSL presets in JS instead of JSON #959
+* Support Node.js 0.12
+* Update Amazon RDS SSL certificates #1001
+
+## v2.5.4 (2014-12-16)
+
+* Fix error if falsy error thrown in callback handler #960
+* Fix various error code strings #954
+
+## v2.5.3 (2014-11-06)
+
+* Fix `pool.query` streaming interface not emitting connection errors #941
+
+## v2.5.2 (2014-10-10)
+
+* Fix receiving large text fields #922
+
+## v2.5.1 (2014-09-22)
+
+* Fix `pool.end` race conditions #915
+* Fix `pool.getConnection` race conditions
+
+## v2.5.0 (2014-09-07)
+
+* Add code `POOL_ENQUEUELIMIT` to error reaching `queueLimit`
+* Add `enqueue` event to pool #716
+* Add `enqueue` event to protocol and connection #381
+* Blacklist unsupported connection flags #881
+* Make only column names enumerable in `RowDataPacket` #549 #895
+* Support Node.js 0.6 #718
+
+## v2.4.3 (2014-08-25)
+
+* Fix `pool.query` to use `typeCast` configuration
+
+## v2.4.2 (2014-08-03)
+
+* Fix incorrect sequence packet errors to be catchable #867
+* Fix stray protocol packet errors to be catchable #867
+* Fix timing of fatal protocol errors bubbling to user #879
+
+## v2.4.1 (2014-07-17)
+
+* Fix `pool.query` not invoking callback on connection error #872
+
+## v2.4.0 (2014-07-13)
+
+* Add code `POOL_NOEXIST` in PoolCluster error #846
+* Add `acquireTimeout` pool option to specify a timeout for acquiring a connection #821 #854
+* Add `connection.escapeId`
+* Add `pool.escapeId`
+* Add `timeout` option to all sequences #855 #863
+* Default `connectTimeout` to 10 seconds
+* Fix domain binding with `conn.connect`
+* Fix `packet.default` to actually be a string
+* Fix `PARSER_*` errors to be catchable
+* Fix `PROTOCOL_PACKETS_OUT_OF_ORDER` error to be catchable #844
+* Include packets that failed parsing under `debug`
+* Return `Query` object from `pool.query` like `conn.query` #830
+* Use `EventEmitter.listenerCount` when possible for faster counting
+
+## v2.3.2 (2014-05-29)
+
+* Fix pool leaking connections after `conn.changeUser` #833
+
+## v2.3.1 (2014-05-26)
+
+* Add database errors to error constants
+* Add global errors to error constants
+* Throw when calling `conn.release` multiple times #824 #827
+* Update known error codes
+
+## v2.3.0 (2014-05-16)
+
+* Accept MySQL charset (like `UTF8` or `UTF8MB4`) in `charset` option #808
+* Accept pool options in connection string to `mysql.createPool` #811
+* Clone connection config for new pool connections
+* Default `connectTimeout` to 2 minutes
+* Reject unauthorized SSL connections (use `ssl.rejectUnauthorized` to override) #816
+* Return last error when PoolCluster exhausts connection retries #818
+* Remove connection from pool after `conn.changeUser` is released #806
+* Throw on unknown SSL profile name #817
+* User newer TLS functions when available #809
+
+## v2.2.0 (2014-04-27)
+
+* Use indexOf instead of for loops removing conn from pool #611
+* Make callback to `pool.query` optional like `conn.query` #585
+* Prevent enqueuing sequences after fatal error #400
+* Fix geometry parser for empty fields #742
+* Accept lower-case charset option
+* Throw on unknown charset option #789
+* Update known charsets
+* Remove console.warn from PoolCluster #744
+* Fix `pool.end` to handle queued connections #797
+* Fix `pool.releaseConnection` to keep connection queue flowing #797
+* Fix SSL handshake error to  be catchable #800
+* Add `connection.threadId` to get MySQL connection ID #602
+* Ensure `pool.getConnection` retrieves good connections #434 #557 #778
+* Fix pool cluster wildcard matching #627
+* Pass query values through to `SqlString.format` #590
+
+## v2.1.1 (2014-03-13)
+
+* fix authentication w/password failure for node.js 0.10.5 #746 #752
+* fix authentication w/password TypeError exception for node.js 0.10.0-0.10.4 #747
+* fix specifying `values` in `conn.query({...}).on(...)` pattern #755
+* fix long stack trace to include the `pool.query(...)` call #715
+
+## v2.1.0 (2014-02-20)
+
+* crypto.createHash fix for node.js < 11 #735
+* Add `connectTimeout` option to specify a timeout for establishing a connection #726
+* SSL support #481
+
+## v2.0.1
+
+* internal parser speed improvement #702
+* domains support
+* 'trace' connection option to control if long stack traces are generated #713 #710 #439
+
+## v2.0.0 (2014-01-09)
+
+* stream improvements:
+  - node 0.8 support #692
+  - Emit 'close' events from query streams #688
+* encoding fix in streaming LOAD DATA LOCAL INFILE #670
+* Doc improvements
+
+## v2.0.0-rc2 (2013-12-07)
+
+* Streaming LOAD DATA LOCAL INFILE #668
+* Doc improvements
+
+## v2.0.0-rc1 (2013-11-30)
+
+* Transaction support
+* Expose SqlString.format as mysql.format()
+* Many bug fixes
+* Better support for dates in local time zone
+* Doc improvements
+
+## v2.0.0-alpha9 (2013-08-27)
+
+* Add query to pool to execute queries directly using the pool
+* Add `sqlState` property to `Error` objects #556
+* Pool option to set queue limit
+* Pool sends 'connection' event when it opens a new connection
+* Added stringifyObjects option to treat input as strings rather than objects (#501)
+* Support for poolClusters
+* Datetime improvements
+* Bug fixes
+
+## v2.0.0-alpha8 (2013-04-30)
+
+* Switch to old mode for Streams 2 (Node.js v 0.10.x)
+* Add stream method to Query Wraps events from the query object into a node v0.10.x Readable stream
+* DECIMAL should also be treated as big number
+* Removed slow unnecessary stack access
+* Added charsets
+* Added bigNumberStrings option for forcing BIGINT columns as strings
+* Changes date parsing to return String if not a valid JS Date
+* Adds support for ?? escape sequence to escape identifiers
+* Changes Auth.token() to force password to be in binary, not utf8 (#378)
+* Restrict debugging by packet types
+* Add 'multipleStatements' option tracking to ConnectionConfig. Fixes GH-408
+* Changes Pool to handle 'error' events and dispose connection
+* Allows db.query({ sql: "..." }, [ val1, ... ], cb); (#390)
+* Improved documentation
+* Bug fixes
+
+## v2.0.0-alpha7 (2013-02-03)
+
+* Add connection pooling (#351)
+
+## v2.0.0-alpha6 (2013-01-31)
+
+* Add supportBigNumbers option (#381, #382)
+* Accept prebuilt Query object in connection.query
+* Bug fixes
+
+## v2.0.0-alpha5 (2012-12-03)
+
+* Add mysql.escapeId to escape identifiers (closes #342)
+* Allow custom escaping mode (config.queryFormat)
+* Convert DATE columns to configured timezone instead of UTC (#332)
+* Convert LONGLONG and NEWDECIMAL to numbers (#333)
+* Fix Connection.escape() (fixes #330)
+* Changed Readme ambiguity about custom type cast fallback
+* Change typeCast to receive Connection instead of Connection.config.timezone
+* Fix drain event having useless err parameter
+* Add Connection.statistics() back from v0.9
+* Add Connection.ping() back from v0.9
+
+## v2.0.0-alpha4 (2012-10-03)
+
+* Fix some OOB errors on resume()
+* Fix quick pause() / resume() usage
+* Properly parse host denied / similar errors
+* Add Connection.ChangeUser functionality
+* Make sure changeUser errors are fatal
+* Enable formatting nested arrays for bulk inserts
+* Add Connection.escape functionality
+* Renamed 'close' to 'end' event
+* Return parsed object instead of Buffer for GEOMETRY types
+* Allow nestTables inline (using a string instead of a boolean)
+* Check for ZEROFILL_FLAG and format number accordingly
+* Add timezone support (default: local)
+* Add custom typeCast functionality
+* Export mysql column types
+* Add connection flags functionality (#237)
+* Exports drain event when queue finishes processing (#272, #271, #306)
+
+## v2.0.0-alpha3 (2012-06-12)
+
+* Implement support for `LOAD DATA LOCAL INFILE` queries (#182).
+* Support OLD\_PASSWORD() accounts like 0.9.x did. You should still upgrade any
+  user accounts in your your MySQL user table that has short (16 byte) Password
+  values. Connecting to those accounts is not secure. (#204)
+* Ignore function values when escaping objects, allows to use RowDataPacket
+  objects as query arguments. (Alex Gorbatchev, #213)
+* Handle initial error packets from server such as `ER_HOST_NOT_PRIVILEGED`.
+* Treat `utf8\_bin` as a String, not Buffer. (#214)
+* Handle empty strings in first row column value. (#222)
+* Honor Connection#nestTables setting for queries. (#221)
+* Remove `CLIENT_INTERACTIVE` flag from config. Improves #225.
+* Improve docs for connections settings.
+* Implement url string support for Connection configs.
+
+## v2.0.0-alpha2 (2012-05-31)
+
+* Specify escaping before for NaN / Infinity (they are as unquoted constants).
+* Support for unix domain socket connections (use: {socketPath: '...'}).
+* Fix type casting for NULL values for Date/Number fields
+* Add `fields` argument to `query()` as well as `'fields'` event. This is
+  similar to what was available in 0.9.x.
+* Support connecting to the sphinx searchd daemon as well as MariaDB (#199).
+* Implement long stack trace support, will be removed / disabled if the node
+  core ever supports it natively.
+* Implement `nestTables` option for queries, allows fetching JOIN result sets
+  with overlapping column names.
+* Fix ? placeholder mechanism for values containing '?' characters (#205).
+* Detect when `connect()` is called more than once on a connection and provide
+  the user with a good error message for it (#204).
+* Switch to `UTF8_GENERAL_CI` (previously `UTF8_UNICODE_CI`) as the default
+  charset for all connections to avoid strange MySQL performance issues (#200),
+  and also make the charset user configurable.
+* Fix BLOB type casting for `TINY_BLOB`, `MEDIUM_BLOB` and `LONG_BLOB`.
+* Add support for sending and receiving large (> 16 MB) packets.
+
+## v2.0.0-alpha (2012-05-15)
+
+This release is a rewrite. You should carefully test your application after
+upgrading to avoid problems. This release features many improvements, most
+importantly:
+
+* ~5x faster than v0.9.x for parsing query results
+* Support for pause() / resume() (for streaming rows)
+* Support for multiple statement queries
+* Support for stored procedures
+* Support for transactions
+* Support for binary columns (as blobs)
+* Consistent & well documented error handling
+* A new Connection class that has well defined semantics (unlike the old Client class).
+* Convenient escaping of objects / arrays that allows for simpler query construction
+* A significantly simpler code base
+* Many bug fixes & other small improvements (Closed 62 out of 66 GitHub issues)
+
+Below are a few notes on the upgrade process itself:
+
+The first thing you will run into is that the old `Client` class is gone and
+has been replaced with a less ambitious `Connection` class. So instead of
+`mysql.createClient()`, you now have to:
+
+```js
+var mysql      = require('mysql');
+var connection = mysql.createConnection({
+  host     : 'localhost',
+  user     : 'me',
+  password : 'secret',
+});
+
+connection.query('SELECT 1', function(err, rows) {
+  if (err) throw err;
+
+  console.log('Query result: ', rows);
+});
+
+connection.end();
+```
+
+The new `Connection` class does not try to handle re-connects, please study the
+`Server disconnects` section in the new Readme.
+
+Other than that, the interface has stayed very similar. Here are a few things
+to check out so:
+
+* BIGINT's are now cast into strings
+* Binary data is now cast to buffers
+* The `'row'` event on the `Query` object is now called `'result'` and will
+  also be emitted for queries that produce an OK/Error response.
+* Error handling is consistently defined now, check the Readme
+* Escaping has become more powerful which may break your code if you are
+  currently using objects to fill query placeholders.
+* Connections can now be established explicitly again, so you may wish to do so
+  if you want to handle connection errors specifically.
+
+That should be most of it, if you run into anything else, please send a patch
+or open an issue to improve this document.
+
+## v0.9.6 (2012-03-12)
+
+* Escape array values so they produce sql arrays (Roger Castells, Colin Smith)
+* docs: mention mysql transaction stop gap solution (Blake Miner)
+* docs: Mention affectedRows in FAQ (Michael Baldwin)
+
+## v0.9.5 (2011-11-26)
+
+* Fix #142 Driver stalls upon reconnect attempt that's immediately closed
+* Add travis build
+* Switch to urun as a test runner
+* Switch to utest for unit tests
+* Remove fast-or-slow dependency for tests
+* Split integration tests into individual files again
+
+## v0.9.4 (2011-08-31)
+
+* Expose package.json as `mysql.PACKAGE` (#104)
+
+## v0.9.3 (2011-08-22)
+
+* Set default `client.user` to root
+* Fix #91: Client#format should not mutate params array
+* Fix #94: TypeError in client.js
+* Parse decimals as string (vadimg)
+
+## v0.9.2 (2011-08-07)
+
+* The underlaying socket connection is now managed implicitly rather than explicitly.
+* Check the [upgrading guide][] for a full list of changes.
+
+## v0.9.1 (2011-02-20)
+
+* Fix issue #49 / `client.escape()` throwing exceptions on objects. (Nick Payne)
+* Drop < v0.4.x compatibility. From now on you need node v0.4.x to use this module.
+
+## Older releases
+
+These releases were done before maintaining this file:
+
+* [v0.9.0](https://github.com/mysqljs/mysql/compare/v0.8.0...v0.9.0)
+  (2011-01-04)
+* [v0.8.0](https://github.com/mysqljs/mysql/compare/v0.7.0...v0.8.0)
+  (2010-10-30)
+* [v0.7.0](https://github.com/mysqljs/mysql/compare/v0.6.0...v0.7.0)
+  (2010-10-14)
+* [v0.6.0](https://github.com/mysqljs/mysql/compare/v0.5.0...v0.6.0)
+  (2010-09-28)
+* [v0.5.0](https://github.com/mysqljs/mysql/compare/v0.4.0...v0.5.0)
+  (2010-09-17)
+* [v0.4.0](https://github.com/mysqljs/mysql/compare/v0.3.0...v0.4.0)
+  (2010-09-02)
+* [v0.3.0](https://github.com/mysqljs/mysql/compare/v0.2.0...v0.3.0)
+  (2010-08-25)
+* [v0.2.0](https://github.com/mysqljs/mysql/compare/v0.1.0...v0.2.0)
+  (2010-08-22)
+* [v0.1.0](https://github.com/mysqljs/mysql/commits/v0.1.0)
+  (2010-08-22)

+ 54 - 0
test_two_list/ClientAuthenticationPacket.js

@@ -0,0 +1,54 @@
+var Buffer = require('safe-buffer').Buffer;
+
+module.exports = ClientAuthenticationPacket;
+function ClientAuthenticationPacket(options) {
+  options = options || {};
+
+  this.clientFlags   = options.clientFlags;
+  this.maxPacketSize = options.maxPacketSize;
+  this.charsetNumber = options.charsetNumber;
+  this.filler        = undefined;
+  this.user          = options.user;
+  this.scrambleBuff  = options.scrambleBuff;
+  this.database      = options.database;
+  this.protocol41    = options.protocol41;
+}
+
+ClientAuthenticationPacket.prototype.parse = function(parser) {
+  if (this.protocol41) {
+    this.clientFlags   = parser.parseUnsignedNumber(4);
+    this.maxPacketSize = parser.parseUnsignedNumber(4);
+    this.charsetNumber = parser.parseUnsignedNumber(1);
+    this.filler        = parser.parseFiller(23);
+    this.user          = parser.parseNullTerminatedString();
+    this.scrambleBuff  = parser.parseLengthCodedBuffer();
+    this.database      = parser.parseNullTerminatedString();
+  } else {
+    this.clientFlags   = parser.parseUnsignedNumber(2);
+    this.maxPacketSize = parser.parseUnsignedNumber(3);
+    this.user          = parser.parseNullTerminatedString();
+    this.scrambleBuff  = parser.parseBuffer(8);
+    this.database      = parser.parseLengthCodedBuffer();
+  }
+};
+
+ClientAuthenticationPacket.prototype.write = function(writer) {
+  if (this.protocol41) {
+    writer.writeUnsignedNumber(4, this.clientFlags);
+    writer.writeUnsignedNumber(4, this.maxPacketSize);
+    writer.writeUnsignedNumber(1, this.charsetNumber);
+    writer.writeFiller(23);
+    writer.writeNullTerminatedString(this.user);
+    writer.writeLengthCodedBuffer(this.scrambleBuff);
+    writer.writeNullTerminatedString(this.database);
+  } else {
+    writer.writeUnsignedNumber(2, this.clientFlags);
+    writer.writeUnsignedNumber(3, this.maxPacketSize);
+    writer.writeNullTerminatedString(this.user);
+    writer.writeBuffer(this.scrambleBuff);
+    if (this.database && this.database.length) {
+      writer.writeFiller(1);
+      writer.writeBuffer(Buffer.from(this.database));
+    }
+  }
+};

+ 26 - 0
test_two_list/ComChangeUserPacket.js

@@ -0,0 +1,26 @@
+module.exports = ComChangeUserPacket;
+function ComChangeUserPacket(options) {
+  options = options || {};
+
+  this.command       = 0x11;
+  this.user          = options.user;
+  this.scrambleBuff  = options.scrambleBuff;
+  this.database      = options.database;
+  this.charsetNumber = options.charsetNumber;
+}
+
+ComChangeUserPacket.prototype.parse = function(parser) {
+  this.command       = parser.parseUnsignedNumber(1);
+  this.user          = parser.parseNullTerminatedString();
+  this.scrambleBuff  = parser.parseLengthCodedBuffer();
+  this.database      = parser.parseNullTerminatedString();
+  this.charsetNumber = parser.parseUnsignedNumber(1);
+};
+
+ComChangeUserPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, this.command);
+  writer.writeNullTerminatedString(this.user);
+  writer.writeLengthCodedBuffer(this.scrambleBuff);
+  writer.writeNullTerminatedString(this.database);
+  writer.writeUnsignedNumber(2, this.charsetNumber);
+};

+ 12 - 0
test_two_list/ComPingPacket.js

@@ -0,0 +1,12 @@
+module.exports = ComPingPacket;
+function ComPingPacket() {
+  this.command = 0x0e;
+}
+
+ComPingPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, this.command);
+};
+
+ComPingPacket.prototype.parse = function(parser) {
+  this.command = parser.parseUnsignedNumber(1);
+};

+ 15 - 0
test_two_list/ComQueryPacket.js

@@ -0,0 +1,15 @@
+module.exports = ComQueryPacket;
+function ComQueryPacket(sql) {
+  this.command = 0x03;
+  this.sql     = sql;
+}
+
+ComQueryPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, this.command);
+  writer.writeString(this.sql);
+};
+
+ComQueryPacket.prototype.parse = function(parser) {
+  this.command = parser.parseUnsignedNumber(1);
+  this.sql     = parser.parsePacketTerminatedString();
+};

+ 12 - 0
test_two_list/ComQuitPacket.js

@@ -0,0 +1,12 @@
+module.exports = ComQuitPacket;
+function ComQuitPacket() {
+  this.command = 0x01;
+}
+
+ComQuitPacket.prototype.parse = function parse(parser) {
+  this.command = parser.parseUnsignedNumber(1);
+};
+
+ComQuitPacket.prototype.write = function write(writer) {
+  writer.writeUnsignedNumber(1, this.command);
+};

+ 12 - 0
test_two_list/ComStatisticsPacket.js

@@ -0,0 +1,12 @@
+module.exports = ComStatisticsPacket;
+function ComStatisticsPacket() {
+  this.command = 0x09;
+}
+
+ComStatisticsPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, this.command);
+};
+
+ComStatisticsPacket.prototype.parse = function(parser) {
+  this.command = parser.parseUnsignedNumber(1);
+};

+ 529 - 0
test_two_list/Connection.js

@@ -0,0 +1,529 @@
+var Crypto           = require('crypto');
+var Events           = require('events');
+var Net              = require('net');
+var tls              = require('tls');
+var ConnectionConfig = require('./ConnectionConfig');
+var Protocol         = require('./protocol/Protocol');
+var SqlString        = require('./protocol/SqlString');
+var Query            = require('./protocol/sequences/Query');
+var Util             = require('util');
+
+module.exports = Connection;
+Util.inherits(Connection, Events.EventEmitter);
+function Connection(options) {
+  Events.EventEmitter.call(this);
+
+  this.config = options.config;
+
+  this._socket        = options.socket;
+  this._protocol      = new Protocol({config: this.config, connection: this});
+  this._connectCalled = false;
+  this.state          = 'disconnected';
+  this.threadId       = null;
+}
+
+Connection.createQuery = function createQuery(sql, values, callback) {
+  if (sql instanceof Query) {
+    return sql;
+  }
+
+  var cb      = callback;
+  var options = {};
+
+  if (typeof sql === 'function') {
+    cb = sql;
+  } else if (typeof sql === 'object') {
+    options = Object.create(sql);
+
+    if (typeof values === 'function') {
+      cb = values;
+    } else if (values !== undefined) {
+      Object.defineProperty(options, 'values', { value: values });
+    }
+  } else {
+    options.sql = sql;
+
+    if (typeof values === 'function') {
+      cb = values;
+    } else if (values !== undefined) {
+      options.values = values;
+    }
+  }
+
+  if (cb !== undefined) {
+    cb = wrapCallbackInDomain(null, cb);
+
+    if (cb === undefined) {
+      throw new TypeError('argument callback must be a function when provided');
+    }
+  }
+
+  return new Query(options, cb);
+};
+
+Connection.prototype.connect = function connect(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  if (!this._connectCalled) {
+    this._connectCalled = true;
+
+    // Connect either via a UNIX domain socket or a TCP socket.
+    this._socket = (this.config.socketPath)
+      ? Net.createConnection(this.config.socketPath)
+      : Net.createConnection(this.config.port, this.config.host);
+
+    // Connect socket to connection domain
+    if (Events.usingDomains) {
+      this._socket.domain = this.domain;
+    }
+
+    var connection = this;
+    this._protocol.on('data', function(data) {
+      connection._socket.write(data);
+    });
+    this._socket.on('data', wrapToDomain(connection, function (data) {
+      connection._protocol.write(data);
+    }));
+    this._protocol.on('end', function() {
+      connection._socket.end();
+    });
+    this._socket.on('end', wrapToDomain(connection, function () {
+      connection._protocol.end();
+    }));
+
+    this._socket.on('error', this._handleNetworkError.bind(this));
+    this._socket.on('connect', this._handleProtocolConnect.bind(this));
+    this._protocol.on('handshake', this._handleProtocolHandshake.bind(this));
+    this._protocol.on('initialize', this._handleProtocolInitialize.bind(this));
+    this._protocol.on('unhandledError', this._handleProtocolError.bind(this));
+    this._protocol.on('drain', this._handleProtocolDrain.bind(this));
+    this._protocol.on('end', this._handleProtocolEnd.bind(this));
+    this._protocol.on('enqueue', this._handleProtocolEnqueue.bind(this));
+
+    if (this.config.connectTimeout) {
+      var handleConnectTimeout = this._handleConnectTimeout.bind(this);
+
+      this._socket.setTimeout(this.config.connectTimeout, handleConnectTimeout);
+      this._socket.once('connect', function() {
+        this.setTimeout(0, handleConnectTimeout);
+      });
+    }
+  }
+
+  this._protocol.handshake(options, wrapCallbackInDomain(this, callback));
+};
+
+Connection.prototype.changeUser = function changeUser(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  this._implyConnect();
+
+  var charsetNumber = (options.charset)
+    ? ConnectionConfig.getCharsetNumber(options.charset)
+    : this.config.charsetNumber;
+
+  return this._protocol.changeUser({
+    user          : options.user || this.config.user,
+    password      : options.password || this.config.password,
+    database      : options.database || this.config.database,
+    timeout       : options.timeout,
+    charsetNumber : charsetNumber,
+    currentConfig : this.config
+  }, wrapCallbackInDomain(this, callback));
+};
+
+Connection.prototype.beginTransaction = function beginTransaction(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  options = options || {};
+  options.sql = 'START TRANSACTION';
+  options.values = null;
+
+  return this.query(options, callback);
+};
+
+Connection.prototype.commit = function commit(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  options = options || {};
+  options.sql = 'COMMIT';
+  options.values = null;
+
+  return this.query(options, callback);
+};
+
+Connection.prototype.rollback = function rollback(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  options = options || {};
+  options.sql = 'ROLLBACK';
+  options.values = null;
+
+  return this.query(options, callback);
+};
+
+Connection.prototype.query = function query(sql, values, cb) {
+  var query = Connection.createQuery(sql, values, cb);
+  query._connection = this;
+
+  if (!(typeof sql === 'object' && 'typeCast' in sql)) {
+    query.typeCast = this.config.typeCast;
+  }
+
+  if (query.sql) {
+    query.sql = this.format(query.sql, query.values);
+  }
+
+  if (query._callback) {
+    query._callback = wrapCallbackInDomain(this, query._callback);
+  }
+
+  this._implyConnect();
+
+  return this._protocol._enqueue(query);
+};
+
+Connection.prototype.ping = function ping(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  this._implyConnect();
+  this._protocol.ping(options, wrapCallbackInDomain(this, callback));
+};
+
+Connection.prototype.statistics = function statistics(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  this._implyConnect();
+  this._protocol.stats(options, wrapCallbackInDomain(this, callback));
+};
+
+Connection.prototype.end = function end(options, callback) {
+  var cb   = callback;
+  var opts = options;
+
+  if (!callback && typeof options === 'function') {
+    cb   = options;
+    opts = null;
+  }
+
+  // create custom options reference
+  opts = Object.create(opts || null);
+
+  if (opts.timeout === undefined) {
+    // default timeout of 30 seconds
+    opts.timeout = 30000;
+  }
+
+  this._implyConnect();
+  this._protocol.quit(opts, wrapCallbackInDomain(this, cb));
+};
+
+Connection.prototype.destroy = function() {
+  this.state = 'disconnected';
+  this._implyConnect();
+  this._socket.destroy();
+  this._protocol.destroy();
+};
+
+Connection.prototype.pause = function() {
+  this._socket.pause();
+  this._protocol.pause();
+};
+
+Connection.prototype.resume = function() {
+  this._socket.resume();
+  this._protocol.resume();
+};
+
+Connection.prototype.escape = function(value) {
+  return SqlString.escape(value, false, this.config.timezone);
+};
+
+Connection.prototype.escapeId = function escapeId(value) {
+  return SqlString.escapeId(value, false);
+};
+
+Connection.prototype.format = function(sql, values) {
+  if (typeof this.config.queryFormat === 'function') {
+    return this.config.queryFormat.call(this, sql, values, this.config.timezone);
+  }
+  return SqlString.format(sql, values, this.config.stringifyObjects, this.config.timezone);
+};
+
+if (tls.TLSSocket) {
+  // 0.11+ environment
+  Connection.prototype._startTLS = function _startTLS(onSecure) {
+    var connection = this;
+
+    createSecureContext(this.config, function (err, secureContext) {
+      if (err) {
+        onSecure(err);
+        return;
+      }
+
+      // "unpipe"
+      connection._socket.removeAllListeners('data');
+      connection._protocol.removeAllListeners('data');
+
+      // socket <-> encrypted
+      var rejectUnauthorized = connection.config.ssl.rejectUnauthorized;
+      var secureEstablished  = false;
+      var secureSocket       = new tls.TLSSocket(connection._socket, {
+        rejectUnauthorized : rejectUnauthorized,
+        requestCert        : true,
+        secureContext      : secureContext,
+        isServer           : false
+      });
+
+      // error handler for secure socket
+      secureSocket.on('_tlsError', function(err) {
+        if (secureEstablished) {
+          connection._handleNetworkError(err);
+        } else {
+          onSecure(err);
+        }
+      });
+
+      // cleartext <-> protocol
+      secureSocket.pipe(connection._protocol);
+      connection._protocol.on('data', function(data) {
+        secureSocket.write(data);
+      });
+
+      secureSocket.on('secure', function() {
+        secureEstablished = true;
+
+        onSecure(rejectUnauthorized ? this.ssl.verifyError() : null);
+      });
+
+      // start TLS communications
+      secureSocket._start();
+    });
+  };
+} else {
+  // pre-0.11 environment
+  Connection.prototype._startTLS = function _startTLS(onSecure) {
+    // before TLS:
+    //  _socket <-> _protocol
+    // after:
+    //  _socket <-> securePair.encrypted <-> securePair.cleartext <-> _protocol
+
+    var connection  = this;
+    var credentials = Crypto.createCredentials({
+      ca         : this.config.ssl.ca,
+      cert       : this.config.ssl.cert,
+      ciphers    : this.config.ssl.ciphers,
+      key        : this.config.ssl.key,
+      passphrase : this.config.ssl.passphrase
+    });
+
+    var rejectUnauthorized = this.config.ssl.rejectUnauthorized;
+    var secureEstablished  = false;
+    var securePair         = tls.createSecurePair(credentials, false, true, rejectUnauthorized);
+
+    // error handler for secure pair
+    securePair.on('error', function(err) {
+      if (secureEstablished) {
+        connection._handleNetworkError(err);
+      } else {
+        onSecure(err);
+      }
+    });
+
+    // "unpipe"
+    this._socket.removeAllListeners('data');
+    this._protocol.removeAllListeners('data');
+
+    // socket <-> encrypted
+    securePair.encrypted.pipe(this._socket);
+    this._socket.on('data', function(data) {
+      securePair.encrypted.write(data);
+    });
+
+    // cleartext <-> protocol
+    securePair.cleartext.pipe(this._protocol);
+    this._protocol.on('data', function(data) {
+      securePair.cleartext.write(data);
+    });
+
+    // secure established
+    securePair.on('secure', function() {
+      secureEstablished = true;
+
+      if (!rejectUnauthorized) {
+        onSecure();
+        return;
+      }
+
+      var verifyError = this.ssl.verifyError();
+      var err = verifyError;
+
+      // node.js 0.6 support
+      if (typeof err === 'string') {
+        err = new Error(verifyError);
+        err.code = verifyError;
+      }
+
+      onSecure(err);
+    });
+
+    // node.js 0.8 bug
+    securePair._cycle = securePair.cycle;
+    securePair.cycle  = function cycle() {
+      if (this.ssl && this.ssl.error) {
+        this.error();
+      }
+
+      return this._cycle.apply(this, arguments);
+    };
+  };
+}
+
+Connection.prototype._handleConnectTimeout = function() {
+  if (this._socket) {
+    this._socket.setTimeout(0);
+    this._socket.destroy();
+  }
+
+  var err = new Error('connect ETIMEDOUT');
+  err.errorno = 'ETIMEDOUT';
+  err.code = 'ETIMEDOUT';
+  err.syscall = 'connect';
+
+  this._handleNetworkError(err);
+};
+
+Connection.prototype._handleNetworkError = function(err) {
+  this._protocol.handleNetworkError(err);
+};
+
+Connection.prototype._handleProtocolError = function(err) {
+  this.state = 'protocol_error';
+  this.emit('error', err);
+};
+
+Connection.prototype._handleProtocolDrain = function() {
+  this.emit('drain');
+};
+
+Connection.prototype._handleProtocolConnect = function() {
+  this.state = 'connected';
+  this.emit('connect');
+};
+
+Connection.prototype._handleProtocolHandshake = function _handleProtocolHandshake() {
+  this.state = 'authenticated';
+};
+
+Connection.prototype._handleProtocolInitialize = function _handleProtocolInitialize(packet) {
+  this.threadId = packet.threadId;
+};
+
+Connection.prototype._handleProtocolEnd = function(err) {
+  this.state = 'disconnected';
+  this.emit('end', err);
+};
+
+Connection.prototype._handleProtocolEnqueue = function _handleProtocolEnqueue(sequence) {
+  this.emit('enqueue', sequence);
+};
+
+Connection.prototype._implyConnect = function() {
+  if (!this._connectCalled) {
+    this.connect();
+  }
+};
+
+function createSecureContext (config, cb) {
+  var context = null;
+  var error   = null;
+
+  try {
+    context = tls.createSecureContext({
+      ca         : config.ssl.ca,
+      cert       : config.ssl.cert,
+      ciphers    : config.ssl.ciphers,
+      key        : config.ssl.key,
+      passphrase : config.ssl.passphrase
+    });
+  } catch (err) {
+    error = err;
+  }
+
+  cb(error, context);
+}
+
+function unwrapFromDomain(fn) {
+  return function () {
+    var domains = [];
+    var ret;
+
+    while (process.domain) {
+      domains.shift(process.domain);
+      process.domain.exit();
+    }
+
+    try {
+      ret = fn.apply(this, arguments);
+    } finally {
+      for (var i = 0; i < domains.length; i++) {
+        domains[i].enter();
+      }
+    }
+
+    return ret;
+  };
+}
+
+function wrapCallbackInDomain(ee, fn) {
+  if (typeof fn !== 'function') {
+    return undefined;
+  }
+
+  if (fn.domain) {
+    return fn;
+  }
+
+  var domain = process.domain;
+
+  if (domain) {
+    return domain.bind(fn);
+  } else if (ee) {
+    return unwrapFromDomain(wrapToDomain(ee, fn));
+  } else {
+    return fn;
+  }
+}
+
+function wrapToDomain(ee, fn) {
+  return function () {
+    if (Events.usingDomains && ee.domain) {
+      ee.domain.enter();
+      fn.apply(this, arguments);
+      ee.domain.exit();
+    } else {
+      fn.apply(this, arguments);
+    }
+  };
+}

+ 209 - 0
test_two_list/ConnectionConfig.js

@@ -0,0 +1,209 @@
+var urlParse        = require('url').parse;
+var ClientConstants = require('./protocol/constants/client');
+var Charsets        = require('./protocol/constants/charsets');
+var SSLProfiles     = null;
+
+module.exports = ConnectionConfig;
+function ConnectionConfig(options) {
+  if (typeof options === 'string') {
+    options = ConnectionConfig.parseUrl(options);
+  }
+
+  this.host               = options.host || 'localhost';
+  this.port               = options.port || 3306;
+  this.localAddress       = options.localAddress;
+  this.socketPath         = options.socketPath;
+  this.user               = options.user || undefined;
+  this.password           = options.password || undefined;
+  this.database           = options.database;
+  this.connectTimeout     = (options.connectTimeout === undefined)
+    ? (10 * 1000)
+    : options.connectTimeout;
+  this.insecureAuth       = options.insecureAuth || false;
+  this.supportBigNumbers  = options.supportBigNumbers || false;
+  this.bigNumberStrings   = options.bigNumberStrings || false;
+  this.dateStrings        = options.dateStrings || false;
+  this.debug              = options.debug;
+  this.trace              = options.trace !== false;
+  this.stringifyObjects   = options.stringifyObjects || false;
+  this.timezone           = options.timezone || 'local';
+  this.flags              = options.flags || '';
+  this.queryFormat        = options.queryFormat;
+  this.pool               = options.pool || undefined;
+  this.ssl                = (typeof options.ssl === 'string')
+    ? ConnectionConfig.getSSLProfile(options.ssl)
+    : (options.ssl || false);
+  this.localInfile        = (options.localInfile === undefined)
+    ? true
+    : options.localInfile;
+  this.multipleStatements = options.multipleStatements || false;
+  this.typeCast           = (options.typeCast === undefined)
+    ? true
+    : options.typeCast;
+
+  if (this.timezone[0] === ' ') {
+    // "+" is a url encoded char for space so it
+    // gets translated to space when giving a
+    // connection string..
+    this.timezone = '+' + this.timezone.substr(1);
+  }
+
+  if (this.ssl) {
+    // Default rejectUnauthorized to true
+    this.ssl.rejectUnauthorized = this.ssl.rejectUnauthorized !== false;
+  }
+
+  this.maxPacketSize = 0;
+  this.charsetNumber = (options.charset)
+    ? ConnectionConfig.getCharsetNumber(options.charset)
+    : options.charsetNumber || Charsets.UTF8_GENERAL_CI;
+
+  // Set the client flags
+  var defaultFlags = ConnectionConfig.getDefaultFlags(options);
+  this.clientFlags = ConnectionConfig.mergeFlags(defaultFlags, options.flags);
+}
+
+ConnectionConfig.mergeFlags = function mergeFlags(defaultFlags, userFlags) {
+  var allFlags = ConnectionConfig.parseFlagList(defaultFlags);
+  var newFlags = ConnectionConfig.parseFlagList(userFlags);
+
+  // Merge the new flags
+  for (var flag in newFlags) {
+    if (allFlags[flag] !== false) {
+      allFlags[flag] = newFlags[flag];
+    }
+  }
+
+  // Build flags
+  var flags = 0x0;
+  for (var flag in allFlags) {
+    if (allFlags[flag]) {
+      // TODO: Throw here on some future release
+      flags |= ClientConstants['CLIENT_' + flag] || 0x0;
+    }
+  }
+
+  return flags;
+};
+
+ConnectionConfig.getCharsetNumber = function getCharsetNumber(charset) {
+  var num = Charsets[charset.toUpperCase()];
+
+  if (num === undefined) {
+    throw new TypeError('Unknown charset \'' + charset + '\'');
+  }
+
+  return num;
+};
+
+ConnectionConfig.getDefaultFlags = function getDefaultFlags(options) {
+  var defaultFlags = [
+    '-COMPRESS',          // Compression protocol *NOT* supported
+    '-CONNECT_ATTRS',     // Does *NOT* send connection attributes in Protocol::HandshakeResponse41
+    '+CONNECT_WITH_DB',   // One can specify db on connect in Handshake Response Packet
+    '+FOUND_ROWS',        // Send found rows instead of affected rows
+    '+IGNORE_SIGPIPE',    // Don't issue SIGPIPE if network failures
+    '+IGNORE_SPACE',      // Let the parser ignore spaces before '('
+    '+LOCAL_FILES',       // Can use LOAD DATA LOCAL
+    '+LONG_FLAG',         // Longer flags in Protocol::ColumnDefinition320
+    '+LONG_PASSWORD',     // Use the improved version of Old Password Authentication
+    '+MULTI_RESULTS',     // Can handle multiple resultsets for COM_QUERY
+    '+ODBC',              // Special handling of ODBC behaviour
+    '-PLUGIN_AUTH',       // Does *NOT* support auth plugins
+    '+PROTOCOL_41',       // Uses the 4.1 protocol
+    '+PS_MULTI_RESULTS',  // Can handle multiple resultsets for COM_STMT_EXECUTE
+    '+RESERVED',          // Unused
+    '+SECURE_CONNECTION', // Supports Authentication::Native41
+    '+TRANSACTIONS'       // Expects status flags
+  ];
+
+  if (options && options.localInfile !== undefined && !options.localInfile) {
+    // Disable LOCAL modifier for LOAD DATA INFILE
+    defaultFlags.push('-LOCAL_FILES');
+  }
+
+  if (options && options.multipleStatements) {
+    // May send multiple statements per COM_QUERY and COM_STMT_PREPARE
+    defaultFlags.push('+MULTI_STATEMENTS');
+  }
+
+  return defaultFlags;
+};
+
+ConnectionConfig.getSSLProfile = function getSSLProfile(name) {
+  if (!SSLProfiles) {
+    SSLProfiles = require('./protocol/constants/ssl_profiles');
+  }
+
+  var ssl = SSLProfiles[name];
+
+  if (ssl === undefined) {
+    throw new TypeError('Unknown SSL profile \'' + name + '\'');
+  }
+
+  return ssl;
+};
+
+ConnectionConfig.parseFlagList = function parseFlagList(flagList) {
+  var allFlags = Object.create(null);
+
+  if (!flagList) {
+    return allFlags;
+  }
+
+  var flags = !Array.isArray(flagList)
+    ? String(flagList || '').toUpperCase().split(/\s*,+\s*/)
+    : flagList;
+
+  for (var i = 0; i < flags.length; i++) {
+    var flag   = flags[i];
+    var offset = 1;
+    var state  = flag[0];
+
+    if (state === undefined) {
+      // TODO: throw here on some future release
+      continue;
+    }
+
+    if (state !== '-' && state !== '+') {
+      offset = 0;
+      state  = '+';
+    }
+
+    allFlags[flag.substr(offset)] = state === '+';
+  }
+
+  return allFlags;
+};
+
+ConnectionConfig.parseUrl = function(url) {
+  url = urlParse(url, true);
+
+  var options = {
+    host     : url.hostname,
+    port     : url.port,
+    database : url.pathname.substr(1)
+  };
+
+  if (url.auth) {
+    var auth = url.auth.split(':');
+    options.user     = auth.shift();
+    options.password = auth.join(':');
+  }
+
+  if (url.query) {
+    for (var key in url.query) {
+      var value = url.query[key];
+
+      try {
+        // Try to parse this as a JSON expression first
+        options[key] = JSON.parse(value);
+      } catch (err) {
+        // Otherwise assume it is a plain string
+        options[key] = value;
+      }
+    }
+  }
+
+  return options;
+};

+ 9 - 0
test_two_list/EmptyPacket.js

@@ -0,0 +1,9 @@
+module.exports = EmptyPacket;
+function EmptyPacket() {
+}
+
+EmptyPacket.prototype.parse = function parse() {
+};
+
+EmptyPacket.prototype.write = function write() {
+};

+ 25 - 0
test_two_list/EofPacket.js

@@ -0,0 +1,25 @@
+module.exports = EofPacket;
+function EofPacket(options) {
+  options = options || {};
+
+  this.fieldCount   = undefined;
+  this.warningCount = options.warningCount;
+  this.serverStatus = options.serverStatus;
+  this.protocol41   = options.protocol41;
+}
+
+EofPacket.prototype.parse = function(parser) {
+  this.fieldCount   = parser.parseUnsignedNumber(1);
+  if (this.protocol41) {
+    this.warningCount = parser.parseUnsignedNumber(2);
+    this.serverStatus = parser.parseUnsignedNumber(2);
+  }
+};
+
+EofPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, 0xfe);
+  if (this.protocol41) {
+    writer.writeUnsignedNumber(2, this.warningCount);
+    writer.writeUnsignedNumber(2, this.serverStatus);
+  }
+};

+ 35 - 0
test_two_list/ErrorPacket.js

@@ -0,0 +1,35 @@
+module.exports = ErrorPacket;
+function ErrorPacket(options) {
+  options = options || {};
+
+  this.fieldCount     = options.fieldCount;
+  this.errno          = options.errno;
+  this.sqlStateMarker = options.sqlStateMarker;
+  this.sqlState       = options.sqlState;
+  this.message        = options.message;
+}
+
+ErrorPacket.prototype.parse = function(parser) {
+  this.fieldCount = parser.parseUnsignedNumber(1);
+  this.errno      = parser.parseUnsignedNumber(2);
+
+  // sqlStateMarker ('#' = 0x23) indicates error packet format
+  if (parser.peak() === 0x23) {
+    this.sqlStateMarker = parser.parseString(1);
+    this.sqlState       = parser.parseString(5);
+  }
+
+  this.message = parser.parsePacketTerminatedString();
+};
+
+ErrorPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, 0xff);
+  writer.writeUnsignedNumber(2, this.errno);
+
+  if (this.sqlStateMarker) {
+    writer.writeString(this.sqlStateMarker);
+    writer.writeString(this.sqlState);
+  }
+
+  writer.writeString(this.message);
+};

+ 26 - 0
test_two_list/Field.js

@@ -0,0 +1,26 @@
+var Types = require('../constants/types');
+
+module.exports = Field;
+function Field(options) {
+  options = options || {};
+
+  this.parser = options.parser;
+  this.packet = options.packet;
+  this.db     = options.packet.db;
+  this.table  = options.packet.table;
+  this.name   = options.packet.name;
+  this.type   = Types[options.packet.type];
+  this.length = options.packet.length;
+}
+
+Field.prototype.string = function () {
+  return this.parser.parseLengthCodedString();
+};
+
+Field.prototype.buffer = function () {
+  return this.parser.parseLengthCodedBuffer();
+};
+
+Field.prototype.geometry = function () {
+  return this.parser.parseGeometryValue();
+};

+ 93 - 0
test_two_list/FieldPacket.js

@@ -0,0 +1,93 @@
+module.exports = FieldPacket;
+function FieldPacket(options) {
+  options = options || {};
+
+  this.catalog    = options.catalog;
+  this.db         = options.db;
+  this.table      = options.table;
+  this.orgTable   = options.orgTable;
+  this.name       = options.name;
+  this.orgName    = options.orgName;
+  this.charsetNr  = options.charsetNr;
+  this.length     = options.length;
+  this.type       = options.type;
+  this.flags      = options.flags;
+  this.decimals   = options.decimals;
+  this.default    = options.default;
+  this.zeroFill   = options.zeroFill;
+  this.protocol41 = options.protocol41;
+}
+
+FieldPacket.prototype.parse = function(parser) {
+  if (this.protocol41) {
+    this.catalog     = parser.parseLengthCodedString();
+    this.db          = parser.parseLengthCodedString();
+    this.table       = parser.parseLengthCodedString();
+    this.orgTable    = parser.parseLengthCodedString();
+    this.name        = parser.parseLengthCodedString();
+    this.orgName     = parser.parseLengthCodedString();
+
+    if (parser.parseLengthCodedNumber() !== 0x0c) {
+      var err  = new TypeError('Received invalid field length');
+      err.code = 'PARSER_INVALID_FIELD_LENGTH';
+      throw err;
+    }
+
+    this.charsetNr   = parser.parseUnsignedNumber(2);
+    this.length      = parser.parseUnsignedNumber(4);
+    this.type        = parser.parseUnsignedNumber(1);
+    this.flags       = parser.parseUnsignedNumber(2);
+    this.decimals    = parser.parseUnsignedNumber(1);
+
+    var filler       = parser.parseBuffer(2);
+    if (filler[0] !== 0x0 || filler[1] !== 0x0) {
+      var err  = new TypeError('Received invalid filler');
+      err.code = 'PARSER_INVALID_FILLER';
+      throw err;
+    }
+
+    // parsed flags
+    this.zeroFill    = (this.flags & 0x0040 ? true : false);
+
+    if (parser.reachedPacketEnd()) {
+      return;
+    }
+
+    this.default     = parser.parseLengthCodedString();
+  } else {
+    this.table       = parser.parseLengthCodedString();
+    this.name        = parser.parseLengthCodedString();
+    this.length      = parser.parseUnsignedNumber(parser.parseUnsignedNumber(1));
+    this.type        = parser.parseUnsignedNumber(parser.parseUnsignedNumber(1));
+  }
+};
+
+FieldPacket.prototype.write = function(writer) {
+  if (this.protocol41) {
+    writer.writeLengthCodedString(this.catalog);
+    writer.writeLengthCodedString(this.db);
+    writer.writeLengthCodedString(this.table);
+    writer.writeLengthCodedString(this.orgTable);
+    writer.writeLengthCodedString(this.name);
+    writer.writeLengthCodedString(this.orgName);
+
+    writer.writeLengthCodedNumber(0x0c);
+    writer.writeUnsignedNumber(2, this.charsetNr || 0);
+    writer.writeUnsignedNumber(4, this.length || 0);
+    writer.writeUnsignedNumber(1, this.type || 0);
+    writer.writeUnsignedNumber(2, this.flags || 0);
+    writer.writeUnsignedNumber(1, this.decimals || 0);
+    writer.writeFiller(2);
+
+    if (this.default !== undefined) {
+      writer.writeLengthCodedString(this.default);
+    }
+  } else {
+    writer.writeLengthCodedString(this.table);
+    writer.writeLengthCodedString(this.name);
+    writer.writeUnsignedNumber(1, 0x01);
+    writer.writeUnsignedNumber(1, this.length);
+    writer.writeUnsignedNumber(1, 0x01);
+    writer.writeUnsignedNumber(1, this.type);
+  }
+};

+ 136 - 0
test_two_list/GOVERNANCE.md

@@ -0,0 +1,136 @@
+### Streams Working Group
+
+The Node.js Streams is jointly governed by a Working Group
+(WG)
+that is responsible for high-level guidance of the project.
+
+The WG has final authority over this project including:
+
+* Technical direction
+* Project governance and process (including this policy)
+* Contribution policy
+* GitHub repository hosting
+* Conduct guidelines
+* Maintaining the list of additional Collaborators
+
+For the current list of WG members, see the project
+[README.md](./README.md#current-project-team-members).
+
+### Collaborators
+
+The readable-stream GitHub repository is
+maintained by the WG and additional Collaborators who are added by the
+WG on an ongoing basis.
+
+Individuals making significant and valuable contributions are made
+Collaborators and given commit-access to the project. These
+individuals are identified by the WG and their addition as
+Collaborators is discussed during the WG meeting.
+
+_Note:_ If you make a significant contribution and are not considered
+for commit-access log an issue or contact a WG member directly and it
+will be brought up in the next WG meeting.
+
+Modifications of the contents of the readable-stream repository are
+made on
+a collaborative basis. Anybody with a GitHub account may propose a
+modification via pull request and it will be considered by the project
+Collaborators. All pull requests must be reviewed and accepted by a
+Collaborator with sufficient expertise who is able to take full
+responsibility for the change. In the case of pull requests proposed
+by an existing Collaborator, an additional Collaborator is required
+for sign-off. Consensus should be sought if additional Collaborators
+participate and there is disagreement around a particular
+modification. See _Consensus Seeking Process_ below for further detail
+on the consensus model used for governance.
+
+Collaborators may opt to elevate significant or controversial
+modifications, or modifications that have not found consensus to the
+WG for discussion by assigning the ***WG-agenda*** tag to a pull
+request or issue. The WG should serve as the final arbiter where
+required.
+
+For the current list of Collaborators, see the project
+[README.md](./README.md#members).
+
+### WG Membership
+
+WG seats are not time-limited.  There is no fixed size of the WG.
+However, the expected target is between 6 and 12, to ensure adequate
+coverage of important areas of expertise, balanced with the ability to
+make decisions efficiently.
+
+There is no specific set of requirements or qualifications for WG
+membership beyond these rules.
+
+The WG may add additional members to the WG by unanimous consensus.
+
+A WG member may be removed from the WG by voluntary resignation, or by
+unanimous consensus of all other WG members.
+
+Changes to WG membership should be posted in the agenda, and may be
+suggested as any other agenda item (see "WG Meetings" below).
+
+If an addition or removal is proposed during a meeting, and the full
+WG is not in attendance to participate, then the addition or removal
+is added to the agenda for the subsequent meeting.  This is to ensure
+that all members are given the opportunity to participate in all
+membership decisions.  If a WG member is unable to attend a meeting
+where a planned membership decision is being made, then their consent
+is assumed.
+
+No more than 1/3 of the WG members may be affiliated with the same
+employer.  If removal or resignation of a WG member, or a change of
+employment by a WG member, creates a situation where more than 1/3 of
+the WG membership shares an employer, then the situation must be
+immediately remedied by the resignation or removal of one or more WG
+members affiliated with the over-represented employer(s).
+
+### WG Meetings
+
+The WG meets occasionally on a Google Hangout On Air. A designated moderator
+approved by the WG runs the meeting. Each meeting should be
+published to YouTube.
+
+Items are added to the WG agenda that are considered contentious or
+are modifications of governance, contribution policy, WG membership,
+or release process.
+
+The intention of the agenda is not to approve or review all patches;
+that should happen continuously on GitHub and be handled by the larger
+group of Collaborators.
+
+Any community member or contributor can ask that something be added to
+the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
+WG member or the moderator can add the item to the agenda by adding
+the ***WG-agenda*** tag to the issue.
+
+Prior to each WG meeting the moderator will share the Agenda with
+members of the WG. WG members can add any items they like to the
+agenda at the beginning of each meeting. The moderator and the WG
+cannot veto or remove items.
+
+The WG may invite persons or representatives from certain projects to
+participate in a non-voting capacity.
+
+The moderator is responsible for summarizing the discussion of each
+agenda item and sends it as a pull request after the meeting.
+
+### Consensus Seeking Process
+
+The WG follows a
+[Consensus
+Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
+decision-making model.
+
+When an agenda item has appeared to reach a consensus the moderator
+will ask "Does anyone object?" as a final call for dissent from the
+consensus.
+
+If an agenda item cannot reach a consensus a WG member can call for
+either a closing vote or a vote to table the issue to the next
+meeting. The call for a vote must be seconded by a majority of the WG
+or else the discussion will continue. Simple majority wins.
+
+Note that changes to WG membership require a majority consensus.  See
+"WG Membership" above.

+ 43 - 0
test_two_list/HISTORY.md

@@ -0,0 +1,43 @@
+2.3.1 / 2018-02-24
+==================
+
+  * Fix incorrectly replacing non-placeholders in SQL
+
+2.3.0 / 2017-10-01
+==================
+
+  * Add `.toSqlString()` escape overriding
+  * Add `raw` method to wrap raw strings for escape overriding
+  * Small performance improvement on `escapeId`
+
+2.2.0 / 2016-11-01
+==================
+
+  * Escape invalid `Date` objects as `NULL`
+
+2.1.0 / 2016-09-26
+==================
+
+  * Accept numbers and other value types in `escapeId`
+  * Run `buffer.toString()` through escaping
+
+2.0.1 / 2016-06-06
+==================
+
+  * Fix npm package to include missing `lib/` directory
+
+2.0.0 / 2016-06-06
+==================
+
+  * Bring repository up-to-date with `mysql` module changes
+  * Support Node.js 0.6.x
+
+1.0.0 / 2014-11-09
+==================
+
+  * Support Node.js 0.8.x
+
+0.0.1 / 2014-02-25
+==================
+
+  * Initial release

+ 126 - 0
test_two_list/Handshake.js

@@ -0,0 +1,126 @@
+var Sequence        = require('./Sequence');
+var Util            = require('util');
+var Packets         = require('../packets');
+var Auth            = require('../Auth');
+var ClientConstants = require('../constants/client');
+
+module.exports = Handshake;
+Util.inherits(Handshake, Sequence);
+function Handshake(options, callback) {
+  Sequence.call(this, options, callback);
+
+  options = options || {};
+
+  this._config                        = options.config;
+  this._handshakeInitializationPacket = null;
+}
+
+Handshake.prototype.determinePacket = function determinePacket(firstByte, parser) {
+  if (firstByte === 0xff) {
+    return Packets.ErrorPacket;
+  }
+
+  if (!this._handshakeInitializationPacket) {
+    return Packets.HandshakeInitializationPacket;
+  }
+
+  if (firstByte === 0xfe) {
+    return (parser.packetLength() === 1)
+      ? Packets.UseOldPasswordPacket
+      : Packets.AuthSwitchRequestPacket;
+  }
+
+  return undefined;
+};
+
+Handshake.prototype['AuthSwitchRequestPacket'] = function (packet) {
+  var name = packet.authMethodName;
+  var data = Auth.auth(name, packet.authMethodData, {
+    password: this._config.password
+  });
+
+  if (data !== undefined) {
+    this.emit('packet', new Packets.AuthSwitchResponsePacket({
+      data: data
+    }));
+  } else {
+    var err   = new Error('MySQL is requesting the ' + name + ' authentication method, which is not supported.');
+    err.code  = 'UNSUPPORTED_AUTH_METHOD';
+    err.fatal = true;
+    this.end(err);
+  }
+};
+
+Handshake.prototype['HandshakeInitializationPacket'] = function(packet) {
+  this._handshakeInitializationPacket = packet;
+
+  this._config.protocol41 = packet.protocol41;
+
+  var serverSSLSupport = packet.serverCapabilities1 & ClientConstants.CLIENT_SSL;
+
+  if (this._config.ssl) {
+    if (!serverSSLSupport) {
+      var err = new Error('Server does not support secure connection');
+
+      err.code = 'HANDSHAKE_NO_SSL_SUPPORT';
+      err.fatal = true;
+
+      this.end(err);
+      return;
+    }
+
+    this._config.clientFlags |= ClientConstants.CLIENT_SSL;
+    this.emit('packet', new Packets.SSLRequestPacket({
+      clientFlags   : this._config.clientFlags,
+      maxPacketSize : this._config.maxPacketSize,
+      charsetNumber : this._config.charsetNumber
+    }));
+    this.emit('start-tls');
+  } else {
+    this._sendCredentials();
+  }
+};
+
+Handshake.prototype._tlsUpgradeCompleteHandler = function() {
+  this._sendCredentials();
+};
+
+Handshake.prototype._sendCredentials = function() {
+  var packet = this._handshakeInitializationPacket;
+  this.emit('packet', new Packets.ClientAuthenticationPacket({
+    clientFlags   : this._config.clientFlags,
+    maxPacketSize : this._config.maxPacketSize,
+    charsetNumber : this._config.charsetNumber,
+    user          : this._config.user,
+    database      : this._config.database,
+    protocol41    : packet.protocol41,
+    scrambleBuff  : (packet.protocol41)
+      ? Auth.token(this._config.password, packet.scrambleBuff())
+      : Auth.scramble323(packet.scrambleBuff(), this._config.password)
+  }));
+};
+
+Handshake.prototype['UseOldPasswordPacket'] = function() {
+  if (!this._config.insecureAuth) {
+    var err = new Error(
+      'MySQL server is requesting the old and insecure pre-4.1 auth mechanism. ' +
+      'Upgrade the user password or use the {insecureAuth: true} option.'
+    );
+
+    err.code = 'HANDSHAKE_INSECURE_AUTH';
+    err.fatal = true;
+
+    this.end(err);
+    return;
+  }
+
+  this.emit('packet', new Packets.OldPasswordPacket({
+    scrambleBuff: Auth.scramble323(this._handshakeInitializationPacket.scrambleBuff(), this._config.password)
+  }));
+};
+
+Handshake.prototype['ErrorPacket'] = function(packet) {
+  var err = this._packetToError(packet, true);
+  err.fatal = true;
+  this.end(err);
+};

+ 103 - 0
test_two_list/HandshakeInitializationPacket.js

@@ -0,0 +1,103 @@
+var Buffer = require('safe-buffer').Buffer;
+var Client = require('../constants/client');
+
+module.exports = HandshakeInitializationPacket;
+function HandshakeInitializationPacket(options) {
+  options = options || {};
+
+  this.protocolVersion     = options.protocolVersion;
+  this.serverVersion       = options.serverVersion;
+  this.threadId            = options.threadId;
+  this.scrambleBuff1       = options.scrambleBuff1;
+  this.filler1             = options.filler1;
+  this.serverCapabilities1 = options.serverCapabilities1;
+  this.serverLanguage      = options.serverLanguage;
+  this.serverStatus        = options.serverStatus;
+  this.serverCapabilities2 = options.serverCapabilities2;
+  this.scrambleLength      = options.scrambleLength;
+  this.filler2             = options.filler2;
+  this.scrambleBuff2       = options.scrambleBuff2;
+  this.filler3             = options.filler3;
+  this.pluginData          = options.pluginData;
+  this.protocol41          = options.protocol41;
+
+  if (this.protocol41) {
+    // force set the bit in serverCapabilities1
+    this.serverCapabilities1 |= Client.CLIENT_PROTOCOL_41;
+  }
+}
+
+HandshakeInitializationPacket.prototype.parse = function(parser) {
+  this.protocolVersion     = parser.parseUnsignedNumber(1);
+  this.serverVersion       = parser.parseNullTerminatedString();
+  this.threadId            = parser.parseUnsignedNumber(4);
+  this.scrambleBuff1       = parser.parseBuffer(8);
+  this.filler1             = parser.parseFiller(1);
+  this.serverCapabilities1 = parser.parseUnsignedNumber(2);
+  this.serverLanguage      = parser.parseUnsignedNumber(1);
+  this.serverStatus        = parser.parseUnsignedNumber(2);
+
+  this.protocol41          = (this.serverCapabilities1 & (1 << 9)) > 0;
+
+  if (this.protocol41) {
+    this.serverCapabilities2 = parser.parseUnsignedNumber(2);
+    this.scrambleLength      = parser.parseUnsignedNumber(1);
+    this.filler2             = parser.parseFiller(10);
+    // scrambleBuff2 should be 0x00 terminated, but sphinx does not do this
+    // so we assume scrambleBuff2 to be 12 byte and treat the next byte as a
+    // filler byte.
+    this.scrambleBuff2       = parser.parseBuffer(12);
+    this.filler3             = parser.parseFiller(1);
+  } else {
+    this.filler2             = parser.parseFiller(13);
+  }
+
+  if (parser.reachedPacketEnd()) {
+    return;
+  }
+
+  // According to the docs this should be 0x00 terminated, but MariaDB does
+  // not do this, so we assume this string to be packet terminated.
+  this.pluginData = parser.parsePacketTerminatedString();
+
+  // However, if there is a trailing '\0', strip it
+  var lastChar = this.pluginData.length - 1;
+  if (this.pluginData[lastChar] === '\0') {
+    this.pluginData = this.pluginData.substr(0, lastChar);
+  }
+};
+
+HandshakeInitializationPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, this.protocolVersion);
+  writer.writeNullTerminatedString(this.serverVersion);
+  writer.writeUnsignedNumber(4, this.threadId);
+  writer.writeBuffer(this.scrambleBuff1);
+  writer.writeFiller(1);
+  writer.writeUnsignedNumber(2, this.serverCapabilities1);
+  writer.writeUnsignedNumber(1, this.serverLanguage);
+  writer.writeUnsignedNumber(2, this.serverStatus);
+  if (this.protocol41) {
+    writer.writeUnsignedNumber(2, this.serverCapabilities2);
+    writer.writeUnsignedNumber(1, this.scrambleLength);
+    writer.writeFiller(10);
+  }
+  writer.writeNullTerminatedBuffer(this.scrambleBuff2);
+
+  if (this.pluginData !== undefined) {
+    writer.writeNullTerminatedString(this.pluginData);
+  }
+};
+
+HandshakeInitializationPacket.prototype.scrambleBuff = function() {
+  var buffer = null;
+
+  if (typeof this.scrambleBuff2 === 'undefined') {
+    buffer = Buffer.from(this.scrambleBuff1);
+  } else {
+    buffer = Buffer.allocUnsafe(this.scrambleBuff1.length + this.scrambleBuff2.length);
+    this.scrambleBuff1.copy(buffer, 0);
+    this.scrambleBuff2.copy(buffer, this.scrambleBuff1.length);
+  }
+
+  return buffer;
+};

+ 16 - 0
test_two_list/History.md

@@ -0,0 +1,16 @@
+
+1.0.2 / 2015-10-07
+==================
+
+  * use try/catch when checking `localStorage` (#3, @kumavis)
+
+1.0.1 / 2014-11-25
+==================
+
+  * browser: use `console.warn()` for deprecation calls
+  * browser: more jsdocs
+
+1.0.0 / 2014-04-30
+==================
+
+  * initial commit

+ 89 - 0
test_two_list/Inquire1.html

@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html>
+<style>
+table, th, td {
+  border:1px solid black;
+}
+</style>
+
+
+<body>
+
+
+<form>
+<table class="table table-bordered">
+    <tr>
+
+      {% for i1 in labels %}
+        <th>{{i1}}</font></th>
+      {% endfor %}
+    </tr>
+
+      {% for i in content %}
+      <tr>
+        <td>{{ i[0] }}</td>
+        <td>{{ i[1] }}</td>
+        <td>{{ i[2] }}</td>
+        <td>{{ i[3] }}</td>
+        <td>{{ i[4] }}</td>
+        <td>{{ i[5] }}</td>
+        <td>{{ i[6] }}</td>
+        <td>{{ i[7] }}</td>
+        <td>{{ i[8] }}</td>
+        <td>{{ i[9] }}</td>
+        <td>{{ i[10] }}</td>
+        <td>{{ i[11] }}</td>
+        <td>{{ i[12] }}</td>
+        <td>{{ i[13] }}</td>
+        <td>{{ i[14] }}</td>
+        <td>{{ i[15] }}</td>
+        <td>{{ i[16] }}</td>
+        <td>{{ i[17] }}</td>
+        <td>{{ i[18] }}</td>
+        <td>{{ i[19] }}</td>
+        <td>{{ i[20] }}</td>
+        <td>{{ i[21] }}</td>
+        <td>{{ i[22] }}</td>
+        <td>{{ i[23] }}</td>
+        <td>{{ i[24] }}</td>
+        <td>{{ i[25] }}</td>
+        <td>{{ i[26] }}</td>
+        <td>{{ i[27] }}</td>
+        <td>{{ i[28] }}</td>
+        <td>{{ i[29] }}</td>
+        <td>{{ i[30] }}</td>
+        <td>{{ i[31] }}</td>
+        <td>{{ i[32] }}</td>
+        <td>{{ i[33] }}</td>
+        <td>{{ i[34] }}</td>
+        <td>{{ i[35] }}</td>
+        <td>{{ i[36] }}</td>
+        <td>{{ i[37] }}</td>
+        <td>{{ i[38] }}</td>
+        <td>{{ i[39] }}</td>
+        <td>{{ i[40] }}</td>
+        <td>{{ i[41] }}</td>
+        <td>{{ i[42] }}</td>
+        <td>{{ i[43] }}</td>
+        <td>{{ i[44] }}</td>
+        <td>{{ i[45] }}</td>
+        <td>{{ i[46] }}</td>
+        <td>{{ i[47] }}</td>
+        <td>{{ i[48] }}</td>
+        <td>{{ i[49] }}</td>
+        <td>{{ i[50] }}</td>
+        <td>{{ i[51] }}</td>
+        <td>{{ i[52] }}</td>
+        <td>{{ i[53] }}</td>
+        <td>{{ i[54] }}</td>
+        <td>{{ i[55] }}</td>
+        <td>{{ i[56] }}</td>
+        <td>{{ i[57] }}</td>
+        <td>{{ i[58] }}</td>
+      </tr>
+    {% endfor %}
+    </table>
+</form>
+
+</body>
+</html>

+ 23 - 0
test_two_list/LICENCE

@@ -0,0 +1,23 @@
+The MIT Licence.
+
+Copyright (c) 2019 Michael Mclaughlin
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+

+ 24 - 0
test_two_list/LICENSE

@@ -0,0 +1,24 @@
+(The MIT License)
+
+Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

+ 19 - 0
test_two_list/License

@@ -0,0 +1,19 @@
+Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.

+ 15 - 0
test_two_list/LocalDataFilePacket.js

@@ -0,0 +1,15 @@
+module.exports = LocalDataFilePacket;
+
+/**
+ * Create a new LocalDataFilePacket
+ * @constructor
+ * @param {Buffer} data The data contents of the packet
+ * @public
+ */
+function LocalDataFilePacket(data) {
+  this.data = data;
+}
+
+LocalDataFilePacket.prototype.write = function(writer) {
+  writer.writeBuffer(this.data);
+};

+ 21 - 0
test_two_list/LocalInfileRequestPacket.js

@@ -0,0 +1,21 @@
+module.exports = LocalInfileRequestPacket;
+function LocalInfileRequestPacket(options) {
+  options = options || {};
+
+  this.filename = options.filename;
+}
+
+LocalInfileRequestPacket.prototype.parse = function parse(parser) {
+  if (parser.parseLengthCodedNumber() !== null) {
+    var err  = new TypeError('Received invalid field length');
+    err.code = 'PARSER_INVALID_FIELD_LENGTH';
+    throw err;
+  }
+
+  this.filename = parser.parsePacketTerminatedString();
+};
+
+LocalInfileRequestPacket.prototype.write = function write(writer) {
+  writer.writeLengthCodedNumber(null);
+  writer.writeString(this.filename);
+};

+ 6 - 0
test_two_list/Makefile

@@ -0,0 +1,6 @@
+
+test:
+	@node_modules/.bin/tape test.js
+
+.PHONY: test
+

+ 44 - 0
test_two_list/OkPacket.js

@@ -0,0 +1,44 @@
+
+// Language-neutral expression to match ER_UPDATE_INFO
+var ER_UPDATE_INFO_REGEXP = /^[^:0-9]+: [0-9]+[^:0-9]+: ([0-9]+)[^:0-9]+: [0-9]+[^:0-9]*$/;
+
+module.exports = OkPacket;
+function OkPacket(options) {
+  options = options || {};
+
+  this.fieldCount   = undefined;
+  this.affectedRows = undefined;
+  this.insertId     = undefined;
+  this.serverStatus = undefined;
+  this.warningCount = undefined;
+  this.message      = undefined;
+  this.protocol41   = options.protocol41;
+}
+
+OkPacket.prototype.parse = function(parser) {
+  this.fieldCount   = parser.parseUnsignedNumber(1);
+  this.affectedRows = parser.parseLengthCodedNumber();
+  this.insertId     = parser.parseLengthCodedNumber();
+  if (this.protocol41) {
+    this.serverStatus = parser.parseUnsignedNumber(2);
+    this.warningCount = parser.parseUnsignedNumber(2);
+  }
+  this.message      = parser.parsePacketTerminatedString();
+  this.changedRows  = 0;
+
+  var m = ER_UPDATE_INFO_REGEXP.exec(this.message);
+  if (m !== null) {
+    this.changedRows = parseInt(m[1], 10);
+  }
+};
+
+OkPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, 0x00);
+  writer.writeLengthCodedNumber(this.affectedRows || 0);
+  writer.writeLengthCodedNumber(this.insertId || 0);
+  if (this.protocol41) {
+    writer.writeUnsignedNumber(2, this.serverStatus || 0);
+    writer.writeUnsignedNumber(2, this.warningCount || 0);
+  }
+  writer.writeString(this.message);
+};

+ 14 - 0
test_two_list/OldPasswordPacket.js

@@ -0,0 +1,14 @@
+module.exports = OldPasswordPacket;
+function OldPasswordPacket(options) {
+  options = options || {};
+
+  this.scrambleBuff = options.scrambleBuff;
+}
+
+OldPasswordPacket.prototype.parse = function(parser) {
+  this.scrambleBuff = parser.parsePacketTerminatedBuffer();
+};
+
+OldPasswordPacket.prototype.write = function(writer) {
+  writer.writeBuffer(this.scrambleBuff);
+};

+ 5 - 0
test_two_list/PacketHeader.js

@@ -0,0 +1,5 @@
+module.exports = PacketHeader;
+function PacketHeader(length, number) {
+  this.length = length;
+  this.number = number;
+}

+ 211 - 0
test_two_list/PacketWriter.js

@@ -0,0 +1,211 @@
+var BIT_16            = Math.pow(2, 16);
+var BIT_24            = Math.pow(2, 24);
+var BUFFER_ALLOC_SIZE = Math.pow(2, 8);
+// The maximum precision JS Numbers can hold precisely
+// Don't panic: Good enough to represent byte values up to 8192 TB
+var IEEE_754_BINARY_64_PRECISION = Math.pow(2, 53);
+var MAX_PACKET_LENGTH            = Math.pow(2, 24) - 1;
+var Buffer                       = require('safe-buffer').Buffer;
+
+module.exports = PacketWriter;
+function PacketWriter() {
+  this._buffer = null;
+  this._offset = 0;
+}
+
+PacketWriter.prototype.toBuffer = function toBuffer(parser) {
+  if (!this._buffer) {
+    this._buffer = Buffer.alloc(0);
+    this._offset = 0;
+  }
+
+  var buffer  = this._buffer;
+  var length  = this._offset;
+  var packets = Math.floor(length / MAX_PACKET_LENGTH) + 1;
+
+  this._buffer = Buffer.allocUnsafe(length + packets * 4);
+  this._offset = 0;
+
+  for (var packet = 0; packet < packets; packet++) {
+    var isLast = (packet + 1 === packets);
+    var packetLength = (isLast)
+      ? length % MAX_PACKET_LENGTH
+      : MAX_PACKET_LENGTH;
+
+    var packetNumber = parser.incrementPacketNumber();
+
+    this.writeUnsignedNumber(3, packetLength);
+    this.writeUnsignedNumber(1, packetNumber);
+
+    var start = packet * MAX_PACKET_LENGTH;
+    var end   = start + packetLength;
+
+    this.writeBuffer(buffer.slice(start, end));
+  }
+
+  return this._buffer;
+};
+
+PacketWriter.prototype.writeUnsignedNumber = function(bytes, value) {
+  this._allocate(bytes);
+
+  for (var i = 0; i < bytes; i++) {
+    this._buffer[this._offset++] = (value >> (i * 8)) & 0xff;
+  }
+};
+
+PacketWriter.prototype.writeFiller = function(bytes) {
+  this._allocate(bytes);
+
+  for (var i = 0; i < bytes; i++) {
+    this._buffer[this._offset++] = 0x00;
+  }
+};
+
+PacketWriter.prototype.writeNullTerminatedString = function(value, encoding) {
+  // Typecast undefined into '' and numbers into strings
+  value = value || '';
+  value = value + '';
+
+  var bytes = Buffer.byteLength(value, encoding || 'utf-8') + 1;
+  this._allocate(bytes);
+
+  this._buffer.write(value, this._offset, encoding);
+  this._buffer[this._offset + bytes - 1] = 0x00;
+
+  this._offset += bytes;
+};
+
+PacketWriter.prototype.writeString = function(value) {
+  // Typecast undefined into '' and numbers into strings
+  value = value || '';
+  value = value + '';
+
+  var bytes = Buffer.byteLength(value, 'utf-8');
+  this._allocate(bytes);
+
+  this._buffer.write(value, this._offset, 'utf-8');
+
+  this._offset += bytes;
+};
+
+PacketWriter.prototype.writeBuffer = function(value) {
+  var bytes = value.length;
+
+  this._allocate(bytes);
+  value.copy(this._buffer, this._offset);
+  this._offset += bytes;
+};
+
+PacketWriter.prototype.writeLengthCodedNumber = function(value) {
+  if (value === null) {
+    this._allocate(1);
+    this._buffer[this._offset++] = 251;
+    return;
+  }
+
+  if (value <= 250) {
+    this._allocate(1);
+    this._buffer[this._offset++] = value;
+    return;
+  }
+
+  if (value > IEEE_754_BINARY_64_PRECISION) {
+    throw new Error(
+      'writeLengthCodedNumber: JS precision range exceeded, your ' +
+      'number is > 53 bit: "' + value + '"'
+    );
+  }
+
+  if (value < BIT_16) {
+    this._allocate(3);
+    this._buffer[this._offset++] = 252;
+  } else if (value < BIT_24) {
+    this._allocate(4);
+    this._buffer[this._offset++] = 253;
+  } else {
+    this._allocate(9);
+    this._buffer[this._offset++] = 254;
+  }
+
+  // 16 Bit
+  this._buffer[this._offset++] = value & 0xff;
+  this._buffer[this._offset++] = (value >> 8) & 0xff;
+
+  if (value < BIT_16) {
+    return;
+  }
+
+  // 24 Bit
+  this._buffer[this._offset++] = (value >> 16) & 0xff;
+
+  if (value < BIT_24) {
+    return;
+  }
+
+  this._buffer[this._offset++] = (value >> 24) & 0xff;
+
+  // Hack: Get the most significant 32 bit (JS bitwise operators are 32 bit)
+  value = value.toString(2);
+  value = value.substr(0, value.length - 32);
+  value = parseInt(value, 2);
+
+  this._buffer[this._offset++] = value & 0xff;
+  this._buffer[this._offset++] = (value >> 8) & 0xff;
+  this._buffer[this._offset++] = (value >> 16) & 0xff;
+
+  // Set last byte to 0, as we can only support 53 bits in JS (see above)
+  this._buffer[this._offset++] = 0;
+};
+
+PacketWriter.prototype.writeLengthCodedBuffer = function(value) {
+  var bytes = value.length;
+  this.writeLengthCodedNumber(bytes);
+  this.writeBuffer(value);
+};
+
+PacketWriter.prototype.writeNullTerminatedBuffer = function(value) {
+  this.writeBuffer(value);
+  this.writeFiller(1); // 0x00 terminator
+};
+
+PacketWriter.prototype.writeLengthCodedString = function(value) {
+  if (value === null) {
+    this.writeLengthCodedNumber(null);
+    return;
+  }
+
+  value = (value === undefined)
+    ? ''
+    : String(value);
+
+  var bytes = Buffer.byteLength(value, 'utf-8');
+  this.writeLengthCodedNumber(bytes);
+
+  if (!bytes) {
+    return;
+  }
+
+  this._allocate(bytes);
+  this._buffer.write(value, this._offset, 'utf-8');
+  this._offset += bytes;
+};
+
+PacketWriter.prototype._allocate = function _allocate(bytes) {
+  if (!this._buffer) {
+    this._buffer = Buffer.alloc(Math.max(BUFFER_ALLOC_SIZE, bytes));
+    this._offset = 0;
+    return;
+  }
+
+  var bytesRemaining = this._buffer.length - this._offset;
+  if (bytesRemaining >= bytes) {
+    return;
+  }
+
+  var newSize   = this._buffer.length + Math.max(BUFFER_ALLOC_SIZE, bytes);
+  var oldBuffer = this._buffer;
+
+  this._buffer = Buffer.alloc(newSize);
+  oldBuffer.copy(this._buffer);
+};

+ 491 - 0
test_two_list/Parser.js

@@ -0,0 +1,491 @@
+var PacketHeader = require('./PacketHeader');
+var BigNumber    = require('bignumber.js');
+var Buffer       = require('safe-buffer').Buffer;
+var BufferList   = require('./BufferList');
+
+var MAX_PACKET_LENGTH    = Math.pow(2, 24) - 1;
+var MUL_32BIT            = Math.pow(2, 32);
+var PACKET_HEADER_LENGTH = 4;
+
+module.exports = Parser;
+function Parser(options) {
+  options = options || {};
+
+  this._supportBigNumbers = options.config && options.config.supportBigNumbers;
+  this._buffer            = Buffer.alloc(0);
+  this._nextBuffers       = new BufferList();
+  this._longPacketBuffers = new BufferList();
+  this._offset            = 0;
+  this._packetEnd         = null;
+  this._packetHeader      = null;
+  this._packetOffset      = null;
+  this._onError           = options.onError || function(err) { throw err; };
+  this._onPacket          = options.onPacket || function() {};
+  this._nextPacketNumber  = 0;
+  this._encoding          = 'utf-8';
+  this._paused            = false;
+}
+
+Parser.prototype.write = function write(chunk) {
+  this._nextBuffers.push(chunk);
+
+  while (!this._paused) {
+    var packetHeader = this._tryReadPacketHeader();
+
+    if (!packetHeader) {
+      break;
+    }
+
+    if (!this._combineNextBuffers(packetHeader.length)) {
+      break;
+    }
+
+    this._parsePacket(packetHeader);
+  }
+};
+
+Parser.prototype.append = function append(chunk) {
+  if (!chunk || chunk.length === 0) {
+    return;
+  }
+
+  // Calculate slice ranges
+  var sliceEnd    = this._buffer.length;
+  var sliceStart  = this._packetOffset === null
+    ? this._offset
+    : this._packetOffset;
+  var sliceLength = sliceEnd - sliceStart;
+
+  // Get chunk data
+  var buffer = null;
+  var chunks = !(chunk instanceof Array || Array.isArray(chunk)) ? [chunk] : chunk;
+  var length = 0;
+  var offset = 0;
+
+  for (var i = 0; i < chunks.length; i++) {
+    length += chunks[i].length;
+  }
+
+  if (sliceLength !== 0) {
+    // Create a new Buffer
+    buffer = Buffer.allocUnsafe(sliceLength + length);
+    offset = 0;
+
+    // Copy data slice
+    offset += this._buffer.copy(buffer, 0, sliceStart, sliceEnd);
+
+    // Copy chunks
+    for (var i = 0; i < chunks.length; i++) {
+      offset += chunks[i].copy(buffer, offset);
+    }
+  } else if (chunks.length > 1) {
+    // Create a new Buffer
+    buffer = Buffer.allocUnsafe(length);
+    offset = 0;
+
+    // Copy chunks
+    for (var i = 0; i < chunks.length; i++) {
+      offset += chunks[i].copy(buffer, offset);
+    }
+  } else {
+    // Buffer is the only chunk
+    buffer = chunks[0];
+  }
+
+  // Adjust data-tracking pointers
+  this._buffer       = buffer;
+  this._offset       = this._offset - sliceStart;
+  this._packetEnd    = this._packetEnd !== null
+    ? this._packetEnd - sliceStart
+    : null;
+  this._packetOffset = this._packetOffset !== null
+    ? this._packetOffset - sliceStart
+    : null;
+};
+
+Parser.prototype.pause = function() {
+  this._paused = true;
+};
+
+Parser.prototype.resume = function() {
+  this._paused = false;
+
+  // nextTick() to avoid entering write() multiple times within the same stack
+  // which would cause problems as write manipulates the state of the object.
+  process.nextTick(this.write.bind(this));
+};
+
+Parser.prototype.peak = function peak(offset) {
+  return this._buffer[this._offset + (offset >>> 0)];
+};
+
+Parser.prototype.parseUnsignedNumber = function parseUnsignedNumber(bytes) {
+  if (bytes === 1) {
+    return this._buffer[this._offset++];
+  }
+
+  var buffer = this._buffer;
+  var offset = this._offset + bytes - 1;
+  var value  = 0;
+
+  if (bytes > 4) {
+    var err    = new Error('parseUnsignedNumber: Supports only up to 4 bytes');
+    err.offset = (this._offset - this._packetOffset - 1);
+    err.code   = 'PARSER_UNSIGNED_TOO_LONG';
+    throw err;
+  }
+
+  while (offset >= this._offset) {
+    value = ((value << 8) | buffer[offset]) >>> 0;
+    offset--;
+  }
+
+  this._offset += bytes;
+
+  return value;
+};
+
+Parser.prototype.parseLengthCodedString = function() {
+  var length = this.parseLengthCodedNumber();
+
+  if (length === null) {
+    return null;
+  }
+
+  return this.parseString(length);
+};
+
+Parser.prototype.parseLengthCodedBuffer = function() {
+  var length = this.parseLengthCodedNumber();
+
+  if (length === null) {
+    return null;
+  }
+
+  return this.parseBuffer(length);
+};
+
+Parser.prototype.parseLengthCodedNumber = function parseLengthCodedNumber() {
+  if (this._offset >= this._buffer.length) {
+    var err    = new Error('Parser: read past end');
+    err.offset = (this._offset - this._packetOffset);
+    err.code   = 'PARSER_READ_PAST_END';
+    throw err;
+  }
+
+  var bits = this._buffer[this._offset++];
+
+  if (bits <= 250) {
+    return bits;
+  }
+
+  switch (bits) {
+    case 251:
+      return null;
+    case 252:
+      return this.parseUnsignedNumber(2);
+    case 253:
+      return this.parseUnsignedNumber(3);
+    case 254:
+      break;
+    default:
+      var err    = new Error('Unexpected first byte' + (bits ? ': 0x' + bits.toString(16) : ''));
+      err.offset = (this._offset - this._packetOffset - 1);
+      err.code   = 'PARSER_BAD_LENGTH_BYTE';
+      throw err;
+  }
+
+  var low = this.parseUnsignedNumber(4);
+  var high = this.parseUnsignedNumber(4);
+  var value;
+
+  if (high >>> 21) {
+    value = BigNumber(MUL_32BIT).times(high).plus(low).toString();
+
+    if (this._supportBigNumbers) {
+      return value;
+    }
+
+    var err    = new Error(
+      'parseLengthCodedNumber: JS precision range exceeded, ' +
+      'number is >= 53 bit: "' + value + '"'
+    );
+    err.offset = (this._offset - this._packetOffset - 8);
+    err.code   = 'PARSER_JS_PRECISION_RANGE_EXCEEDED';
+    throw err;
+  }
+
+  value = low + (MUL_32BIT * high);
+
+  return value;
+};
+
+Parser.prototype.parseFiller = function(length) {
+  return this.parseBuffer(length);
+};
+
+Parser.prototype.parseNullTerminatedBuffer = function() {
+  var end      = this._nullByteOffset();
+  var value    = this._buffer.slice(this._offset, end);
+  this._offset = end + 1;
+
+  return value;
+};
+
+Parser.prototype.parseNullTerminatedString = function() {
+  var end      = this._nullByteOffset();
+  var value    = this._buffer.toString(this._encoding, this._offset, end);
+  this._offset = end + 1;
+
+  return value;
+};
+
+Parser.prototype._nullByteOffset = function() {
+  var offset = this._offset;
+
+  while (this._buffer[offset] !== 0x00) {
+    offset++;
+
+    if (offset >= this._buffer.length) {
+      var err    = new Error('Offset of null terminated string not found.');
+      err.offset = (this._offset - this._packetOffset);
+      err.code   = 'PARSER_MISSING_NULL_BYTE';
+      throw err;
+    }
+  }
+
+  return offset;
+};
+
+Parser.prototype.parsePacketTerminatedBuffer = function parsePacketTerminatedBuffer() {
+  var length = this._packetEnd - this._offset;
+  return this.parseBuffer(length);
+};
+
+Parser.prototype.parsePacketTerminatedString = function() {
+  var length = this._packetEnd - this._offset;
+  return this.parseString(length);
+};
+
+Parser.prototype.parseBuffer = function(length) {
+  var response = Buffer.alloc(length);
+  this._buffer.copy(response, 0, this._offset, this._offset + length);
+
+  this._offset += length;
+  return response;
+};
+
+Parser.prototype.parseString = function(length) {
+  var offset = this._offset;
+  var end = offset + length;
+  var value = this._buffer.toString(this._encoding, offset, end);
+
+  this._offset = end;
+  return value;
+};
+
+Parser.prototype.parseGeometryValue = function() {
+  var buffer = this.parseLengthCodedBuffer();
+  var offset = 4;
+
+  if (buffer === null || !buffer.length) {
+    return null;
+  }
+
+  function parseGeometry() {
+    var result = null;
+    var byteOrder = buffer.readUInt8(offset); offset += 1;
+    var wkbType = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
+    switch (wkbType) {
+      case 1: // WKBPoint
+        var x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
+        var y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
+        result = {x: x, y: y};
+        break;
+      case 2: // WKBLineString
+        var numPoints = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
+        result = [];
+        for (var i = numPoints; i > 0; i--) {
+          var x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
+          var y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
+          result.push({x: x, y: y});
+        }
+        break;
+      case 3: // WKBPolygon
+        var numRings = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
+        result = [];
+        for (var i = numRings; i > 0; i--) {
+          var numPoints = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
+          var line = [];
+          for (var j = numPoints; j > 0; j--) {
+            var x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
+            var y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
+            line.push({x: x, y: y});
+          }
+          result.push(line);
+        }
+        break;
+      case 4: // WKBMultiPoint
+      case 5: // WKBMultiLineString
+      case 6: // WKBMultiPolygon
+      case 7: // WKBGeometryCollection
+        var num = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
+        var result = [];
+        for (var i = num; i > 0; i--) {
+          result.push(parseGeometry());
+        }
+        break;
+    }
+    return result;
+  }
+  return parseGeometry();
+};
+
+Parser.prototype.reachedPacketEnd = function() {
+  return this._offset === this._packetEnd;
+};
+
+Parser.prototype.incrementPacketNumber = function() {
+  var currentPacketNumber = this._nextPacketNumber;
+  this._nextPacketNumber = (this._nextPacketNumber + 1) % 256;
+
+  return currentPacketNumber;
+};
+
+Parser.prototype.resetPacketNumber = function() {
+  this._nextPacketNumber = 0;
+};
+
+Parser.prototype.packetLength = function packetLength() {
+  if (!this._packetHeader) {
+    return null;
+  }
+
+  return this._packetHeader.length + this._longPacketBuffers.size;
+};
+
+Parser.prototype._combineNextBuffers = function _combineNextBuffers(bytes) {
+  var length = this._buffer.length - this._offset;
+
+  if (length >= bytes) {
+    return true;
+  }
+
+  if ((length + this._nextBuffers.size) < bytes) {
+    return false;
+  }
+
+  var buffers     = [];
+  var bytesNeeded = bytes - length;
+
+  while (bytesNeeded > 0) {
+    var buffer = this._nextBuffers.shift();
+    buffers.push(buffer);
+    bytesNeeded -= buffer.length;
+  }
+
+  this.append(buffers);
+  return true;
+};
+
+Parser.prototype._combineLongPacketBuffers = function _combineLongPacketBuffers() {
+  if (!this._longPacketBuffers.size) {
+    return;
+  }
+
+  // Calculate bytes
+  var remainingBytes      = this._buffer.length - this._offset;
+  var trailingPacketBytes = this._buffer.length - this._packetEnd;
+
+  // Create buffer
+  var buf    = null;
+  var buffer = Buffer.allocUnsafe(remainingBytes + this._longPacketBuffers.size);
+  var offset = 0;
+
+  // Copy long buffers
+  while ((buf = this._longPacketBuffers.shift())) {
+    offset += buf.copy(buffer, offset);
+  }
+
+  // Copy remaining bytes
+  this._buffer.copy(buffer, offset, this._offset);
+
+  this._buffer       = buffer;
+  this._offset       = 0;
+  this._packetEnd    = this._buffer.length - trailingPacketBytes;
+  this._packetOffset = 0;
+};
+
+Parser.prototype._parsePacket = function _parsePacket(packetHeader) {
+  this._packetEnd    = this._offset + packetHeader.length;
+  this._packetOffset = this._offset;
+
+  if (packetHeader.length === MAX_PACKET_LENGTH) {
+    this._longPacketBuffers.push(this._buffer.slice(this._packetOffset, this._packetEnd));
+    this._advanceToNextPacket();
+    return;
+  }
+
+  this._combineLongPacketBuffers();
+
+  var hadException = true;
+  try {
+    this._onPacket(packetHeader);
+    hadException = false;
+  } catch (err) {
+    if (!err || typeof err.code !== 'string' || err.code.substr(0, 7) !== 'PARSER_') {
+      throw err; // Rethrow non-MySQL errors
+    }
+
+    // Pass down parser errors
+    this._onError(err);
+    hadException = false;
+  } finally {
+    this._advanceToNextPacket();
+
+    // If there was an exception, the parser while loop will be broken out
+    // of after the finally block. So schedule a blank write to re-enter it
+    // to continue parsing any bytes that may already have been received.
+    if (hadException) {
+      process.nextTick(this.write.bind(this));
+    }
+  }
+};
+
+Parser.prototype._tryReadPacketHeader = function _tryReadPacketHeader() {
+  if (this._packetHeader) {
+    return this._packetHeader;
+  }
+
+  if (!this._combineNextBuffers(PACKET_HEADER_LENGTH)) {
+    return null;
+  }
+
+  this._packetHeader = new PacketHeader(
+    this.parseUnsignedNumber(3),
+    this.parseUnsignedNumber(1)
+  );
+
+  if (this._packetHeader.number !== this._nextPacketNumber) {
+    var err = new Error(
+      'Packets out of order. Got: ' + this._packetHeader.number + ' ' +
+      'Expected: ' + this._nextPacketNumber
+    );
+
+    err.code  = 'PROTOCOL_PACKETS_OUT_OF_ORDER';
+    err.fatal = true;
+
+    this._onError(err);
+  }
+
+  this.incrementPacketNumber();
+
+  return this._packetHeader;
+};
+
+Parser.prototype._advanceToNextPacket = function() {
+  this._offset       = this._packetEnd;
+  this._packetHeader = null;
+  this._packetEnd    = null;
+  this._packetOffset = null;
+};

+ 19 - 0
test_two_list/Ping.js

@@ -0,0 +1,19 @@
+var Sequence = require('./Sequence');
+var Util     = require('util');
+var Packets  = require('../packets');
+
+module.exports = Ping;
+Util.inherits(Ping, Sequence);
+
+function Ping(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  Sequence.call(this, options, callback);
+}
+
+Ping.prototype.start = function() {
+  this.emit('packet', new Packets.ComPingPacket());
+};

+ 294 - 0
test_two_list/Pool.js

@@ -0,0 +1,294 @@
+var mysql          = require('../');
+var Connection     = require('./Connection');
+var EventEmitter   = require('events').EventEmitter;
+var Util           = require('util');
+var PoolConnection = require('./PoolConnection');
+
+module.exports = Pool;
+
+Util.inherits(Pool, EventEmitter);
+function Pool(options) {
+  EventEmitter.call(this);
+  this.config = options.config;
+  this.config.connectionConfig.pool = this;
+
+  this._acquiringConnections = [];
+  this._allConnections       = [];
+  this._freeConnections      = [];
+  this._connectionQueue      = [];
+  this._closed               = false;
+}
+
+Pool.prototype.getConnection = function (cb) {
+
+  if (this._closed) {
+    var err = new Error('Pool is closed.');
+    err.code = 'POOL_CLOSED';
+    process.nextTick(function () {
+      cb(err);
+    });
+    return;
+  }
+
+  var connection;
+  var pool = this;
+
+  if (this._freeConnections.length > 0) {
+    connection = this._freeConnections.shift();
+    this.acquireConnection(connection, cb);
+    return;
+  }
+
+  if (this.config.connectionLimit === 0 || this._allConnections.length < this.config.connectionLimit) {
+    connection = new PoolConnection(this, { config: this.config.newConnectionConfig() });
+
+    this._acquiringConnections.push(connection);
+    this._allConnections.push(connection);
+
+    connection.connect({timeout: this.config.acquireTimeout}, function onConnect(err) {
+      spliceConnection(pool._acquiringConnections, connection);
+
+      if (pool._closed) {
+        err = new Error('Pool is closed.');
+        err.code = 'POOL_CLOSED';
+      }
+
+      if (err) {
+        pool._purgeConnection(connection);
+        cb(err);
+        return;
+      }
+
+      pool.emit('connection', connection);
+      pool.emit('acquire', connection);
+      cb(null, connection);
+    });
+    return;
+  }
+
+  if (!this.config.waitForConnections) {
+    process.nextTick(function(){
+      var err = new Error('No connections available.');
+      err.code = 'POOL_CONNLIMIT';
+      cb(err);
+    });
+    return;
+  }
+
+  this._enqueueCallback(cb);
+};
+
+Pool.prototype.acquireConnection = function acquireConnection(connection, cb) {
+  if (connection._pool !== this) {
+    throw new Error('Connection acquired from wrong pool.');
+  }
+
+  var changeUser = this._needsChangeUser(connection);
+  var pool       = this;
+
+  this._acquiringConnections.push(connection);
+
+  function onOperationComplete(err) {
+    spliceConnection(pool._acquiringConnections, connection);
+
+    if (pool._closed) {
+      err = new Error('Pool is closed.');
+      err.code = 'POOL_CLOSED';
+    }
+
+    if (err) {
+      pool._connectionQueue.unshift(cb);
+      pool._purgeConnection(connection);
+      return;
+    }
+
+    if (changeUser) {
+      pool.emit('connection', connection);
+    }
+
+    pool.emit('acquire', connection);
+    cb(null, connection);
+  }
+
+  if (changeUser) {
+    // restore user back to pool configuration
+    connection.config = this.config.newConnectionConfig();
+    connection.changeUser({timeout: this.config.acquireTimeout}, onOperationComplete);
+  } else {
+    // ping connection
+    connection.ping({timeout: this.config.acquireTimeout}, onOperationComplete);
+  }
+};
+
+Pool.prototype.releaseConnection = function releaseConnection(connection) {
+
+  if (this._acquiringConnections.indexOf(connection) !== -1) {
+    // connection is being acquired
+    return;
+  }
+
+  if (connection._pool) {
+    if (connection._pool !== this) {
+      throw new Error('Connection released to wrong pool');
+    }
+
+    if (this._freeConnections.indexOf(connection) !== -1) {
+      // connection already in free connection pool
+      // this won't catch all double-release cases
+      throw new Error('Connection already released');
+    } else {
+      // add connection to end of free queue
+      this._freeConnections.push(connection);
+      this.emit('release', connection);
+    }
+  }
+
+  if (this._closed) {
+    // empty the connection queue
+    this._connectionQueue.splice(0).forEach(function (cb) {
+      var err = new Error('Pool is closed.');
+      err.code = 'POOL_CLOSED';
+      process.nextTick(function () {
+        cb(err);
+      });
+    });
+  } else if (this._connectionQueue.length) {
+    // get connection with next waiting callback
+    this.getConnection(this._connectionQueue.shift());
+  }
+};
+
+Pool.prototype.end = function (cb) {
+  this._closed = true;
+
+  if (typeof cb !== 'function') {
+    cb = function (err) {
+      if (err) throw err;
+    };
+  }
+
+  var calledBack   = false;
+  var waitingClose = 0;
+
+  function onEnd(err) {
+    if (!calledBack && (err || --waitingClose <= 0)) {
+      calledBack = true;
+      cb(err);
+    }
+  }
+
+  while (this._allConnections.length !== 0) {
+    waitingClose++;
+    this._purgeConnection(this._allConnections[0], onEnd);
+  }
+
+  if (waitingClose === 0) {
+    process.nextTick(onEnd);
+  }
+};
+
+Pool.prototype.query = function (sql, values, cb) {
+  var query = Connection.createQuery(sql, values, cb);
+
+  if (!(typeof sql === 'object' && 'typeCast' in sql)) {
+    query.typeCast = this.config.connectionConfig.typeCast;
+  }
+
+  if (this.config.connectionConfig.trace) {
+    // Long stack trace support
+    query._callSite = new Error();
+  }
+
+  this.getConnection(function (err, conn) {
+    if (err) {
+      query.on('error', function () {});
+      query.end(err);
+      return;
+    }
+
+    // Release connection based off event
+    query.once('end', function() {
+      conn.release();
+    });
+
+    conn.query(query);
+  });
+
+  return query;
+};
+
+Pool.prototype._enqueueCallback = function _enqueueCallback(callback) {
+
+  if (this.config.queueLimit && this._connectionQueue.length >= this.config.queueLimit) {
+    process.nextTick(function () {
+      var err = new Error('Queue limit reached.');
+      err.code = 'POOL_ENQUEUELIMIT';
+      callback(err);
+    });
+    return;
+  }
+
+  // Bind to domain, as dequeue will likely occur in a different domain
+  var cb = process.domain
+    ? process.domain.bind(callback)
+    : callback;
+
+  this._connectionQueue.push(cb);
+  this.emit('enqueue');
+};
+
+Pool.prototype._needsChangeUser = function _needsChangeUser(connection) {
+  var connConfig = connection.config;
+  var poolConfig = this.config.connectionConfig;
+
+  // check if changeUser values are different
+  return connConfig.user !== poolConfig.user
+    || connConfig.database !== poolConfig.database
+    || connConfig.password !== poolConfig.password
+    || connConfig.charsetNumber !== poolConfig.charsetNumber;
+};
+
+Pool.prototype._purgeConnection = function _purgeConnection(connection, callback) {
+  var cb = callback || function () {};
+
+  if (connection.state === 'disconnected') {
+    connection.destroy();
+  }
+
+  this._removeConnection(connection);
+
+  if (connection.state !== 'disconnected' && !connection._protocol._quitSequence) {
+    connection._realEnd(cb);
+    return;
+  }
+
+  process.nextTick(cb);
+};
+
+Pool.prototype._removeConnection = function(connection) {
+  connection._pool = null;
+
+  // Remove connection from all connections
+  spliceConnection(this._allConnections, connection);
+
+  // Remove connection from free connections
+  spliceConnection(this._freeConnections, connection);
+
+  this.releaseConnection(connection);
+};
+
+Pool.prototype.escape = function(value) {
+  return mysql.escape(value, this.config.connectionConfig.stringifyObjects, this.config.connectionConfig.timezone);
+};
+
+Pool.prototype.escapeId = function escapeId(value) {
+  return mysql.escapeId(value, false);
+};
+
+function spliceConnection(array, connection) {
+  var index;
+  if ((index = array.indexOf(connection)) !== -1) {
+    // Remove connection from all connections
+    array.splice(index, 1);
+  }
+}

+ 288 - 0
test_two_list/PoolCluster.js

@@ -0,0 +1,288 @@
+var Pool          = require('./Pool');
+var PoolConfig    = require('./PoolConfig');
+var PoolNamespace = require('./PoolNamespace');
+var PoolSelector  = require('./PoolSelector');
+var Util          = require('util');
+var EventEmitter  = require('events').EventEmitter;
+
+module.exports = PoolCluster;
+
+/**
+ * PoolCluster
+ * @constructor
+ * @param {object} [config] The pool cluster configuration
+ * @public
+ */
+function PoolCluster(config) {
+  EventEmitter.call(this);
+
+  config = config || {};
+  this._canRetry = typeof config.canRetry === 'undefined' ? true : config.canRetry;
+  this._defaultSelector = config.defaultSelector || 'RR';
+  this._removeNodeErrorCount = config.removeNodeErrorCount || 5;
+  this._restoreNodeTimeout = config.restoreNodeTimeout || 0;
+
+  this._closed = false;
+  this._findCaches = Object.create(null);
+  this._lastId = 0;
+  this._namespaces = Object.create(null);
+  this._nodes = Object.create(null);
+}
+
+Util.inherits(PoolCluster, EventEmitter);
+
+PoolCluster.prototype.add = function add(id, config) {
+  if (this._closed) {
+    throw new Error('PoolCluster is closed.');
+  }
+
+  var nodeId = typeof id === 'object'
+    ? 'CLUSTER::' + (++this._lastId)
+    : String(id);
+
+  if (this._nodes[nodeId] !== undefined) {
+    throw new Error('Node ID "' + nodeId + '" is already defined in PoolCluster.');
+  }
+
+  var poolConfig = typeof id !== 'object'
+    ? new PoolConfig(config)
+    : new PoolConfig(id);
+
+  this._nodes[nodeId] = {
+    id            : nodeId,
+    errorCount    : 0,
+    pool          : new Pool({config: poolConfig}),
+    _offlineUntil : 0
+  };
+
+  this._clearFindCaches();
+};
+
+PoolCluster.prototype.end = function end(callback) {
+  var cb = callback !== undefined
+    ? callback
+    : _cb;
+
+  if (typeof cb !== 'function') {
+    throw TypeError('callback argument must be a function');
+  }
+
+  if (this._closed) {
+    process.nextTick(cb);
+    return;
+  }
+
+  this._closed = true;
+
+  var calledBack   = false;
+  var nodeIds      = Object.keys(this._nodes);
+  var waitingClose = 0;
+
+  function onEnd(err) {
+    if (!calledBack && (err || --waitingClose <= 0)) {
+      calledBack = true;
+      cb(err);
+    }
+  }
+
+  for (var i = 0; i < nodeIds.length; i++) {
+    var nodeId = nodeIds[i];
+    var node = this._nodes[nodeId];
+
+    waitingClose++;
+    node.pool.end(onEnd);
+  }
+
+  if (waitingClose === 0) {
+    process.nextTick(onEnd);
+  }
+};
+
+PoolCluster.prototype.of = function(pattern, selector) {
+  pattern = pattern || '*';
+
+  selector = selector || this._defaultSelector;
+  selector = selector.toUpperCase();
+  if (typeof PoolSelector[selector] === 'undefined') {
+    selector = this._defaultSelector;
+  }
+
+  var key = pattern + selector;
+
+  if (typeof this._namespaces[key] === 'undefined') {
+    this._namespaces[key] = new PoolNamespace(this, pattern, selector);
+  }
+
+  return this._namespaces[key];
+};
+
+PoolCluster.prototype.remove = function remove(pattern) {
+  var foundNodeIds = this._findNodeIds(pattern, true);
+
+  for (var i = 0; i < foundNodeIds.length; i++) {
+    var node = this._getNode(foundNodeIds[i]);
+
+    if (node) {
+      this._removeNode(node);
+    }
+  }
+};
+
+PoolCluster.prototype.getConnection = function(pattern, selector, cb) {
+  var namespace;
+  if (typeof pattern === 'function') {
+    cb = pattern;
+    namespace = this.of();
+  } else {
+    if (typeof selector === 'function') {
+      cb = selector;
+      selector = this._defaultSelector;
+    }
+
+    namespace = this.of(pattern, selector);
+  }
+
+  namespace.getConnection(cb);
+};
+
+PoolCluster.prototype._clearFindCaches = function _clearFindCaches() {
+  this._findCaches = Object.create(null);
+};
+
+PoolCluster.prototype._decreaseErrorCount = function _decreaseErrorCount(node) {
+  var errorCount = node.errorCount;
+
+  if (errorCount > this._removeNodeErrorCount) {
+    errorCount = this._removeNodeErrorCount;
+  }
+
+  if (errorCount < 1) {
+    errorCount = 1;
+  }
+
+  node.errorCount = errorCount - 1;
+
+  if (node._offlineUntil) {
+    node._offlineUntil = 0;
+    this.emit('online', node.id);
+  }
+};
+
+PoolCluster.prototype._findNodeIds = function _findNodeIds(pattern, includeOffline) {
+  var currentTime  = 0;
+  var foundNodeIds = this._findCaches[pattern];
+
+  if (foundNodeIds === undefined) {
+    var expression = patternRegExp(pattern);
+    var nodeIds    = Object.keys(this._nodes);
+
+    foundNodeIds = nodeIds.filter(function (id) {
+      return id.match(expression);
+    });
+
+    this._findCaches[pattern] = foundNodeIds;
+  }
+
+  if (includeOffline) {
+    return foundNodeIds;
+  }
+
+  return foundNodeIds.filter(function (nodeId) {
+    var node = this._getNode(nodeId);
+
+    if (!node._offlineUntil) {
+      return true;
+    }
+
+    if (!currentTime) {
+      currentTime = getMonotonicMilliseconds();
+    }
+
+    return node._offlineUntil <= currentTime;
+  }, this);
+};
+
+PoolCluster.prototype._getNode = function _getNode(id) {
+  return this._nodes[id] || null;
+};
+
+PoolCluster.prototype._increaseErrorCount = function _increaseErrorCount(node) {
+  var errorCount = ++node.errorCount;
+
+  if (this._removeNodeErrorCount > errorCount) {
+    return;
+  }
+
+  if (this._restoreNodeTimeout > 0) {
+    node._offlineUntil = getMonotonicMilliseconds() + this._restoreNodeTimeout;
+    this.emit('offline', node.id);
+    return;
+  }
+
+  this._removeNode(node);
+  this.emit('remove', node.id);
+};
+
+PoolCluster.prototype._getConnection = function(node, cb) {
+  var self = this;
+
+  node.pool.getConnection(function (err, connection) {
+    if (err) {
+      self._increaseErrorCount(node);
+      cb(err);
+      return;
+    } else {
+      self._decreaseErrorCount(node);
+    }
+
+    connection._clusterId = node.id;
+
+    cb(null, connection);
+  });
+};
+
+PoolCluster.prototype._removeNode = function _removeNode(node) {
+  delete this._nodes[node.id];
+
+  this._clearFindCaches();
+
+  node.pool.end(_noop);
+};
+
+function getMonotonicMilliseconds() {
+  var ms;
+
+  if (typeof process.hrtime === 'function') {
+    ms = process.hrtime();
+    ms = ms[0] * 1e3 + ms[1] * 1e-6;
+  } else {
+    ms = process.uptime() * 1000;
+  }
+
+  return Math.floor(ms);
+}
+
+function isRegExp(val) {
+  return typeof val === 'object'
+    && Object.prototype.toString.call(val) === '[object RegExp]';
+}
+
+function patternRegExp(pattern) {
+  if (isRegExp(pattern)) {
+    return pattern;
+  }
+
+  var source = pattern
+    .replace(/([.+?^=!:${}()|\[\]\/\\])/g, '\\$1')
+    .replace(/\*/g, '.*');
+
+  return new RegExp('^' + source + '$');
+}
+
+function _cb(err) {
+  if (err) {
+    throw err;
+  }
+}
+
+function _noop() {}

+ 32 - 0
test_two_list/PoolConfig.js

@@ -0,0 +1,32 @@
+
+var ConnectionConfig = require('./ConnectionConfig');
+
+module.exports = PoolConfig;
+function PoolConfig(options) {
+  if (typeof options === 'string') {
+    options = ConnectionConfig.parseUrl(options);
+  }
+
+  this.acquireTimeout     = (options.acquireTimeout === undefined)
+    ? 10 * 1000
+    : Number(options.acquireTimeout);
+  this.connectionConfig   = new ConnectionConfig(options);
+  this.waitForConnections = (options.waitForConnections === undefined)
+    ? true
+    : Boolean(options.waitForConnections);
+  this.connectionLimit    = (options.connectionLimit === undefined)
+    ? 10
+    : Number(options.connectionLimit);
+  this.queueLimit         = (options.queueLimit === undefined)
+    ? 0
+    : Number(options.queueLimit);
+}
+
+PoolConfig.prototype.newConnectionConfig = function newConnectionConfig() {
+  var connectionConfig = new ConnectionConfig(this.connectionConfig);
+
+  connectionConfig.clientFlags   = this.connectionConfig.clientFlags;
+  connectionConfig.maxPacketSize = this.connectionConfig.maxPacketSize;
+
+  return connectionConfig;
+};

+ 65 - 0
test_two_list/PoolConnection.js

@@ -0,0 +1,65 @@
+var inherits   = require('util').inherits;
+var Connection = require('./Connection');
+var Events     = require('events');
+
+module.exports = PoolConnection;
+inherits(PoolConnection, Connection);
+
+function PoolConnection(pool, options) {
+  Connection.call(this, options);
+  this._pool  = pool;
+
+  // Bind connection to pool domain
+  if (Events.usingDomains) {
+    this.domain = pool.domain;
+  }
+
+  // When a fatal error occurs the connection's protocol ends, which will cause
+  // the connection to end as well, thus we only need to watch for the end event
+  // and we will be notified of disconnects.
+  this.on('end', this._removeFromPool);
+  this.on('error', function (err) {
+    if (err.fatal) {
+      this._removeFromPool();
+    }
+  });
+}
+
+PoolConnection.prototype.release = function release() {
+  var pool = this._pool;
+
+  if (!pool || pool._closed) {
+    return undefined;
+  }
+
+  return pool.releaseConnection(this);
+};
+
+// TODO: Remove this when we are removing PoolConnection#end
+PoolConnection.prototype._realEnd = Connection.prototype.end;
+
+PoolConnection.prototype.end = function () {
+  console.warn(
+    'Calling conn.end() to release a pooled connection is ' +
+    'deprecated. In next version calling conn.end() will be ' +
+    'restored to default conn.end() behavior. Use ' +
+    'conn.release() instead.'
+  );
+  this.release();
+};
+
+PoolConnection.prototype.destroy = function () {
+  Connection.prototype.destroy.apply(this, arguments);
+  this._removeFromPool(this);
+};
+
+PoolConnection.prototype._removeFromPool = function _removeFromPool() {
+  if (!this._pool || this._pool._closed) {
+    return;
+  }
+
+  var pool = this._pool;
+  this._pool = null;
+
+  pool._purgeConnection(this);
+};

+ 136 - 0
test_two_list/PoolNamespace.js

@@ -0,0 +1,136 @@
+var Connection   = require('./Connection');
+var PoolSelector = require('./PoolSelector');
+
+module.exports = PoolNamespace;
+
+/**
+ * PoolNamespace
+ * @constructor
+ * @param {PoolCluster} cluster The parent cluster for the namespace
+ * @param {string} pattern The selection pattern to use
+ * @param {string} selector The selector name to use
+ * @public
+ */
+function PoolNamespace(cluster, pattern, selector) {
+  this._cluster = cluster;
+  this._pattern = pattern;
+  this._selector = new PoolSelector[selector]();
+}
+
+PoolNamespace.prototype.getConnection = function(cb) {
+  var clusterNode = this._getClusterNode();
+  var cluster     = this._cluster;
+  var namespace   = this;
+
+  if (clusterNode === null) {
+    var err = null;
+
+    if (this._cluster._findNodeIds(this._pattern, true).length !== 0) {
+      err = new Error('Pool does not have online node.');
+      err.code = 'POOL_NONEONLINE';
+    } else {
+      err = new Error('Pool does not exist.');
+      err.code = 'POOL_NOEXIST';
+    }
+
+    cb(err);
+    return;
+  }
+
+  cluster._getConnection(clusterNode, function(err, connection) {
+    var retry = err && cluster._canRetry
+      && cluster._findNodeIds(namespace._pattern).length !== 0;
+
+    if (retry) {
+      namespace.getConnection(cb);
+      return;
+    }
+
+    if (err) {
+      cb(err);
+      return;
+    }
+
+    cb(null, connection);
+  });
+};
+
+PoolNamespace.prototype.query = function (sql, values, cb) {
+  var cluster     = this._cluster;
+  var clusterNode = this._getClusterNode();
+  var query       = Connection.createQuery(sql, values, cb);
+  var namespace   = this;
+
+  if (clusterNode === null) {
+    var err = null;
+
+    if (this._cluster._findNodeIds(this._pattern, true).length !== 0) {
+      err = new Error('Pool does not have online node.');
+      err.code = 'POOL_NONEONLINE';
+    } else {
+      err = new Error('Pool does not exist.');
+      err.code = 'POOL_NOEXIST';
+    }
+
+    process.nextTick(function () {
+      query.on('error', function () {});
+      query.end(err);
+    });
+    return query;
+  }
+
+  if (!(typeof sql === 'object' && 'typeCast' in sql)) {
+    query.typeCast = clusterNode.pool.config.connectionConfig.typeCast;
+  }
+
+  if (clusterNode.pool.config.connectionConfig.trace) {
+    // Long stack trace support
+    query._callSite = new Error();
+  }
+
+  cluster._getConnection(clusterNode, function (err, conn) {
+    var retry = err && cluster._canRetry
+      && cluster._findNodeIds(namespace._pattern).length !== 0;
+
+    if (retry) {
+      namespace.query(query);
+      return;
+    }
+
+    if (err) {
+      query.on('error', function () {});
+      query.end(err);
+      return;
+    }
+
+    // Release connection based off event
+    query.once('end', function() {
+      conn.release();
+    });
+
+    conn.query(query);
+  });
+
+  return query;
+};
+
+PoolNamespace.prototype._getClusterNode = function _getClusterNode() {
+  var foundNodeIds = this._cluster._findNodeIds(this._pattern);
+  var nodeId;
+
+  switch (foundNodeIds.length) {
+    case 0:
+      nodeId = null;
+      break;
+    case 1:
+      nodeId = foundNodeIds[0];
+      break;
+    default:
+      nodeId = this._selector(foundNodeIds);
+      break;
+  }
+
+  return nodeId !== null
+    ? this._cluster._getNode(nodeId)
+    : null;
+};

+ 31 - 0
test_two_list/PoolSelector.js

@@ -0,0 +1,31 @@
+
+/**
+ * PoolSelector
+ */
+var PoolSelector = module.exports = {};
+
+PoolSelector.RR = function PoolSelectorRoundRobin() {
+  var index = 0;
+
+  return function(clusterIds) {
+    if (index >= clusterIds.length) {
+      index = 0;
+    }
+
+    var clusterId = clusterIds[index++];
+
+    return clusterId;
+  };
+};
+
+PoolSelector.RANDOM = function PoolSelectorRandom() {
+  return function(clusterIds) {
+    return clusterIds[Math.floor(Math.random() * clusterIds.length)];
+  };
+};
+
+PoolSelector.ORDER = function PoolSelectorOrder() {
+  return function(clusterIds) {
+    return clusterIds[0];
+  };
+};

+ 463 - 0
test_two_list/Protocol.js

@@ -0,0 +1,463 @@
+var Parser       = require('./Parser');
+var Sequences    = require('./sequences');
+var Packets      = require('./packets');
+var Stream       = require('stream').Stream;
+var Util         = require('util');
+var PacketWriter = require('./PacketWriter');
+
+module.exports = Protocol;
+Util.inherits(Protocol, Stream);
+function Protocol(options) {
+  Stream.call(this);
+
+  options = options || {};
+
+  this.readable = true;
+  this.writable = true;
+
+  this._config                        = options.config || {};
+  this._connection                    = options.connection;
+  this._callback                      = null;
+  this._fatalError                    = null;
+  this._quitSequence                  = null;
+  this._handshake                     = false;
+  this._handshaked                    = false;
+  this._ended                         = false;
+  this._destroyed                     = false;
+  this._queue                         = [];
+  this._handshakeInitializationPacket = null;
+
+  this._parser = new Parser({
+    onError  : this.handleParserError.bind(this),
+    onPacket : this._parsePacket.bind(this),
+    config   : this._config
+  });
+}
+
+Protocol.prototype.write = function(buffer) {
+  this._parser.write(buffer);
+  return true;
+};
+
+Protocol.prototype.handshake = function handshake(options, callback) {
+  if (typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  options = options || {};
+  options.config = this._config;
+
+  var sequence = this._enqueue(new Sequences.Handshake(options, callback));
+
+  this._handshake = true;
+
+  return sequence;
+};
+
+Protocol.prototype.query = function query(options, callback) {
+  return this._enqueue(new Sequences.Query(options, callback));
+};
+
+Protocol.prototype.changeUser = function changeUser(options, callback) {
+  return this._enqueue(new Sequences.ChangeUser(options, callback));
+};
+
+Protocol.prototype.ping = function ping(options, callback) {
+  if (typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  return this._enqueue(new Sequences.Ping(options, callback));
+};
+
+Protocol.prototype.stats = function stats(options, callback) {
+  if (typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  return this._enqueue(new Sequences.Statistics(options, callback));
+};
+
+Protocol.prototype.quit = function quit(options, callback) {
+  if (typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  var self     = this;
+  var sequence = this._enqueue(new Sequences.Quit(options, callback));
+
+  sequence.on('end', function () {
+    self.end();
+  });
+
+  return this._quitSequence = sequence;
+};
+
+Protocol.prototype.end = function() {
+  if (this._ended) {
+    return;
+  }
+  this._ended = true;
+
+  if (this._quitSequence && (this._quitSequence._ended || this._queue[0] === this._quitSequence)) {
+    this._quitSequence.end();
+    this.emit('end');
+    return;
+  }
+
+  var err = new Error('Connection lost: The server closed the connection.');
+  err.fatal = true;
+  err.code = 'PROTOCOL_CONNECTION_LOST';
+
+  this._delegateError(err);
+};
+
+Protocol.prototype.pause = function() {
+  this._parser.pause();
+  // Since there is a file stream in query, we must transmit pause/resume event to current sequence.
+  var seq = this._queue[0];
+  if (seq && seq.emit) {
+    seq.emit('pause');
+  }
+};
+
+Protocol.prototype.resume = function() {
+  this._parser.resume();
+  // Since there is a file stream in query, we must transmit pause/resume event to current sequence.
+  var seq = this._queue[0];
+  if (seq && seq.emit) {
+    seq.emit('resume');
+  }
+};
+
+Protocol.prototype._enqueue = function(sequence) {
+  if (!this._validateEnqueue(sequence)) {
+    return sequence;
+  }
+
+  if (this._config.trace) {
+    // Long stack trace support
+    sequence._callSite = sequence._callSite || new Error();
+  }
+
+  this._queue.push(sequence);
+  this.emit('enqueue', sequence);
+
+  var self = this;
+  sequence
+    .on('error', function(err) {
+      self._delegateError(err, sequence);
+    })
+    .on('packet', function(packet) {
+      sequence._timer.active();
+      self._emitPacket(packet);
+    })
+    .on('timeout', function() {
+      var err = new Error(sequence.constructor.name + ' inactivity timeout');
+
+      err.code    = 'PROTOCOL_SEQUENCE_TIMEOUT';
+      err.fatal   = true;
+      err.timeout = sequence._timeout;
+
+      self._delegateError(err, sequence);
+    });
+
+  if (sequence.constructor === Sequences.Handshake) {
+    sequence.on('start-tls', function () {
+      sequence._timer.active();
+      self._connection._startTLS(function(err) {
+        if (err) {
+          // SSL negotiation error are fatal
+          err.code  = 'HANDSHAKE_SSL_ERROR';
+          err.fatal = true;
+          sequence.end(err);
+          return;
+        }
+
+        sequence._timer.active();
+        sequence._tlsUpgradeCompleteHandler();
+      });
+    });
+
+    sequence.on('end', function () {
+      self._handshaked = true;
+
+      if (!self._fatalError) {
+        self.emit('handshake', self._handshakeInitializationPacket);
+      }
+    });
+  }
+
+  sequence.on('end', function () {
+    self._dequeue(sequence);
+  });
+
+  if (this._queue.length === 1) {
+    this._parser.resetPacketNumber();
+    this._startSequence(sequence);
+  }
+
+  return sequence;
+};
+
+Protocol.prototype._validateEnqueue = function _validateEnqueue(sequence) {
+  var err;
+  var prefix = 'Cannot enqueue ' + sequence.constructor.name;
+
+  if (this._fatalError) {
+    err      = new Error(prefix + ' after fatal error.');
+    err.code = 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR';
+  } else if (this._quitSequence) {
+    err      = new Error(prefix + ' after invoking quit.');
+    err.code = 'PROTOCOL_ENQUEUE_AFTER_QUIT';
+  } else if (this._destroyed) {
+    err      = new Error(prefix + ' after being destroyed.');
+    err.code = 'PROTOCOL_ENQUEUE_AFTER_DESTROY';
+  } else if ((this._handshake || this._handshaked) && sequence.constructor === Sequences.Handshake) {
+    err      = new Error(prefix + ' after already enqueuing a Handshake.');
+    err.code = 'PROTOCOL_ENQUEUE_HANDSHAKE_TWICE';
+  } else {
+    return true;
+  }
+
+  var self  = this;
+  err.fatal = false;
+
+  // add error handler
+  sequence.on('error', function (err) {
+    self._delegateError(err, sequence);
+  });
+
+  process.nextTick(function () {
+    sequence.end(err);
+  });
+
+  return false;
+};
+
+Protocol.prototype._parsePacket = function() {
+  var sequence = this._queue[0];
+
+  if (!sequence) {
+    var err   = new Error('Received packet with no active sequence.');
+    err.code  = 'PROTOCOL_STRAY_PACKET';
+    err.fatal = true;
+
+    this._delegateError(err);
+    return;
+  }
+
+  var Packet     = this._determinePacket(sequence);
+  var packet     = new Packet({protocol41: this._config.protocol41});
+  var packetName = Packet.name;
+
+  // Special case: Faster dispatch, and parsing done inside sequence
+  if (Packet === Packets.RowDataPacket) {
+    sequence.RowDataPacket(packet, this._parser, this._connection);
+
+    if (this._config.debug) {
+      this._debugPacket(true, packet);
+    }
+
+    return;
+  }
+
+  if (this._config.debug) {
+    this._parsePacketDebug(packet);
+  } else {
+    packet.parse(this._parser);
+  }
+
+  if (Packet === Packets.HandshakeInitializationPacket) {
+    this._handshakeInitializationPacket = packet;
+    this.emit('initialize', packet);
+  }
+
+  sequence._timer.active();
+
+  if (!sequence[packetName]) {
+    var err   = new Error('Received packet in the wrong sequence.');
+    err.code  = 'PROTOCOL_INCORRECT_PACKET_SEQUENCE';
+    err.fatal = true;
+
+    this._delegateError(err);
+    return;
+  }
+
+  sequence[packetName](packet);
+};
+
+Protocol.prototype._parsePacketDebug = function _parsePacketDebug(packet) {
+  try {
+    packet.parse(this._parser);
+  } finally {
+    this._debugPacket(true, packet);
+  }
+};
+
+Protocol.prototype._emitPacket = function(packet) {
+  var packetWriter = new PacketWriter();
+  packet.write(packetWriter);
+  this.emit('data', packetWriter.toBuffer(this._parser));
+
+  if (this._config.debug) {
+    this._debugPacket(false, packet);
+  }
+};
+
+Protocol.prototype._determinePacket = function(sequence) {
+  var firstByte = this._parser.peak();
+
+  if (sequence.determinePacket) {
+    var Packet = sequence.determinePacket(firstByte, this._parser);
+    if (Packet) {
+      return Packet;
+    }
+  }
+
+  switch (firstByte) {
+    case 0x00: return Packets.OkPacket;
+    case 0xfe: return Packets.EofPacket;
+    case 0xff: return Packets.ErrorPacket;
+  }
+
+  throw new Error('Could not determine packet, firstByte = ' + firstByte);
+};
+
+Protocol.prototype._dequeue = function(sequence) {
+  sequence._timer.stop();
+
+  // No point in advancing the queue, we are dead
+  if (this._fatalError) {
+    return;
+  }
+
+  this._queue.shift();
+
+  var sequence = this._queue[0];
+  if (!sequence) {
+    this.emit('drain');
+    return;
+  }
+
+  this._parser.resetPacketNumber();
+
+  this._startSequence(sequence);
+};
+
+Protocol.prototype._startSequence = function(sequence) {
+  if (sequence._timeout > 0 && isFinite(sequence._timeout)) {
+    sequence._timer.start(sequence._timeout);
+  }
+
+  if (sequence.constructor === Sequences.ChangeUser) {
+    sequence.start(this._handshakeInitializationPacket);
+  } else {
+    sequence.start();
+  }
+};
+
+Protocol.prototype.handleNetworkError = function(err) {
+  err.fatal = true;
+
+  var sequence = this._queue[0];
+  if (sequence) {
+    sequence.end(err);
+  } else {
+    this._delegateError(err);
+  }
+};
+
+Protocol.prototype.handleParserError = function handleParserError(err) {
+  var sequence = this._queue[0];
+  if (sequence) {
+    sequence.end(err);
+  } else {
+    this._delegateError(err);
+  }
+};
+
+Protocol.prototype._delegateError = function(err, sequence) {
+  // Stop delegating errors after the first fatal error
+  if (this._fatalError) {
+    return;
+  }
+
+  if (err.fatal) {
+    this._fatalError = err;
+  }
+
+  if (this._shouldErrorBubbleUp(err, sequence)) {
+    // Can't use regular 'error' event here as that always destroys the pipe
+    // between socket and protocol which is not what we want (unless the
+    // exception was fatal).
+    this.emit('unhandledError', err);
+  } else if (err.fatal) {
+    // Send fatal error to all sequences in the queue
+    var queue = this._queue;
+    process.nextTick(function () {
+      queue.forEach(function (sequence) {
+        sequence.end(err);
+      });
+      queue.length = 0;
+    });
+  }
+
+  // Make sure the stream we are piping to is getting closed
+  if (err.fatal) {
+    this.emit('end', err);
+  }
+};
+
+Protocol.prototype._shouldErrorBubbleUp = function(err, sequence) {
+  if (sequence) {
+    if (sequence.hasErrorHandler()) {
+      return false;
+    } else if (!err.fatal) {
+      return true;
+    }
+  }
+
+  return (err.fatal && !this._hasPendingErrorHandlers());
+};
+
+Protocol.prototype._hasPendingErrorHandlers = function() {
+  return this._queue.some(function(sequence) {
+    return sequence.hasErrorHandler();
+  });
+};
+
+Protocol.prototype.destroy = function() {
+  this._destroyed = true;
+  this._parser.pause();
+
+  if (this._connection.state !== 'disconnected') {
+    if (!this._ended) {
+      this.end();
+    }
+  }
+};
+
+Protocol.prototype._debugPacket = function(incoming, packet) {
+  var connection = this._connection;
+  var direction  = incoming
+    ? '<--'
+    : '-->';
+  var packetName = packet.constructor.name;
+  var threadId   = connection && connection.threadId !== null
+    ? ' (' + connection.threadId + ')'
+    : '';
+
+  // check for debug packet restriction
+  if (Array.isArray(this._config.debug) && this._config.debug.indexOf(packetName) === -1) {
+    return;
+  }
+
+  var packetPayload = Util.inspect(packet).replace(/^[^{]+/, '');
+
+  console.log('%s%s %s %s\n', direction, threadId, packetName, packetPayload);
+};

+ 228 - 0
test_two_list/Query.js

@@ -0,0 +1,228 @@
+var ClientConstants = require('../constants/client');
+var fs              = require('fs');
+var Packets         = require('../packets');
+var ResultSet       = require('../ResultSet');
+var Sequence        = require('./Sequence');
+var ServerStatus    = require('../constants/server_status');
+var Readable        = require('readable-stream');
+var Util            = require('util');
+
+module.exports = Query;
+Util.inherits(Query, Sequence);
+function Query(options, callback) {
+  Sequence.call(this, options, callback);
+
+  this.sql = options.sql;
+  this.values = options.values;
+  this.typeCast = (options.typeCast === undefined)
+    ? true
+    : options.typeCast;
+  this.nestTables = options.nestTables || false;
+
+  this._resultSet = null;
+  this._results   = [];
+  this._fields    = [];
+  this._index     = 0;
+  this._loadError = null;
+}
+
+Query.prototype.start = function() {
+  this.emit('packet', new Packets.ComQueryPacket(this.sql));
+};
+
+Query.prototype.determinePacket = function determinePacket(byte, parser) {
+  var resultSet = this._resultSet;
+
+  if (!resultSet) {
+    switch (byte) {
+      case 0x00: return Packets.OkPacket;
+      case 0xfb: return Packets.LocalInfileRequestPacket;
+      case 0xff: return Packets.ErrorPacket;
+      default:   return Packets.ResultSetHeaderPacket;
+    }
+  }
+
+  if (resultSet.eofPackets.length === 0) {
+    return (resultSet.fieldPackets.length < resultSet.resultSetHeaderPacket.fieldCount)
+      ? Packets.FieldPacket
+      : Packets.EofPacket;
+  }
+
+  if (byte === 0xff) {
+    return Packets.ErrorPacket;
+  }
+
+  if (byte === 0xfe && parser.packetLength() < 9) {
+    return Packets.EofPacket;
+  }
+
+  return Packets.RowDataPacket;
+};
+
+Query.prototype['OkPacket'] = function(packet) {
+  // try...finally for exception safety
+  try {
+    if (!this._callback) {
+      this.emit('result', packet, this._index);
+    } else {
+      this._results.push(packet);
+      this._fields.push(undefined);
+    }
+  } finally {
+    this._index++;
+    this._resultSet = null;
+    this._handleFinalResultPacket(packet);
+  }
+};
+
+Query.prototype['ErrorPacket'] = function(packet) {
+  var err = this._packetToError(packet);
+
+  var results = (this._results.length > 0)
+    ? this._results
+    : undefined;
+
+  var fields = (this._fields.length > 0)
+    ? this._fields
+    : undefined;
+
+  err.index = this._index;
+  err.sql   = this.sql;
+
+  this.end(err, results, fields);
+};
+
+Query.prototype['LocalInfileRequestPacket'] = function(packet) {
+  if (this._connection.config.clientFlags & ClientConstants.CLIENT_LOCAL_FILES) {
+    this._sendLocalDataFile(packet.filename);
+  } else {
+    this._loadError       = new Error('Load local files command is disabled');
+    this._loadError.code  = 'LOCAL_FILES_DISABLED';
+    this._loadError.fatal = false;
+
+    this.emit('packet', new Packets.EmptyPacket());
+  }
+};
+
+Query.prototype['ResultSetHeaderPacket'] = function(packet) {
+  this._resultSet = new ResultSet(packet);
+};
+
+Query.prototype['FieldPacket'] = function(packet) {
+  this._resultSet.fieldPackets.push(packet);
+};
+
+Query.prototype['EofPacket'] = function(packet) {
+  this._resultSet.eofPackets.push(packet);
+
+  if (this._resultSet.eofPackets.length === 1 && !this._callback) {
+    this.emit('fields', this._resultSet.fieldPackets, this._index);
+  }
+
+  if (this._resultSet.eofPackets.length !== 2) {
+    return;
+  }
+
+  if (this._callback) {
+    this._results.push(this._resultSet.rows);
+    this._fields.push(this._resultSet.fieldPackets);
+  }
+
+  this._index++;
+  this._resultSet = null;
+  this._handleFinalResultPacket(packet);
+};
+
+Query.prototype._handleFinalResultPacket = function(packet) {
+  if (packet.serverStatus & ServerStatus.SERVER_MORE_RESULTS_EXISTS) {
+    return;
+  }
+
+  var results = (this._results.length > 1)
+    ? this._results
+    : this._results[0];
+
+  var fields = (this._fields.length > 1)
+    ? this._fields
+    : this._fields[0];
+
+  this.end(this._loadError, results, fields);
+};
+
+Query.prototype['RowDataPacket'] = function(packet, parser, connection) {
+  packet.parse(parser, this._resultSet.fieldPackets, this.typeCast, this.nestTables, connection);
+
+  if (this._callback) {
+    this._resultSet.rows.push(packet);
+  } else {
+    this.emit('result', packet, this._index);
+  }
+};
+
+Query.prototype._sendLocalDataFile = function(path) {
+  var self = this;
+  var localStream = fs.createReadStream(path, {
+    flag      : 'r',
+    encoding  : null,
+    autoClose : true
+  });
+
+  this.on('pause', function () {
+    localStream.pause();
+  });
+
+  this.on('resume', function () {
+    localStream.resume();
+  });
+
+  localStream.on('data', function (data) {
+    self.emit('packet', new Packets.LocalDataFilePacket(data));
+  });
+
+  localStream.on('error', function (err) {
+    self._loadError = err;
+    localStream.emit('end');
+  });
+
+  localStream.on('end', function () {
+    self.emit('packet', new Packets.EmptyPacket());
+  });
+};
+
+Query.prototype.stream = function(options) {
+  var self = this;
+
+  options = options || {};
+  options.objectMode = true;
+
+  var stream = new Readable(options);
+
+  stream._read = function() {
+    self._connection && self._connection.resume();
+  };
+
+  stream.once('end', function() {
+    process.nextTick(function () {
+      stream.emit('close');
+    });
+  });
+
+  this.on('result', function(row, i) {
+    if (!stream.push(row)) self._connection.pause();
+    stream.emit('result', row, i);  // replicate old emitter
+  });
+
+  this.on('error', function(err) {
+    stream.emit('error', err);  // Pass on any errors
+  });
+
+  this.on('end', function() {
+    stream.push(null);  // pushing null, indicating EOF
+  });
+
+  this.on('fields', function(fields, i) {
+    stream.emit('fields', fields, i);  // replicate old emitter
+  });
+
+  return stream;
+};

+ 40 - 0
test_two_list/Quit.js

@@ -0,0 +1,40 @@
+var Sequence = require('./Sequence');
+var Util     = require('util');
+var Packets  = require('../packets');
+
+module.exports = Quit;
+Util.inherits(Quit, Sequence);
+function Quit(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  Sequence.call(this, options, callback);
+
+  this._started = false;
+}
+
+Quit.prototype.end = function end(err) {
+  if (this._ended) {
+    return;
+  }
+
+  if (!this._started) {
+    Sequence.prototype.end.call(this, err);
+    return;
+  }
+
+  if (err && err.code === 'ECONNRESET' && err.syscall === 'read') {
+    // Ignore read errors after packet sent
+    Sequence.prototype.end.call(this);
+    return;
+  }
+
+  Sequence.prototype.end.call(this, err);
+};
+
+Quit.prototype.start = function() {
+  this._started = true;
+  this.emit('packet', new Packets.ComQuitPacket());
+};

+ 53 - 0
test_two_list/README.md

@@ -0,0 +1,53 @@
+util-deprecate
+==============
+### The Node.js `util.deprecate()` function with browser support
+
+In Node.js, this module simply re-exports the `util.deprecate()` function.
+
+In the web browser (i.e. via browserify), a browser-specific implementation
+of the `util.deprecate()` function is used.
+
+
+## API
+
+A `deprecate()` function is the only thing exposed by this module.
+
+``` javascript
+// setup:
+exports.foo = deprecate(foo, 'foo() is deprecated, use bar() instead');
+
+
+// users see:
+foo();
+// foo() is deprecated, use bar() instead
+foo();
+foo();
+```
+
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

Файловите разлики са ограничени, защото са твърде много
+ 1548 - 0
test_two_list/Readme.md


+ 7 - 0
test_two_list/ResultSet.js

@@ -0,0 +1,7 @@
+module.exports = ResultSet;
+function ResultSet(resultSetHeaderPacket) {
+  this.resultSetHeaderPacket = resultSetHeaderPacket;
+  this.fieldPackets          = [];
+  this.eofPackets            = [];
+  this.rows                  = [];
+}

+ 14 - 0
test_two_list/ResultSetHeaderPacket.js

@@ -0,0 +1,14 @@
+module.exports = ResultSetHeaderPacket;
+function ResultSetHeaderPacket(options) {
+  options = options || {};
+
+  this.fieldCount = options.fieldCount;
+}
+
+ResultSetHeaderPacket.prototype.parse = function(parser) {
+  this.fieldCount = parser.parseLengthCodedNumber();
+};
+
+ResultSetHeaderPacket.prototype.write = function(writer) {
+  writer.writeLengthCodedNumber(this.fieldCount);
+};

+ 130 - 0
test_two_list/RowDataPacket.js

@@ -0,0 +1,130 @@
+var Types                        = require('../constants/types');
+var Charsets                     = require('../constants/charsets');
+var Field                        = require('./Field');
+var IEEE_754_BINARY_64_PRECISION = Math.pow(2, 53);
+
+module.exports = RowDataPacket;
+function RowDataPacket() {
+}
+
+Object.defineProperty(RowDataPacket.prototype, 'parse', {
+  configurable : true,
+  enumerable   : false,
+  value        : parse
+});
+
+Object.defineProperty(RowDataPacket.prototype, '_typeCast', {
+  configurable : true,
+  enumerable   : false,
+  value        : typeCast
+});
+
+function parse(parser, fieldPackets, typeCast, nestTables, connection) {
+  var self = this;
+  var next = function () {
+    return self._typeCast(fieldPacket, parser, connection.config.timezone, connection.config.supportBigNumbers, connection.config.bigNumberStrings, connection.config.dateStrings);
+  };
+
+  for (var i = 0; i < fieldPackets.length; i++) {
+    var fieldPacket = fieldPackets[i];
+    var value;
+
+    if (typeof typeCast === 'function') {
+      value = typeCast.apply(connection, [ new Field({ packet: fieldPacket, parser: parser }), next ]);
+    } else {
+      value = (typeCast)
+        ? this._typeCast(fieldPacket, parser, connection.config.timezone, connection.config.supportBigNumbers, connection.config.bigNumberStrings, connection.config.dateStrings)
+        : ( (fieldPacket.charsetNr === Charsets.BINARY)
+          ? parser.parseLengthCodedBuffer()
+          : parser.parseLengthCodedString() );
+    }
+
+    if (typeof nestTables === 'string' && nestTables.length) {
+      this[fieldPacket.table + nestTables + fieldPacket.name] = value;
+    } else if (nestTables) {
+      this[fieldPacket.table] = this[fieldPacket.table] || {};
+      this[fieldPacket.table][fieldPacket.name] = value;
+    } else {
+      this[fieldPacket.name] = value;
+    }
+  }
+}
+
+function typeCast(field, parser, timeZone, supportBigNumbers, bigNumberStrings, dateStrings) {
+  var numberString;
+
+  switch (field.type) {
+    case Types.TIMESTAMP:
+    case Types.TIMESTAMP2:
+    case Types.DATE:
+    case Types.DATETIME:
+    case Types.DATETIME2:
+    case Types.NEWDATE:
+      var dateString = parser.parseLengthCodedString();
+
+      if (typeMatch(field.type, dateStrings)) {
+        return dateString;
+      }
+
+      if (dateString === null) {
+        return null;
+      }
+
+      var originalString = dateString;
+      if (field.type === Types.DATE) {
+        dateString += ' 00:00:00';
+      }
+
+      if (timeZone !== 'local') {
+        dateString += ' ' + timeZone;
+      }
+
+      var dt = new Date(dateString);
+      if (isNaN(dt.getTime())) {
+        return originalString;
+      }
+
+      return dt;
+    case Types.TINY:
+    case Types.SHORT:
+    case Types.LONG:
+    case Types.INT24:
+    case Types.YEAR:
+    case Types.FLOAT:
+    case Types.DOUBLE:
+      numberString = parser.parseLengthCodedString();
+      return (numberString === null || (field.zeroFill && numberString[0] === '0'))
+        ? numberString : Number(numberString);
+    case Types.NEWDECIMAL:
+    case Types.LONGLONG:
+      numberString = parser.parseLengthCodedString();
+      return (numberString === null || (field.zeroFill && numberString[0] === '0'))
+        ? numberString
+        : ((supportBigNumbers && (bigNumberStrings || (Number(numberString) >= IEEE_754_BINARY_64_PRECISION) || Number(numberString) <= -IEEE_754_BINARY_64_PRECISION))
+          ? numberString
+          : Number(numberString));
+    case Types.BIT:
+      return parser.parseLengthCodedBuffer();
+    case Types.STRING:
+    case Types.VAR_STRING:
+    case Types.TINY_BLOB:
+    case Types.MEDIUM_BLOB:
+    case Types.LONG_BLOB:
+    case Types.BLOB:
+      return (field.charsetNr === Charsets.BINARY)
+        ? parser.parseLengthCodedBuffer()
+        : parser.parseLengthCodedString();
+    case Types.GEOMETRY:
+      return parser.parseGeometryValue();
+    default:
+      return parser.parseLengthCodedString();
+  }
+}
+
+function typeMatch(type, list) {
+  if (Array.isArray(list)) {
+    return list.indexOf(Types[type]) !== -1;
+  } else {
+    return Boolean(list);
+  }
+}

+ 27 - 0
test_two_list/SSLRequestPacket.js

@@ -0,0 +1,27 @@
+// http://dev.mysql.com/doc/internals/en/ssl.html
+// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest
+
+var ClientConstants = require('../constants/client');
+
+module.exports = SSLRequestPacket;
+
+function SSLRequestPacket(options) {
+  options = options || {};
+  this.clientFlags   = options.clientFlags | ClientConstants.CLIENT_SSL;
+  this.maxPacketSize = options.maxPacketSize;
+  this.charsetNumber = options.charsetNumber;
+}
+
+SSLRequestPacket.prototype.parse = function(parser) {
+  // TODO: check SSLRequest packet v41 vs pre v41
+  this.clientFlags   = parser.parseUnsignedNumber(4);
+  this.maxPacketSize = parser.parseUnsignedNumber(4);
+  this.charsetNumber = parser.parseUnsignedNumber(1);
+};
+
+SSLRequestPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(4, this.clientFlags);
+  writer.writeUnsignedNumber(4, this.maxPacketSize);
+  writer.writeUnsignedNumber(1, this.charsetNumber);
+  writer.writeFiller(23);
+};

+ 125 - 0
test_two_list/Sequence.js

@@ -0,0 +1,125 @@
+var Util           = require('util');
+var EventEmitter   = require('events').EventEmitter;
+var Packets        = require('../packets');
+var ErrorConstants = require('../constants/errors');
+var Timer          = require('../Timer');
+
+// istanbul ignore next: Node.js < 0.10 not covered
+var listenerCount = EventEmitter.listenerCount
+  || function(emitter, type){ return emitter.listeners(type).length; };
+
+var LONG_STACK_DELIMITER = '\n    --------------------\n';
+
+module.exports = Sequence;
+Util.inherits(Sequence, EventEmitter);
+function Sequence(options, callback) {
+  if (typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  EventEmitter.call(this);
+
+  options = options || {};
+
+  this._callback = callback;
+  this._callSite = null;
+  this._ended    = false;
+  this._timeout  = options.timeout;
+  this._timer    = new Timer(this);
+}
+
+Sequence.determinePacket = function(byte) {
+  switch (byte) {
+    case 0x00: return Packets.OkPacket;
+    case 0xfe: return Packets.EofPacket;
+    case 0xff: return Packets.ErrorPacket;
+    default:   return undefined;
+  }
+};
+
+Sequence.prototype.hasErrorHandler = function() {
+  return Boolean(this._callback) || listenerCount(this, 'error') > 1;
+};
+
+Sequence.prototype._packetToError = function(packet) {
+  var code = ErrorConstants[packet.errno] || 'UNKNOWN_CODE_PLEASE_REPORT';
+  var err  = new Error(code + ': ' + packet.message);
+  err.code = code;
+  err.errno = packet.errno;
+
+  err.sqlMessage = packet.message;
+  err.sqlState   = packet.sqlState;
+
+  return err;
+};
+
+Sequence.prototype.end = function(err) {
+  if (this._ended) {
+    return;
+  }
+
+  this._ended = true;
+
+  if (err) {
+    this._addLongStackTrace(err);
+  }
+
+  // Without this we are leaking memory. This problem was introduced in
+  // 8189925374e7ce3819bbe88b64c7b15abac96b16. I suspect that the error object
+  // causes a cyclic reference that the GC does not detect properly, but I was
+  // unable to produce a standalone version of this leak. This would be a great
+  // challenge for somebody interested in difficult problems : )!
+  this._callSite = null;
+
+  // try...finally for exception safety
+  try {
+    if (err) {
+      this.emit('error', err);
+    }
+  } finally {
+    try {
+      if (this._callback) {
+        this._callback.apply(this, arguments);
+      }
+    } finally {
+      this.emit('end');
+    }
+  }
+};
+
+Sequence.prototype['OkPacket'] = function(packet) {
+  this.end(null, packet);
+};
+
+Sequence.prototype['ErrorPacket'] = function(packet) {
+  this.end(this._packetToError(packet));
+};
+
+// Implemented by child classes
+Sequence.prototype.start = function() {};
+
+Sequence.prototype._addLongStackTrace = function _addLongStackTrace(err) {
+  var callSiteStack = this._callSite && this._callSite.stack;
+
+  if (!callSiteStack || typeof callSiteStack !== 'string') {
+    // No recorded call site
+    return;
+  }
+
+  if (err.stack.indexOf(LONG_STACK_DELIMITER) !== -1) {
+    // Error stack already looks long
+    return;
+  }
+
+  var index = callSiteStack.indexOf('\n');
+
+  if (index !== -1) {
+    // Append recorded call site
+    err.stack += LONG_STACK_DELIMITER + callSiteStack.substr(index + 1);
+  }
+};
+
+Sequence.prototype._onTimeout = function _onTimeout() {
+  this.emit('timeout');
+};

+ 1 - 0
test_two_list/SqlString.js

@@ -0,0 +1 @@
+module.exports = require('sqlstring');

+ 30 - 0
test_two_list/Statistics.js

@@ -0,0 +1,30 @@
+var Sequence = require('./Sequence');
+var Util     = require('util');
+var Packets  = require('../packets');
+
+module.exports = Statistics;
+Util.inherits(Statistics, Sequence);
+function Statistics(options, callback) {
+  if (!callback && typeof options === 'function') {
+    callback = options;
+    options = {};
+  }
+
+  Sequence.call(this, options, callback);
+}
+
+Statistics.prototype.start = function() {
+  this.emit('packet', new Packets.ComStatisticsPacket());
+};
+
+Statistics.prototype['StatisticsPacket'] = function (packet) {
+  this.end(null, packet);
+};
+
+Statistics.prototype.determinePacket = function determinePacket(firstByte) {
+  if (firstByte === 0x55) {
+    return Packets.StatisticsPacket;
+  }
+
+  return undefined;
+};

+ 20 - 0
test_two_list/StatisticsPacket.js

@@ -0,0 +1,20 @@
+module.exports = StatisticsPacket;
+function StatisticsPacket() {
+  this.message      = undefined;
+}
+
+StatisticsPacket.prototype.parse = function(parser) {
+  this.message      = parser.parsePacketTerminatedString();
+
+  var items = this.message.split(/\s\s/);
+  for (var i = 0; i < items.length; i++) {
+    var m = items[i].match(/^(.+)\:\s+(.+)$/);
+    if (m !== null) {
+      this[m[1].toLowerCase().replace(/\s/g, '_')] = Number(m[2]);
+    }
+  }
+};
+
+StatisticsPacket.prototype.write = function(writer) {
+  writer.writeString(this.message);
+};

+ 33 - 0
test_two_list/Timer.js

@@ -0,0 +1,33 @@
+var Timers = require('timers');
+
+module.exports = Timer;
+function Timer(object) {
+  this._object  = object;
+  this._timeout = null;
+}
+
+Timer.prototype.active = function active() {
+  if (this._timeout) {
+    if (this._timeout.refresh) {
+      this._timeout.refresh();
+    } else {
+      Timers.active(this._timeout);
+    }
+  }
+};
+
+Timer.prototype.start = function start(msecs) {
+  this.stop();
+  this._timeout = Timers.setTimeout(this._onTimeout.bind(this), msecs);
+};
+
+Timer.prototype.stop = function stop() {
+  if (this._timeout) {
+    Timers.clearTimeout(this._timeout);
+    this._timeout = null;
+  }
+};
+
+Timer.prototype._onTimeout = function _onTimeout() {
+  return this._object._onTimeout();
+};

+ 14 - 0
test_two_list/UseOldPasswordPacket.js

@@ -0,0 +1,14 @@
+module.exports = UseOldPasswordPacket;
+function UseOldPasswordPacket(options) {
+  options = options || {};
+
+  this.firstByte = options.firstByte || 0xfe;
+}
+
+UseOldPasswordPacket.prototype.parse = function(parser) {
+  this.firstByte = parser.parseUnsignedNumber(1);
+};
+
+UseOldPasswordPacket.prototype.write = function(writer) {
+  writer.writeUnsignedNumber(1, this.firstByte);
+};

+ 131 - 0
test_two_list/_stream_duplex.js

@@ -0,0 +1,131 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// a duplex stream is just a stream that is both readable and writable.
+// Since JS doesn't have multiple prototypal inheritance, this class
+// prototypally inherits from Readable, and then parasitically from
+// Writable.
+
+'use strict';
+
+/*<replacement>*/
+
+var pna = require('process-nextick-args');
+/*</replacement>*/
+
+/*<replacement>*/
+var objectKeys = Object.keys || function (obj) {
+  var keys = [];
+  for (var key in obj) {
+    keys.push(key);
+  }return keys;
+};
+/*</replacement>*/
+
+module.exports = Duplex;
+
+/*<replacement>*/
+var util = Object.create(require('core-util-is'));
+util.inherits = require('inherits');
+/*</replacement>*/
+
+var Readable = require('./_stream_readable');
+var Writable = require('./_stream_writable');
+
+util.inherits(Duplex, Readable);
+
+{
+  // avoid scope creep, the keys array can then be collected
+  var keys = objectKeys(Writable.prototype);
+  for (var v = 0; v < keys.length; v++) {
+    var method = keys[v];
+    if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
+  }
+}
+
+function Duplex(options) {
+  if (!(this instanceof Duplex)) return new Duplex(options);
+
+  Readable.call(this, options);
+  Writable.call(this, options);
+
+  if (options && options.readable === false) this.readable = false;
+
+  if (options && options.writable === false) this.writable = false;
+
+  this.allowHalfOpen = true;
+  if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
+
+  this.once('end', onend);
+}
+
+Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
+  // making it explicit this property is not enumerable
+  // because otherwise some prototype manipulation in
+  // userland will fail
+  enumerable: false,
+  get: function () {
+    return this._writableState.highWaterMark;
+  }
+});
+
+// the no-half-open enforcer
+function onend() {
+  // if we allow half-open state, or if the writable side ended,
+  // then we're ok.
+  if (this.allowHalfOpen || this._writableState.ended) return;
+
+  // no more data can be written.
+  // But allow more writes to happen in this tick.
+  pna.nextTick(onEndNT, this);
+}
+
+function onEndNT(self) {
+  self.end();
+}
+
+Object.defineProperty(Duplex.prototype, 'destroyed', {
+  get: function () {
+    if (this._readableState === undefined || this._writableState === undefined) {
+      return false;
+    }
+    return this._readableState.destroyed && this._writableState.destroyed;
+  },
+  set: function (value) {
+    // we ignore the value if the stream
+    // has not been initialized yet
+    if (this._readableState === undefined || this._writableState === undefined) {
+      return;
+    }
+
+    // backward compatibility, the user is explicitly
+    // managing destroyed
+    this._readableState.destroyed = value;
+    this._writableState.destroyed = value;
+  }
+});
+
+Duplex.prototype._destroy = function (err, cb) {
+  this.push(null);
+  this.end();
+
+  pna.nextTick(cb, err);
+};

+ 47 - 0
test_two_list/_stream_passthrough.js

@@ -0,0 +1,47 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// a passthrough stream.
+// basically just the most minimal sort of Transform stream.
+// Every written chunk gets output as-is.
+
+'use strict';
+
+module.exports = PassThrough;
+
+var Transform = require('./_stream_transform');
+
+/*<replacement>*/
+var util = Object.create(require('core-util-is'));
+util.inherits = require('inherits');
+/*</replacement>*/
+
+util.inherits(PassThrough, Transform);
+
+function PassThrough(options) {
+  if (!(this instanceof PassThrough)) return new PassThrough(options);
+
+  Transform.call(this, options);
+}
+
+PassThrough.prototype._transform = function (chunk, encoding, cb) {
+  cb(null, chunk);
+};

Файловите разлики са ограничени, защото са твърде много
+ 1019 - 0
test_two_list/_stream_readable.js


+ 214 - 0
test_two_list/_stream_transform.js

@@ -0,0 +1,214 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// a transform stream is a readable/writable stream where you do
+// something with the data.  Sometimes it's called a "filter",
+// but that's not a great name for it, since that implies a thing where
+// some bits pass through, and others are simply ignored.  (That would
+// be a valid example of a transform, of course.)
+//
+// While the output is causally related to the input, it's not a
+// necessarily symmetric or synchronous transformation.  For example,
+// a zlib stream might take multiple plain-text writes(), and then
+// emit a single compressed chunk some time in the future.
+//
+// Here's how this works:
+//
+// The Transform stream has all the aspects of the readable and writable
+// stream classes.  When you write(chunk), that calls _write(chunk,cb)
+// internally, and returns false if there's a lot of pending writes
+// buffered up.  When you call read(), that calls _read(n) until
+// there's enough pending readable data buffered up.
+//
+// In a transform stream, the written data is placed in a buffer.  When
+// _read(n) is called, it transforms the queued up data, calling the
+// buffered _write cb's as it consumes chunks.  If consuming a single
+// written chunk would result in multiple output chunks, then the first
+// outputted bit calls the readcb, and subsequent chunks just go into
+// the read buffer, and will cause it to emit 'readable' if necessary.
+//
+// This way, back-pressure is actually determined by the reading side,
+// since _read has to be called to start processing a new chunk.  However,
+// a pathological inflate type of transform can cause excessive buffering
+// here.  For example, imagine a stream where every byte of input is
+// interpreted as an integer from 0-255, and then results in that many
+// bytes of output.  Writing the 4 bytes {ff,ff,ff,ff} would result in
+// 1kb of data being output.  In this case, you could write a very small
+// amount of input, and end up with a very large amount of output.  In
+// such a pathological inflating mechanism, there'd be no way to tell
+// the system to stop doing the transform.  A single 4MB write could
+// cause the system to run out of memory.
+//
+// However, even in such a pathological case, only a single written chunk
+// would be consumed, and then the rest would wait (un-transformed) until
+// the results of the previous transformed chunk were consumed.
+
+'use strict';
+
+module.exports = Transform;
+
+var Duplex = require('./_stream_duplex');
+
+/*<replacement>*/
+var util = Object.create(require('core-util-is'));
+util.inherits = require('inherits');
+/*</replacement>*/
+
+util.inherits(Transform, Duplex);
+
+function afterTransform(er, data) {
+  var ts = this._transformState;
+  ts.transforming = false;
+
+  var cb = ts.writecb;
+
+  if (!cb) {
+    return this.emit('error', new Error('write callback called multiple times'));
+  }
+
+  ts.writechunk = null;
+  ts.writecb = null;
+
+  if (data != null) // single equals check for both `null` and `undefined`
+    this.push(data);
+
+  cb(er);
+
+  var rs = this._readableState;
+  rs.reading = false;
+  if (rs.needReadable || rs.length < rs.highWaterMark) {
+    this._read(rs.highWaterMark);
+  }
+}
+
+function Transform(options) {
+  if (!(this instanceof Transform)) return new Transform(options);
+
+  Duplex.call(this, options);
+
+  this._transformState = {
+    afterTransform: afterTransform.bind(this),
+    needTransform: false,
+    transforming: false,
+    writecb: null,
+    writechunk: null,
+    writeencoding: null
+  };
+
+  // start out asking for a readable event once data is transformed.
+  this._readableState.needReadable = true;
+
+  // we have implemented the _read method, and done the other things
+  // that Readable wants before the first _read call, so unset the
+  // sync guard flag.
+  this._readableState.sync = false;
+
+  if (options) {
+    if (typeof options.transform === 'function') this._transform = options.transform;
+
+    if (typeof options.flush === 'function') this._flush = options.flush;
+  }
+
+  // When the writable side finishes, then flush out anything remaining.
+  this.on('prefinish', prefinish);
+}
+
+function prefinish() {
+  var _this = this;
+
+  if (typeof this._flush === 'function') {
+    this._flush(function (er, data) {
+      done(_this, er, data);
+    });
+  } else {
+    done(this, null, null);
+  }
+}
+
+Transform.prototype.push = function (chunk, encoding) {
+  this._transformState.needTransform = false;
+  return Duplex.prototype.push.call(this, chunk, encoding);
+};
+
+// This is the part where you do stuff!
+// override this function in implementation classes.
+// 'chunk' is an input chunk.
+//
+// Call `push(newChunk)` to pass along transformed output
+// to the readable side.  You may call 'push' zero or more times.
+//
+// Call `cb(err)` when you are done with this chunk.  If you pass
+// an error, then that'll put the hurt on the whole operation.  If you
+// never call cb(), then you'll never get another chunk.
+Transform.prototype._transform = function (chunk, encoding, cb) {
+  throw new Error('_transform() is not implemented');
+};
+
+Transform.prototype._write = function (chunk, encoding, cb) {
+  var ts = this._transformState;
+  ts.writecb = cb;
+  ts.writechunk = chunk;
+  ts.writeencoding = encoding;
+  if (!ts.transforming) {
+    var rs = this._readableState;
+    if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
+  }
+};
+
+// Doesn't matter what the args are here.
+// _transform does all the work.
+// That we got here means that the readable side wants more data.
+Transform.prototype._read = function (n) {
+  var ts = this._transformState;
+
+  if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
+    ts.transforming = true;
+    this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
+  } else {
+    // mark that we need a transform, so that any data that comes in
+    // will get processed, now that we've asked for it.
+    ts.needTransform = true;
+  }
+};
+
+Transform.prototype._destroy = function (err, cb) {
+  var _this2 = this;
+
+  Duplex.prototype._destroy.call(this, err, function (err2) {
+    cb(err2);
+    _this2.emit('close');
+  });
+};
+
+function done(stream, er, data) {
+  if (er) return stream.emit('error', er);
+
+  if (data != null) // single equals check for both `null` and `undefined`
+    stream.push(data);
+
+  // if there's nothing in the write buffer, then that means
+  // that nothing more will ever be provided
+  if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
+
+  if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
+
+  return stream.push(null);
+}

+ 687 - 0
test_two_list/_stream_writable.js

@@ -0,0 +1,687 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// A bit simpler than readable streams.
+// Implement an async ._write(chunk, encoding, cb), and it'll handle all
+// the drain event emission and buffering.
+
+'use strict';
+
+/*<replacement>*/
+
+var pna = require('process-nextick-args');
+/*</replacement>*/
+
+module.exports = Writable;
+
+/* <replacement> */
+function WriteReq(chunk, encoding, cb) {
+  this.chunk = chunk;
+  this.encoding = encoding;
+  this.callback = cb;
+  this.next = null;
+}
+
+// It seems a linked list but it is not
+// there will be only 2 of these for each stream
+function CorkedRequest(state) {
+  var _this = this;
+
+  this.next = null;
+  this.entry = null;
+  this.finish = function () {
+    onCorkedFinish(_this, state);
+  };
+}
+/* </replacement> */
+
+/*<replacement>*/
+var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
+/*</replacement>*/
+
+/*<replacement>*/
+var Duplex;
+/*</replacement>*/
+
+Writable.WritableState = WritableState;
+
+/*<replacement>*/
+var util = Object.create(require('core-util-is'));
+util.inherits = require('inherits');
+/*</replacement>*/
+
+/*<replacement>*/
+var internalUtil = {
+  deprecate: require('util-deprecate')
+};
+/*</replacement>*/
+
+/*<replacement>*/
+var Stream = require('./internal/streams/stream');
+/*</replacement>*/
+
+/*<replacement>*/
+
+var Buffer = require('safe-buffer').Buffer;
+var OurUint8Array = global.Uint8Array || function () {};
+function _uint8ArrayToBuffer(chunk) {
+  return Buffer.from(chunk);
+}
+function _isUint8Array(obj) {
+  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
+}
+
+/*</replacement>*/
+
+var destroyImpl = require('./internal/streams/destroy');
+
+util.inherits(Writable, Stream);
+
+function nop() {}
+
+function WritableState(options, stream) {
+  Duplex = Duplex || require('./_stream_duplex');
+
+  options = options || {};
+
+  // Duplex streams are both readable and writable, but share
+  // the same options object.
+  // However, some cases require setting options to different
+  // values for the readable and the writable sides of the duplex stream.
+  // These options can be provided separately as readableXXX and writableXXX.
+  var isDuplex = stream instanceof Duplex;
+
+  // object stream flag to indicate whether or not this stream
+  // contains buffers or objects.
+  this.objectMode = !!options.objectMode;
+
+  if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
+
+  // the point at which write() starts returning false
+  // Note: 0 is a valid value, means that we always return false if
+  // the entire buffer is not flushed immediately on write()
+  var hwm = options.highWaterMark;
+  var writableHwm = options.writableHighWaterMark;
+  var defaultHwm = this.objectMode ? 16 : 16 * 1024;
+
+  if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
+
+  // cast to ints.
+  this.highWaterMark = Math.floor(this.highWaterMark);
+
+  // if _final has been called
+  this.finalCalled = false;
+
+  // drain event flag.
+  this.needDrain = false;
+  // at the start of calling end()
+  this.ending = false;
+  // when end() has been called, and returned
+  this.ended = false;
+  // when 'finish' is emitted
+  this.finished = false;
+
+  // has it been destroyed
+  this.destroyed = false;
+
+  // should we decode strings into buffers before passing to _write?
+  // this is here so that some node-core streams can optimize string
+  // handling at a lower level.
+  var noDecode = options.decodeStrings === false;
+  this.decodeStrings = !noDecode;
+
+  // Crypto is kind of old and crusty.  Historically, its default string
+  // encoding is 'binary' so we have to make this configurable.
+  // Everything else in the universe uses 'utf8', though.
+  this.defaultEncoding = options.defaultEncoding || 'utf8';
+
+  // not an actual buffer we keep track of, but a measurement
+  // of how much we're waiting to get pushed to some underlying
+  // socket or file.
+  this.length = 0;
+
+  // a flag to see when we're in the middle of a write.
+  this.writing = false;
+
+  // when true all writes will be buffered until .uncork() call
+  this.corked = 0;
+
+  // a flag to be able to tell if the onwrite cb is called immediately,
+  // or on a later tick.  We set this to true at first, because any
+  // actions that shouldn't happen until "later" should generally also
+  // not happen before the first write call.
+  this.sync = true;
+
+  // a flag to know if we're processing previously buffered items, which
+  // may call the _write() callback in the same tick, so that we don't
+  // end up in an overlapped onwrite situation.
+  this.bufferProcessing = false;
+
+  // the callback that's passed to _write(chunk,cb)
+  this.onwrite = function (er) {
+    onwrite(stream, er);
+  };
+
+  // the callback that the user supplies to write(chunk,encoding,cb)
+  this.writecb = null;
+
+  // the amount that is being written when _write is called.
+  this.writelen = 0;
+
+  this.bufferedRequest = null;
+  this.lastBufferedRequest = null;
+
+  // number of pending user-supplied write callbacks
+  // this must be 0 before 'finish' can be emitted
+  this.pendingcb = 0;
+
+  // emit prefinish if the only thing we're waiting for is _write cbs
+  // This is relevant for synchronous Transform streams
+  this.prefinished = false;
+
+  // True if the error was already emitted and should not be thrown again
+  this.errorEmitted = false;
+
+  // count buffered requests
+  this.bufferedRequestCount = 0;
+
+  // allocate the first CorkedRequest, there is always
+  // one allocated and free to use, and we maintain at most two
+  this.corkedRequestsFree = new CorkedRequest(this);
+}
+
+WritableState.prototype.getBuffer = function getBuffer() {
+  var current = this.bufferedRequest;
+  var out = [];
+  while (current) {
+    out.push(current);
+    current = current.next;
+  }
+  return out;
+};
+
+(function () {
+  try {
+    Object.defineProperty(WritableState.prototype, 'buffer', {
+      get: internalUtil.deprecate(function () {
+        return this.getBuffer();
+      }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
+    });
+  } catch (_) {}
+})();
+
+// Test _writableState for inheritance to account for Duplex streams,
+// whose prototype chain only points to Readable.
+var realHasInstance;
+if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
+  realHasInstance = Function.prototype[Symbol.hasInstance];
+  Object.defineProperty(Writable, Symbol.hasInstance, {
+    value: function (object) {
+      if (realHasInstance.call(this, object)) return true;
+      if (this !== Writable) return false;
+
+      return object && object._writableState instanceof WritableState;
+    }
+  });
+} else {
+  realHasInstance = function (object) {
+    return object instanceof this;
+  };
+}
+
+function Writable(options) {
+  Duplex = Duplex || require('./_stream_duplex');
+
+  // Writable ctor is applied to Duplexes, too.
+  // `realHasInstance` is necessary because using plain `instanceof`
+  // would return false, as no `_writableState` property is attached.
+
+  // Trying to use the custom `instanceof` for Writable here will also break the
+  // Node.js LazyTransform implementation, which has a non-trivial getter for
+  // `_writableState` that would lead to infinite recursion.
+  if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
+    return new Writable(options);
+  }
+
+  this._writableState = new WritableState(options, this);
+
+  // legacy.
+  this.writable = true;
+
+  if (options) {
+    if (typeof options.write === 'function') this._write = options.write;
+
+    if (typeof options.writev === 'function') this._writev = options.writev;
+
+    if (typeof options.destroy === 'function') this._destroy = options.destroy;
+
+    if (typeof options.final === 'function') this._final = options.final;
+  }
+
+  Stream.call(this);
+}
+
+// Otherwise people can pipe Writable streams, which is just wrong.
+Writable.prototype.pipe = function () {
+  this.emit('error', new Error('Cannot pipe, not readable'));
+};
+
+function writeAfterEnd(stream, cb) {
+  var er = new Error('write after end');
+  // TODO: defer error events consistently everywhere, not just the cb
+  stream.emit('error', er);
+  pna.nextTick(cb, er);
+}
+
+// Checks that a user-supplied chunk is valid, especially for the particular
+// mode the stream is in. Currently this means that `null` is never accepted
+// and undefined/non-string values are only allowed in object mode.
+function validChunk(stream, state, chunk, cb) {
+  var valid = true;
+  var er = false;
+
+  if (chunk === null) {
+    er = new TypeError('May not write null values to stream');
+  } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
+    er = new TypeError('Invalid non-string/buffer chunk');
+  }
+  if (er) {
+    stream.emit('error', er);
+    pna.nextTick(cb, er);
+    valid = false;
+  }
+  return valid;
+}
+
+Writable.prototype.write = function (chunk, encoding, cb) {
+  var state = this._writableState;
+  var ret = false;
+  var isBuf = !state.objectMode && _isUint8Array(chunk);
+
+  if (isBuf && !Buffer.isBuffer(chunk)) {
+    chunk = _uint8ArrayToBuffer(chunk);
+  }
+
+  if (typeof encoding === 'function') {
+    cb = encoding;
+    encoding = null;
+  }
+
+  if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
+
+  if (typeof cb !== 'function') cb = nop;
+
+  if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
+    state.pendingcb++;
+    ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
+  }
+
+  return ret;
+};
+
+Writable.prototype.cork = function () {
+  var state = this._writableState;
+
+  state.corked++;
+};
+
+Writable.prototype.uncork = function () {
+  var state = this._writableState;
+
+  if (state.corked) {
+    state.corked--;
+
+    if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
+  }
+};
+
+Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
+  // node::ParseEncoding() requires lower case.
+  if (typeof encoding === 'string') encoding = encoding.toLowerCase();
+  if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
+  this._writableState.defaultEncoding = encoding;
+  return this;
+};
+
+function decodeChunk(state, chunk, encoding) {
+  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
+    chunk = Buffer.from(chunk, encoding);
+  }
+  return chunk;
+}
+
+Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
+  // making it explicit this property is not enumerable
+  // because otherwise some prototype manipulation in
+  // userland will fail
+  enumerable: false,
+  get: function () {
+    return this._writableState.highWaterMark;
+  }
+});
+
+// if we're already writing something, then just put this
+// in the queue, and wait our turn.  Otherwise, call _write
+// If we return false, then we need a drain event, so set that flag.
+function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
+  if (!isBuf) {
+    var newChunk = decodeChunk(state, chunk, encoding);
+    if (chunk !== newChunk) {
+      isBuf = true;
+      encoding = 'buffer';
+      chunk = newChunk;
+    }
+  }
+  var len = state.objectMode ? 1 : chunk.length;
+
+  state.length += len;
+
+  var ret = state.length < state.highWaterMark;
+  // we must ensure that previous needDrain will not be reset to false.
+  if (!ret) state.needDrain = true;
+
+  if (state.writing || state.corked) {
+    var last = state.lastBufferedRequest;
+    state.lastBufferedRequest = {
+      chunk: chunk,
+      encoding: encoding,
+      isBuf: isBuf,
+      callback: cb,
+      next: null
+    };
+    if (last) {
+      last.next = state.lastBufferedRequest;
+    } else {
+      state.bufferedRequest = state.lastBufferedRequest;
+    }
+    state.bufferedRequestCount += 1;
+  } else {
+    doWrite(stream, state, false, len, chunk, encoding, cb);
+  }
+
+  return ret;
+}
+
+function doWrite(stream, state, writev, len, chunk, encoding, cb) {
+  state.writelen = len;
+  state.writecb = cb;
+  state.writing = true;
+  state.sync = true;
+  if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
+  state.sync = false;
+}
+
+function onwriteError(stream, state, sync, er, cb) {
+  --state.pendingcb;
+
+  if (sync) {
+    // defer the callback if we are being called synchronously
+    // to avoid piling up things on the stack
+    pna.nextTick(cb, er);
+    // this can emit finish, and it will always happen
+    // after error
+    pna.nextTick(finishMaybe, stream, state);
+    stream._writableState.errorEmitted = true;
+    stream.emit('error', er);
+  } else {
+    // the caller expect this to happen before if
+    // it is async
+    cb(er);
+    stream._writableState.errorEmitted = true;
+    stream.emit('error', er);
+    // this can emit finish, but finish must
+    // always follow error
+    finishMaybe(stream, state);
+  }
+}
+
+function onwriteStateUpdate(state) {
+  state.writing = false;
+  state.writecb = null;
+  state.length -= state.writelen;
+  state.writelen = 0;
+}
+
+function onwrite(stream, er) {
+  var state = stream._writableState;
+  var sync = state.sync;
+  var cb = state.writecb;
+
+  onwriteStateUpdate(state);
+
+  if (er) onwriteError(stream, state, sync, er, cb);else {
+    // Check if we're actually ready to finish, but don't emit yet
+    var finished = needFinish(state);
+
+    if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
+      clearBuffer(stream, state);
+    }
+
+    if (sync) {
+      /*<replacement>*/
+      asyncWrite(afterWrite, stream, state, finished, cb);
+      /*</replacement>*/
+    } else {
+      afterWrite(stream, state, finished, cb);
+    }
+  }
+}
+
+function afterWrite(stream, state, finished, cb) {
+  if (!finished) onwriteDrain(stream, state);
+  state.pendingcb--;
+  cb();
+  finishMaybe(stream, state);
+}
+
+// Must force callback to be called on nextTick, so that we don't
+// emit 'drain' before the write() consumer gets the 'false' return
+// value, and has a chance to attach a 'drain' listener.
+function onwriteDrain(stream, state) {
+  if (state.length === 0 && state.needDrain) {
+    state.needDrain = false;
+    stream.emit('drain');
+  }
+}
+
+// if there's something in the buffer waiting, then process it
+function clearBuffer(stream, state) {
+  state.bufferProcessing = true;
+  var entry = state.bufferedRequest;
+
+  if (stream._writev && entry && entry.next) {
+    // Fast case, write everything using _writev()
+    var l = state.bufferedRequestCount;
+    var buffer = new Array(l);
+    var holder = state.corkedRequestsFree;
+    holder.entry = entry;
+
+    var count = 0;
+    var allBuffers = true;
+    while (entry) {
+      buffer[count] = entry;
+      if (!entry.isBuf) allBuffers = false;
+      entry = entry.next;
+      count += 1;
+    }
+    buffer.allBuffers = allBuffers;
+
+    doWrite(stream, state, true, state.length, buffer, '', holder.finish);
+
+    // doWrite is almost always async, defer these to save a bit of time
+    // as the hot path ends with doWrite
+    state.pendingcb++;
+    state.lastBufferedRequest = null;
+    if (holder.next) {
+      state.corkedRequestsFree = holder.next;
+      holder.next = null;
+    } else {
+      state.corkedRequestsFree = new CorkedRequest(state);
+    }
+    state.bufferedRequestCount = 0;
+  } else {
+    // Slow case, write chunks one-by-one
+    while (entry) {
+      var chunk = entry.chunk;
+      var encoding = entry.encoding;
+      var cb = entry.callback;
+      var len = state.objectMode ? 1 : chunk.length;
+
+      doWrite(stream, state, false, len, chunk, encoding, cb);
+      entry = entry.next;
+      state.bufferedRequestCount--;
+      // if we didn't call the onwrite immediately, then
+      // it means that we need to wait until it does.
+      // also, that means that the chunk and cb are currently
+      // being processed, so move the buffer counter past them.
+      if (state.writing) {
+        break;
+      }
+    }
+
+    if (entry === null) state.lastBufferedRequest = null;
+  }
+
+  state.bufferedRequest = entry;
+  state.bufferProcessing = false;
+}
+
+Writable.prototype._write = function (chunk, encoding, cb) {
+  cb(new Error('_write() is not implemented'));
+};
+
+Writable.prototype._writev = null;
+
+Writable.prototype.end = function (chunk, encoding, cb) {
+  var state = this._writableState;
+
+  if (typeof chunk === 'function') {
+    cb = chunk;
+    chunk = null;
+    encoding = null;
+  } else if (typeof encoding === 'function') {
+    cb = encoding;
+    encoding = null;
+  }
+
+  if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
+
+  // .end() fully uncorks
+  if (state.corked) {
+    state.corked = 1;
+    this.uncork();
+  }
+
+  // ignore unnecessary end() calls.
+  if (!state.ending && !state.finished) endWritable(this, state, cb);
+};
+
+function needFinish(state) {
+  return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
+}
+function callFinal(stream, state) {
+  stream._final(function (err) {
+    state.pendingcb--;
+    if (err) {
+      stream.emit('error', err);
+    }
+    state.prefinished = true;
+    stream.emit('prefinish');
+    finishMaybe(stream, state);
+  });
+}
+function prefinish(stream, state) {
+  if (!state.prefinished && !state.finalCalled) {
+    if (typeof stream._final === 'function') {
+      state.pendingcb++;
+      state.finalCalled = true;
+      pna.nextTick(callFinal, stream, state);
+    } else {
+      state.prefinished = true;
+      stream.emit('prefinish');
+    }
+  }
+}
+
+function finishMaybe(stream, state) {
+  var need = needFinish(state);
+  if (need) {
+    prefinish(stream, state);
+    if (state.pendingcb === 0) {
+      state.finished = true;
+      stream.emit('finish');
+    }
+  }
+  return need;
+}
+
+function endWritable(stream, state, cb) {
+  state.ending = true;
+  finishMaybe(stream, state);
+  if (cb) {
+    if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
+  }
+  state.ended = true;
+  stream.writable = false;
+}
+
+function onCorkedFinish(corkReq, state, err) {
+  var entry = corkReq.entry;
+  corkReq.entry = null;
+  while (entry) {
+    var cb = entry.callback;
+    state.pendingcb--;
+    cb(err);
+    entry = entry.next;
+  }
+  if (state.corkedRequestsFree) {
+    state.corkedRequestsFree.next = corkReq;
+  } else {
+    state.corkedRequestsFree = corkReq;
+  }
+}
+
+Object.defineProperty(Writable.prototype, 'destroyed', {
+  get: function () {
+    if (this._writableState === undefined) {
+      return false;
+    }
+    return this._writableState.destroyed;
+  },
+  set: function (value) {
+    // we ignore the value if the stream
+    // has not been initialized yet
+    if (!this._writableState) {
+      return;
+    }
+
+    // backward compatibility, the user is explicitly
+    // managing destroyed
+    this._writableState.destroyed = value;
+  }
+});
+
+Writable.prototype.destroy = destroyImpl.destroy;
+Writable.prototype._undestroy = destroyImpl.undestroy;
+Writable.prototype._destroy = function (err, cb) {
+  this.end();
+  cb(err);
+};

+ 128 - 0
test_two_list/app.py

@@ -0,0 +1,128 @@
+from flask import Flask, render_template,request,url_for, redirect
+import pymysql
+import pandas as pd
+import csv
+
+app = Flask(__name__)
+
+
+
+# MySQL configurations
+conn = pymysql.connect(
+    host='127.0.0.1',
+    user='root',
+    password='g53743001',
+    db='erptest',
+    charset='utf8'
+)
+
+
+@app.route('/Inquire_from/',methods=['GET','POST'])
+def Inquire_from():
+    cur1 = conn.cursor()
+    # 獲取欄位資料
+    sql1 = "select DISTINCT 產品 from abc"
+    cur1.execute(sql1)
+    labels1 = cur1.fetchall()
+    labels1 = [g[0] for g in labels1]
+    #print(labels1)
+    
+    cur2 = conn.cursor()
+    # 獲取欄位資料
+    sql2 = "select DISTINCT 系統 from abc"
+    cur2.execute(sql2)
+    labels2 = cur2.fetchall()
+    labels2 = [g[0] for g in labels2]
+    #print(labels2)
+   
+    cur3 = conn.cursor()
+    # 獲取欄位資料
+    sql3 = "select DISTINCT 模組圖名 from abc"
+    cur3.execute(sql3)
+    labels3 = cur3.fetchall()
+    labels3 = [g[0] for g in labels3]
+    #print(labels3)
+   
+    cur4 = conn.cursor()
+    # 獲取欄位資料
+    sql4 = "select DISTINCT 零件圖名 from abc"
+    cur4.execute(sql4)
+    labels4 = cur4.fetchall()
+    labels4 = [g[0] for g in labels4]
+    #print(labels4)
+    
+
+    cur5 = conn.cursor()
+    # 獲取欄位資料
+    sql5 = "select DISTINCT 系統 from abc WHERE 產品 = '乾燥貨櫃' "
+    cur5.execute(sql5)
+    labels5 = cur5.fetchall()
+    labels5 = [g[0] for g in labels5]
+    print(labels5)
+
+
+    if request.method == 'POST':
+        sql = "SHOW FIELDS FROM abc"
+        cur1.execute(sql)
+        labels = cur1.fetchall()
+        labels = [g[0] for g in labels]
+        # ----------------------------------------#
+
+        t1 = request.values['Test1']
+        t2 = request.values['Test2']
+        t3 = request.values['Test3']
+        t4 = request.values['Test4']
+        # print(t1)
+        # print(t2)
+        # print(t3)
+        # print(t4)
+
+
+        cur = conn.cursor()
+
+        #
+        data = 'select * from abc'
+        if t1 == '' and t2 == '' and t3 == '' and t4 == '':
+            pass
+        else:
+            data += ' WHERE '
+            if t1 != '':
+                data += '產品 = \'' + t1 + '\' '
+                if t2 != '':
+                    data += ' AND '
+                elif t3 != '':
+                    data += ' AND '
+                elif t4 != '':
+                    data += ' AND '
+            if t2 != '':
+                data += '系統 = \'' + t2 + '\' '
+                if t3 != '':
+                    data += ' AND '
+                elif t4 != '':
+                    data += ' AND '
+
+            if t3 != '':
+                data += '模組圖名 = \'' + t3 + '\' '
+                if t4 != '':
+                    data += ' AND '
+            if t4 != '': data += '零件圖名 = \'' + t4 + '\' '
+
+        print(data)
+        # 進資料庫
+        cur.execute(data)
+
+
+
+
+        content = cur.fetchall()
+        # print(content)
+        return render_template('Inquire1.html', content=content, labels=labels)
+
+    return render_template('two_list.html',labels1=labels1,labels2=labels2,labels3=labels3,labels4=labels4,labels5=labels5)
+
+
+
+
+
+if __name__ == '__main__':
+    app.run(debug=True,port=5050)

Файловите разлики са ограничени, защото са твърде много
+ 1829 - 0
test_two_list/bignumber.d.ts


Файловите разлики са ограничени, защото са твърде много
+ 2902 - 0
test_two_list/bignumber.js


Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
test_two_list/bignumber.min.js


Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
test_two_list/bignumber.min.js.map


Файловите разлики са ограничени, защото са твърде много
+ 2888 - 0
test_two_list/bignumber.mjs


+ 67 - 0
test_two_list/browser.js

@@ -0,0 +1,67 @@
+
+/**
+ * Module exports.
+ */
+
+module.exports = deprecate;
+
+/**
+ * Mark that a method should not be used.
+ * Returns a modified function which warns once by default.
+ *
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
+ *
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
+ * will throw an Error when invoked.
+ *
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
+ * will invoke `console.trace()` instead of `console.error()`.
+ *
+ * @param {Function} fn - the function to deprecate
+ * @param {String} msg - the string to print to the console when `fn` is invoked
+ * @returns {Function} a new "deprecated" version of `fn`
+ * @api public
+ */
+
+function deprecate (fn, msg) {
+  if (config('noDeprecation')) {
+    return fn;
+  }
+
+  var warned = false;
+  function deprecated() {
+    if (!warned) {
+      if (config('throwDeprecation')) {
+        throw new Error(msg);
+      } else if (config('traceDeprecation')) {
+        console.trace(msg);
+      } else {
+        console.warn(msg);
+      }
+      warned = true;
+    }
+    return fn.apply(this, arguments);
+  }
+
+  return deprecated;
+}
+
+/**
+ * Checks `localStorage` for boolean values for the given `name`.
+ *
+ * @param {String} name
+ * @returns {Boolean}
+ * @api private
+ */
+
+function config (name) {
+  // accessing global.localStorage can trigger a DOMException in sandboxed iframes
+  try {
+    if (!global.localStorage) return false;
+  } catch (_) {
+    return false;
+  }
+  var val = global.localStorage[name];
+  if (null == val) return false;
+  return String(val).toLowerCase() === 'true';
+}

+ 262 - 0
test_two_list/charsets.js

@@ -0,0 +1,262 @@
+exports.BIG5_CHINESE_CI              = 1;
+exports.LATIN2_CZECH_CS              = 2;
+exports.DEC8_SWEDISH_CI              = 3;
+exports.CP850_GENERAL_CI             = 4;
+exports.LATIN1_GERMAN1_CI            = 5;
+exports.HP8_ENGLISH_CI               = 6;
+exports.KOI8R_GENERAL_CI             = 7;
+exports.LATIN1_SWEDISH_CI            = 8;
+exports.LATIN2_GENERAL_CI            = 9;
+exports.SWE7_SWEDISH_CI              = 10;
+exports.ASCII_GENERAL_CI             = 11;
+exports.UJIS_JAPANESE_CI             = 12;
+exports.SJIS_JAPANESE_CI             = 13;
+exports.CP1251_BULGARIAN_CI          = 14;
+exports.LATIN1_DANISH_CI             = 15;
+exports.HEBREW_GENERAL_CI            = 16;
+exports.TIS620_THAI_CI               = 18;
+exports.EUCKR_KOREAN_CI              = 19;
+exports.LATIN7_ESTONIAN_CS           = 20;
+exports.LATIN2_HUNGARIAN_CI          = 21;
+exports.KOI8U_GENERAL_CI             = 22;
+exports.CP1251_UKRAINIAN_CI          = 23;
+exports.GB2312_CHINESE_CI            = 24;
+exports.GREEK_GENERAL_CI             = 25;
+exports.CP1250_GENERAL_CI            = 26;
+exports.LATIN2_CROATIAN_CI           = 27;
+exports.GBK_CHINESE_CI               = 28;
+exports.CP1257_LITHUANIAN_CI         = 29;
+exports.LATIN5_TURKISH_CI            = 30;
+exports.LATIN1_GERMAN2_CI            = 31;
+exports.ARMSCII8_GENERAL_CI          = 32;
+exports.UTF8_GENERAL_CI              = 33;
+exports.CP1250_CZECH_CS              = 34;
+exports.UCS2_GENERAL_CI              = 35;
+exports.CP866_GENERAL_CI             = 36;
+exports.KEYBCS2_GENERAL_CI           = 37;
+exports.MACCE_GENERAL_CI             = 38;
+exports.MACROMAN_GENERAL_CI          = 39;
+exports.CP852_GENERAL_CI             = 40;
+exports.LATIN7_GENERAL_CI            = 41;
+exports.LATIN7_GENERAL_CS            = 42;
+exports.MACCE_BIN                    = 43;
+exports.CP1250_CROATIAN_CI           = 44;
+exports.UTF8MB4_GENERAL_CI           = 45;
+exports.UTF8MB4_BIN                  = 46;
+exports.LATIN1_BIN                   = 47;
+exports.LATIN1_GENERAL_CI            = 48;
+exports.LATIN1_GENERAL_CS            = 49;
+exports.CP1251_BIN                   = 50;
+exports.CP1251_GENERAL_CI            = 51;
+exports.CP1251_GENERAL_CS            = 52;
+exports.MACROMAN_BIN                 = 53;
+exports.UTF16_GENERAL_CI             = 54;
+exports.UTF16_BIN                    = 55;
+exports.UTF16LE_GENERAL_CI           = 56;
+exports.CP1256_GENERAL_CI            = 57;
+exports.CP1257_BIN                   = 58;
+exports.CP1257_GENERAL_CI            = 59;
+exports.UTF32_GENERAL_CI             = 60;
+exports.UTF32_BIN                    = 61;
+exports.UTF16LE_BIN                  = 62;
+exports.BINARY                       = 63;
+exports.ARMSCII8_BIN                 = 64;
+exports.ASCII_BIN                    = 65;
+exports.CP1250_BIN                   = 66;
+exports.CP1256_BIN                   = 67;
+exports.CP866_BIN                    = 68;
+exports.DEC8_BIN                     = 69;
+exports.GREEK_BIN                    = 70;
+exports.HEBREW_BIN                   = 71;
+exports.HP8_BIN                      = 72;
+exports.KEYBCS2_BIN                  = 73;
+exports.KOI8R_BIN                    = 74;
+exports.KOI8U_BIN                    = 75;
+exports.LATIN2_BIN                   = 77;
+exports.LATIN5_BIN                   = 78;
+exports.LATIN7_BIN                   = 79;
+exports.CP850_BIN                    = 80;
+exports.CP852_BIN                    = 81;
+exports.SWE7_BIN                     = 82;
+exports.UTF8_BIN                     = 83;
+exports.BIG5_BIN                     = 84;
+exports.EUCKR_BIN                    = 85;
+exports.GB2312_BIN                   = 86;
+exports.GBK_BIN                      = 87;
+exports.SJIS_BIN                     = 88;
+exports.TIS620_BIN                   = 89;
+exports.UCS2_BIN                     = 90;
+exports.UJIS_BIN                     = 91;
+exports.GEOSTD8_GENERAL_CI           = 92;
+exports.GEOSTD8_BIN                  = 93;
+exports.LATIN1_SPANISH_CI            = 94;
+exports.CP932_JAPANESE_CI            = 95;
+exports.CP932_BIN                    = 96;
+exports.EUCJPMS_JAPANESE_CI          = 97;
+exports.EUCJPMS_BIN                  = 98;
+exports.CP1250_POLISH_CI             = 99;
+exports.UTF16_UNICODE_CI             = 101;
+exports.UTF16_ICELANDIC_CI           = 102;
+exports.UTF16_LATVIAN_CI             = 103;
+exports.UTF16_ROMANIAN_CI            = 104;
+exports.UTF16_SLOVENIAN_CI           = 105;
+exports.UTF16_POLISH_CI              = 106;
+exports.UTF16_ESTONIAN_CI            = 107;
+exports.UTF16_SPANISH_CI             = 108;
+exports.UTF16_SWEDISH_CI             = 109;
+exports.UTF16_TURKISH_CI             = 110;
+exports.UTF16_CZECH_CI               = 111;
+exports.UTF16_DANISH_CI              = 112;
+exports.UTF16_LITHUANIAN_CI          = 113;
+exports.UTF16_SLOVAK_CI              = 114;
+exports.UTF16_SPANISH2_CI            = 115;
+exports.UTF16_ROMAN_CI               = 116;
+exports.UTF16_PERSIAN_CI             = 117;
+exports.UTF16_ESPERANTO_CI           = 118;
+exports.UTF16_HUNGARIAN_CI           = 119;
+exports.UTF16_SINHALA_CI             = 120;
+exports.UTF16_GERMAN2_CI             = 121;
+exports.UTF16_CROATIAN_MYSQL561_CI   = 122;
+exports.UTF16_UNICODE_520_CI         = 123;
+exports.UTF16_VIETNAMESE_CI          = 124;
+exports.UCS2_UNICODE_CI              = 128;
+exports.UCS2_ICELANDIC_CI            = 129;
+exports.UCS2_LATVIAN_CI              = 130;
+exports.UCS2_ROMANIAN_CI             = 131;
+exports.UCS2_SLOVENIAN_CI            = 132;
+exports.UCS2_POLISH_CI               = 133;
+exports.UCS2_ESTONIAN_CI             = 134;
+exports.UCS2_SPANISH_CI              = 135;
+exports.UCS2_SWEDISH_CI              = 136;
+exports.UCS2_TURKISH_CI              = 137;
+exports.UCS2_CZECH_CI                = 138;
+exports.UCS2_DANISH_CI               = 139;
+exports.UCS2_LITHUANIAN_CI           = 140;
+exports.UCS2_SLOVAK_CI               = 141;
+exports.UCS2_SPANISH2_CI             = 142;
+exports.UCS2_ROMAN_CI                = 143;
+exports.UCS2_PERSIAN_CI              = 144;
+exports.UCS2_ESPERANTO_CI            = 145;
+exports.UCS2_HUNGARIAN_CI            = 146;
+exports.UCS2_SINHALA_CI              = 147;
+exports.UCS2_GERMAN2_CI              = 148;
+exports.UCS2_CROATIAN_MYSQL561_CI    = 149;
+exports.UCS2_UNICODE_520_CI          = 150;
+exports.UCS2_VIETNAMESE_CI           = 151;
+exports.UCS2_GENERAL_MYSQL500_CI     = 159;
+exports.UTF32_UNICODE_CI             = 160;
+exports.UTF32_ICELANDIC_CI           = 161;
+exports.UTF32_LATVIAN_CI             = 162;
+exports.UTF32_ROMANIAN_CI            = 163;
+exports.UTF32_SLOVENIAN_CI           = 164;
+exports.UTF32_POLISH_CI              = 165;
+exports.UTF32_ESTONIAN_CI            = 166;
+exports.UTF32_SPANISH_CI             = 167;
+exports.UTF32_SWEDISH_CI             = 168;
+exports.UTF32_TURKISH_CI             = 169;
+exports.UTF32_CZECH_CI               = 170;
+exports.UTF32_DANISH_CI              = 171;
+exports.UTF32_LITHUANIAN_CI          = 172;
+exports.UTF32_SLOVAK_CI              = 173;
+exports.UTF32_SPANISH2_CI            = 174;
+exports.UTF32_ROMAN_CI               = 175;
+exports.UTF32_PERSIAN_CI             = 176;
+exports.UTF32_ESPERANTO_CI           = 177;
+exports.UTF32_HUNGARIAN_CI           = 178;
+exports.UTF32_SINHALA_CI             = 179;
+exports.UTF32_GERMAN2_CI             = 180;
+exports.UTF32_CROATIAN_MYSQL561_CI   = 181;
+exports.UTF32_UNICODE_520_CI         = 182;
+exports.UTF32_VIETNAMESE_CI          = 183;
+exports.UTF8_UNICODE_CI              = 192;
+exports.UTF8_ICELANDIC_CI            = 193;
+exports.UTF8_LATVIAN_CI              = 194;
+exports.UTF8_ROMANIAN_CI             = 195;
+exports.UTF8_SLOVENIAN_CI            = 196;
+exports.UTF8_POLISH_CI               = 197;
+exports.UTF8_ESTONIAN_CI             = 198;
+exports.UTF8_SPANISH_CI              = 199;
+exports.UTF8_SWEDISH_CI              = 200;
+exports.UTF8_TURKISH_CI              = 201;
+exports.UTF8_CZECH_CI                = 202;
+exports.UTF8_DANISH_CI               = 203;
+exports.UTF8_LITHUANIAN_CI           = 204;
+exports.UTF8_SLOVAK_CI               = 205;
+exports.UTF8_SPANISH2_CI             = 206;
+exports.UTF8_ROMAN_CI                = 207;
+exports.UTF8_PERSIAN_CI              = 208;
+exports.UTF8_ESPERANTO_CI            = 209;
+exports.UTF8_HUNGARIAN_CI            = 210;
+exports.UTF8_SINHALA_CI              = 211;
+exports.UTF8_GERMAN2_CI              = 212;
+exports.UTF8_CROATIAN_MYSQL561_CI    = 213;
+exports.UTF8_UNICODE_520_CI          = 214;
+exports.UTF8_VIETNAMESE_CI           = 215;
+exports.UTF8_GENERAL_MYSQL500_CI     = 223;
+exports.UTF8MB4_UNICODE_CI           = 224;
+exports.UTF8MB4_ICELANDIC_CI         = 225;
+exports.UTF8MB4_LATVIAN_CI           = 226;
+exports.UTF8MB4_ROMANIAN_CI          = 227;
+exports.UTF8MB4_SLOVENIAN_CI         = 228;
+exports.UTF8MB4_POLISH_CI            = 229;
+exports.UTF8MB4_ESTONIAN_CI          = 230;
+exports.UTF8MB4_SPANISH_CI           = 231;
+exports.UTF8MB4_SWEDISH_CI           = 232;
+exports.UTF8MB4_TURKISH_CI           = 233;
+exports.UTF8MB4_CZECH_CI             = 234;
+exports.UTF8MB4_DANISH_CI            = 235;
+exports.UTF8MB4_LITHUANIAN_CI        = 236;
+exports.UTF8MB4_SLOVAK_CI            = 237;
+exports.UTF8MB4_SPANISH2_CI          = 238;
+exports.UTF8MB4_ROMAN_CI             = 239;
+exports.UTF8MB4_PERSIAN_CI           = 240;
+exports.UTF8MB4_ESPERANTO_CI         = 241;
+exports.UTF8MB4_HUNGARIAN_CI         = 242;
+exports.UTF8MB4_SINHALA_CI           = 243;
+exports.UTF8MB4_GERMAN2_CI           = 244;
+exports.UTF8MB4_CROATIAN_MYSQL561_CI = 245;
+exports.UTF8MB4_UNICODE_520_CI       = 246;
+exports.UTF8MB4_VIETNAMESE_CI        = 247;
+exports.UTF8_GENERAL50_CI            = 253;
+
+// short aliases
+exports.ARMSCII8 = exports.ARMSCII8_GENERAL_CI;
+exports.ASCII    = exports.ASCII_GENERAL_CI;
+exports.BIG5     = exports.BIG5_CHINESE_CI;
+exports.BINARY   = exports.BINARY;
+exports.CP1250   = exports.CP1250_GENERAL_CI;
+exports.CP1251   = exports.CP1251_GENERAL_CI;
+exports.CP1256   = exports.CP1256_GENERAL_CI;
+exports.CP1257   = exports.CP1257_GENERAL_CI;
+exports.CP866    = exports.CP866_GENERAL_CI;
+exports.CP850    = exports.CP850_GENERAL_CI;
+exports.CP852    = exports.CP852_GENERAL_CI;
+exports.CP932    = exports.CP932_JAPANESE_CI;
+exports.DEC8     = exports.DEC8_SWEDISH_CI;
+exports.EUCJPMS  = exports.EUCJPMS_JAPANESE_CI;
+exports.EUCKR    = exports.EUCKR_KOREAN_CI;
+exports.GB2312   = exports.GB2312_CHINESE_CI;
+exports.GBK      = exports.GBK_CHINESE_CI;
+exports.GEOSTD8  = exports.GEOSTD8_GENERAL_CI;
+exports.GREEK    = exports.GREEK_GENERAL_CI;
+exports.HEBREW   = exports.HEBREW_GENERAL_CI;
+exports.HP8      = exports.HP8_ENGLISH_CI;
+exports.KEYBCS2  = exports.KEYBCS2_GENERAL_CI;
+exports.KOI8R    = exports.KOI8R_GENERAL_CI;
+exports.KOI8U    = exports.KOI8U_GENERAL_CI;
+exports.LATIN1   = exports.LATIN1_SWEDISH_CI;
+exports.LATIN2   = exports.LATIN2_GENERAL_CI;
+exports.LATIN5   = exports.LATIN5_TURKISH_CI;
+exports.LATIN7   = exports.LATIN7_GENERAL_CI;
+exports.MACCE    = exports.MACCE_GENERAL_CI;
+exports.MACROMAN = exports.MACROMAN_GENERAL_CI;
+exports.SJIS     = exports.SJIS_JAPANESE_CI;
+exports.SWE7     = exports.SWE7_SWEDISH_CI;
+exports.TIS620   = exports.TIS620_THAI_CI;
+exports.UCS2     = exports.UCS2_GENERAL_CI;
+exports.UJIS     = exports.UJIS_JAPANESE_CI;
+exports.UTF16    = exports.UTF16_GENERAL_CI;
+exports.UTF16LE  = exports.UTF16LE_GENERAL_CI;
+exports.UTF8     = exports.UTF8_GENERAL_CI;
+exports.UTF8MB4  = exports.UTF8MB4_GENERAL_CI;
+exports.UTF32    = exports.UTF32_GENERAL_CI;

+ 26 - 0
test_two_list/client.js

@@ -0,0 +1,26 @@
+// Manually extracted from mysql-5.5.23/include/mysql_com.h
+exports.CLIENT_LONG_PASSWORD     = 1; /* new more secure passwords */
+exports.CLIENT_FOUND_ROWS        = 2; /* Found instead of affected rows */
+exports.CLIENT_LONG_FLAG         = 4; /* Get all column flags */
+exports.CLIENT_CONNECT_WITH_DB   = 8; /* One can specify db on connect */
+exports.CLIENT_NO_SCHEMA         = 16; /* Don't allow database.table.column */
+exports.CLIENT_COMPRESS          = 32; /* Can use compression protocol */
+exports.CLIENT_ODBC              = 64; /* Odbc client */
+exports.CLIENT_LOCAL_FILES       = 128; /* Can use LOAD DATA LOCAL */
+exports.CLIENT_IGNORE_SPACE      = 256; /* Ignore spaces before '(' */
+exports.CLIENT_PROTOCOL_41       = 512; /* New 4.1 protocol */
+exports.CLIENT_INTERACTIVE       = 1024; /* This is an interactive client */
+exports.CLIENT_SSL               = 2048; /* Switch to SSL after handshake */
+exports.CLIENT_IGNORE_SIGPIPE    = 4096;    /* IGNORE sigpipes */
+exports.CLIENT_TRANSACTIONS      = 8192; /* Client knows about transactions */
+exports.CLIENT_RESERVED          = 16384;   /* Old flag for 4.1 protocol  */
+exports.CLIENT_SECURE_CONNECTION = 32768;  /* New 4.1 authentication */
+
+exports.CLIENT_MULTI_STATEMENTS = 65536; /* Enable/disable multi-stmt support */
+exports.CLIENT_MULTI_RESULTS    = 131072; /* Enable/disable multi-results */
+exports.CLIENT_PS_MULTI_RESULTS = 262144; /* Multi-results in PS-protocol */
+
+exports.CLIENT_PLUGIN_AUTH = 524288; /* Client supports plugin authentication */
+
+exports.CLIENT_SSL_VERIFY_SERVER_CERT = 1073741824;
+exports.CLIENT_REMEMBER_OPTIONS       = 2147483648;

+ 19 - 0
test_two_list/component.json

@@ -0,0 +1,19 @@
+{
+  "name" : "isarray",
+  "description" : "Array#isArray for older browsers",
+  "version" : "0.0.1",
+  "repository" : "juliangruber/isarray",
+  "homepage": "https://github.com/juliangruber/isarray",
+  "main" : "index.js",
+  "scripts" : [
+    "index.js"
+  ],
+  "dependencies" : {},
+  "keywords": ["browser","isarray","array"],
+  "author": {
+    "name": "Julian Gruber",
+    "email": "mail@juliangruber.com",
+    "url": "http://juliangruber.com"
+  },
+  "license": "MIT"
+}

+ 74 - 0
test_two_list/destroy.js

@@ -0,0 +1,74 @@
+'use strict';
+
+/*<replacement>*/
+
+var pna = require('process-nextick-args');
+/*</replacement>*/
+
+// undocumented cb() API, needed for core, not for public API
+function destroy(err, cb) {
+  var _this = this;
+
+  var readableDestroyed = this._readableState && this._readableState.destroyed;
+  var writableDestroyed = this._writableState && this._writableState.destroyed;
+
+  if (readableDestroyed || writableDestroyed) {
+    if (cb) {
+      cb(err);
+    } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
+      pna.nextTick(emitErrorNT, this, err);
+    }
+    return this;
+  }
+
+  // we set destroyed to true before firing error callbacks in order
+  // to make it re-entrance safe in case destroy() is called within callbacks
+
+  if (this._readableState) {
+    this._readableState.destroyed = true;
+  }
+
+  // if this is a duplex stream mark the writable part as destroyed as well
+  if (this._writableState) {
+    this._writableState.destroyed = true;
+  }
+
+  this._destroy(err || null, function (err) {
+    if (!cb && err) {
+      pna.nextTick(emitErrorNT, _this, err);
+      if (_this._writableState) {
+        _this._writableState.errorEmitted = true;
+      }
+    } else if (cb) {
+      cb(err);
+    }
+  });
+
+  return this;
+}
+
+function undestroy() {
+  if (this._readableState) {
+    this._readableState.destroyed = false;
+    this._readableState.reading = false;
+    this._readableState.ended = false;
+    this._readableState.endEmitted = false;
+  }
+
+  if (this._writableState) {
+    this._writableState.destroyed = false;
+    this._writableState.ended = false;
+    this._writableState.ending = false;
+    this._writableState.finished = false;
+    this._writableState.errorEmitted = false;
+  }
+}
+
+function emitErrorNT(self, err) {
+  self.emit('error', err);
+}
+
+module.exports = {
+  destroy: destroy,
+  undestroy: undestroy
+};

+ 1 - 0
test_two_list/duplex-browser.js

@@ -0,0 +1 @@
+module.exports = require('./lib/_stream_duplex.js');

+ 1 - 0
test_two_list/duplex.js

@@ -0,0 +1 @@
+module.exports = require('./readable').Duplex

Файловите разлики са ограничени, защото са твърде много
+ 2476 - 0
test_two_list/errors.js


+ 18 - 0
test_two_list/field_flags.js

@@ -0,0 +1,18 @@
+// Manually extracted from mysql-5.5.23/include/mysql_com.h
+exports.NOT_NULL_FLAG     = 1; /* Field can't be NULL */
+exports.PRI_KEY_FLAG      = 2; /* Field is part of a primary key */
+exports.UNIQUE_KEY_FLAG   = 4; /* Field is part of a unique key */
+exports.MULTIPLE_KEY_FLAG = 8; /* Field is part of a key */
+exports.BLOB_FLAG         = 16; /* Field is a blob */
+exports.UNSIGNED_FLAG     = 32; /* Field is unsigned */
+exports.ZEROFILL_FLAG     = 64; /* Field is zerofill */
+exports.BINARY_FLAG       = 128; /* Field is binary   */
+
+/* The following are only sent to new clients */
+exports.ENUM_FLAG             = 256; /* field is an enum */
+exports.AUTO_INCREMENT_FLAG   = 512; /* field is a autoincrement field */
+exports.TIMESTAMP_FLAG        = 1024; /* Field is a timestamp */
+exports.SET_FLAG              = 2048; /* field is a set */
+exports.NO_DEFAULT_VALUE_FLAG = 4096; /* Field doesn't have default value */
+exports.ON_UPDATE_NOW_FLAG    = 8192; /* Field is set to NOW on UPDATE */
+exports.NUM_FLAG              = 32768; /* Field is num (for clients) */

+ 187 - 0
test_two_list/index.d.ts

@@ -0,0 +1,187 @@
+declare module "safe-buffer" {
+  export class Buffer {
+    length: number
+    write(string: string, offset?: number, length?: number, encoding?: string): number;
+    toString(encoding?: string, start?: number, end?: number): string;
+    toJSON(): { type: 'Buffer', data: any[] };
+    equals(otherBuffer: Buffer): boolean;
+    compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
+    copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
+    slice(start?: number, end?: number): Buffer;
+    writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+    writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+    writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+    writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
+    readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
+    readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
+    readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
+    readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
+    readUInt8(offset: number, noAssert?: boolean): number;
+    readUInt16LE(offset: number, noAssert?: boolean): number;
+    readUInt16BE(offset: number, noAssert?: boolean): number;
+    readUInt32LE(offset: number, noAssert?: boolean): number;
+    readUInt32BE(offset: number, noAssert?: boolean): number;
+    readInt8(offset: number, noAssert?: boolean): number;
+    readInt16LE(offset: number, noAssert?: boolean): number;
+    readInt16BE(offset: number, noAssert?: boolean): number;
+    readInt32LE(offset: number, noAssert?: boolean): number;
+    readInt32BE(offset: number, noAssert?: boolean): number;
+    readFloatLE(offset: number, noAssert?: boolean): number;
+    readFloatBE(offset: number, noAssert?: boolean): number;
+    readDoubleLE(offset: number, noAssert?: boolean): number;
+    readDoubleBE(offset: number, noAssert?: boolean): number;
+    swap16(): Buffer;
+    swap32(): Buffer;
+    swap64(): Buffer;
+    writeUInt8(value: number, offset: number, noAssert?: boolean): number;
+    writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
+    writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
+    writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
+    writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
+    writeInt8(value: number, offset: number, noAssert?: boolean): number;
+    writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
+    writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
+    writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
+    writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
+    writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
+    writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
+    writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
+    writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
+    fill(value: any, offset?: number, end?: number): this;
+    indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
+    lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
+    includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
+
+    /**
+     * Allocates a new buffer containing the given {str}.
+     *
+     * @param str String to store in buffer.
+     * @param encoding encoding to use, optional.  Default is 'utf8'
+     */
+     constructor (str: string, encoding?: string);
+    /**
+     * Allocates a new buffer of {size} octets.
+     *
+     * @param size count of octets to allocate.
+     */
+    constructor (size: number);
+    /**
+     * Allocates a new buffer containing the given {array} of octets.
+     *
+     * @param array The octets to store.
+     */
+    constructor (array: Uint8Array);
+    /**
+     * Produces a Buffer backed by the same allocated memory as
+     * the given {ArrayBuffer}.
+     *
+     *
+     * @param arrayBuffer The ArrayBuffer with which to share memory.
+     */
+    constructor (arrayBuffer: ArrayBuffer);
+    /**
+     * Allocates a new buffer containing the given {array} of octets.
+     *
+     * @param array The octets to store.
+     */
+    constructor (array: any[]);
+    /**
+     * Copies the passed {buffer} data onto a new {Buffer} instance.
+     *
+     * @param buffer The buffer to copy.
+     */
+    constructor (buffer: Buffer);
+    prototype: Buffer;
+    /**
+     * Allocates a new Buffer using an {array} of octets.
+     *
+     * @param array
+     */
+    static from(array: any[]): Buffer;
+    /**
+     * When passed a reference to the .buffer property of a TypedArray instance,
+     * the newly created Buffer will share the same allocated memory as the TypedArray.
+     * The optional {byteOffset} and {length} arguments specify a memory range
+     * within the {arrayBuffer} that will be shared by the Buffer.
+     *
+     * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
+     * @param byteOffset
+     * @param length
+     */
+    static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
+    /**
+     * Copies the passed {buffer} data onto a new Buffer instance.
+     *
+     * @param buffer
+     */
+    static from(buffer: Buffer): Buffer;
+    /**
+     * Creates a new Buffer containing the given JavaScript string {str}.
+     * If provided, the {encoding} parameter identifies the character encoding.
+     * If not provided, {encoding} defaults to 'utf8'.
+     *
+     * @param str
+     */
+    static from(str: string, encoding?: string): Buffer;
+    /**
+     * Returns true if {obj} is a Buffer
+     *
+     * @param obj object to test.
+     */
+    static isBuffer(obj: any): obj is Buffer;
+    /**
+     * Returns true if {encoding} is a valid encoding argument.
+     * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
+     *
+     * @param encoding string to test.
+     */
+    static isEncoding(encoding: string): boolean;
+    /**
+     * Gives the actual byte length of a string. encoding defaults to 'utf8'.
+     * This is not the same as String.prototype.length since that returns the number of characters in a string.
+     *
+     * @param string string to test.
+     * @param encoding encoding used to evaluate (defaults to 'utf8')
+     */
+    static byteLength(string: string, encoding?: string): number;
+    /**
+     * Returns a buffer which is the result of concatenating all the buffers in the list together.
+     *
+     * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
+     * If the list has exactly one item, then the first item of the list is returned.
+     * If the list has more than one item, then a new Buffer is created.
+     *
+     * @param list An array of Buffer objects to concatenate
+     * @param totalLength Total length of the buffers when concatenated.
+     *   If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
+     */
+    static concat(list: Buffer[], totalLength?: number): Buffer;
+    /**
+     * The same as buf1.compare(buf2).
+     */
+    static compare(buf1: Buffer, buf2: Buffer): number;
+    /**
+     * Allocates a new buffer of {size} octets.
+     *
+     * @param size count of octets to allocate.
+     * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
+     *    If parameter is omitted, buffer will be filled with zeros.
+     * @param encoding encoding used for call to buf.fill while initalizing
+     */
+    static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
+    /**
+     * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
+     * of the newly created Buffer are unknown and may contain sensitive data.
+     *
+     * @param size count of octets to allocate
+     */
+    static allocUnsafe(size: number): Buffer;
+    /**
+     * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
+     * of the newly created Buffer are unknown and may contain sensitive data.
+     *
+     * @param size count of octets to allocate
+     */
+    static allocUnsafeSlow(size: number): Buffer;
+  }
+}

+ 7 - 0
test_two_list/index.js

@@ -0,0 +1,7 @@
+exports.ChangeUser = require('./ChangeUser');
+exports.Handshake = require('./Handshake');
+exports.Ping = require('./Ping');
+exports.Query = require('./Query');
+exports.Quit = require('./Quit');
+exports.Sequence = require('./Sequence');
+exports.Statistics = require('./Statistics');

+ 9 - 0
test_two_list/inherits.js

@@ -0,0 +1,9 @@
+try {
+  var util = require('util');
+  /* istanbul ignore next */
+  if (typeof util.inherits !== 'function') throw '';
+  module.exports = util.inherits;
+} catch (e) {
+  /* istanbul ignore next */
+  module.exports = require('./inherits_browser.js');
+}

+ 27 - 0
test_two_list/inherits_browser.js

@@ -0,0 +1,27 @@
+if (typeof Object.create === 'function') {
+  // implementation from standard node.js 'util' module
+  module.exports = function inherits(ctor, superCtor) {
+    if (superCtor) {
+      ctor.super_ = superCtor
+      ctor.prototype = Object.create(superCtor.prototype, {
+        constructor: {
+          value: ctor,
+          enumerable: false,
+          writable: true,
+          configurable: true
+        }
+      })
+    }
+  };
+} else {
+  // old school shim for old browsers
+  module.exports = function inherits(ctor, superCtor) {
+    if (superCtor) {
+      ctor.super_ = superCtor
+      var TempCtor = function () {}
+      TempCtor.prototype = superCtor.prototype
+      ctor.prototype = new TempCtor()
+      ctor.prototype.constructor = ctor
+    }
+  }
+}

+ 19 - 0
test_two_list/license.md

@@ -0,0 +1,19 @@
+# Copyright (c) 2015 Calvin Metcalf
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.**

+ 6 - 0
test_two_list/node.js

@@ -0,0 +1,6 @@
+
+/**
+ * For Node.js, simply re-export the core `util.deprecate` function.
+ */
+
+module.exports = require('util').deprecate;

+ 79 - 0
test_two_list/package-lock.json

@@ -0,0 +1,79 @@
+{
+  "requires": true,
+  "lockfileVersion": 1,
+  "dependencies": {
+    "bignumber.js": {
+      "version": "9.0.0",
+      "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
+      "integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A=="
+    },
+    "core-util-is": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
+      "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
+    },
+    "inherits": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+    },
+    "isarray": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+      "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
+    },
+    "mysql": {
+      "version": "2.18.1",
+      "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
+      "integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==",
+      "requires": {
+        "bignumber.js": "9.0.0",
+        "readable-stream": "2.3.7",
+        "safe-buffer": "5.1.2",
+        "sqlstring": "2.3.1"
+      }
+    },
+    "process-nextick-args": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
+      "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
+    },
+    "readable-stream": {
+      "version": "2.3.7",
+      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
+      "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
+      "requires": {
+        "core-util-is": "~1.0.0",
+        "inherits": "~2.0.3",
+        "isarray": "~1.0.0",
+        "process-nextick-args": "~2.0.0",
+        "safe-buffer": "~5.1.1",
+        "string_decoder": "~1.1.1",
+        "util-deprecate": "~1.0.1"
+      }
+    },
+    "safe-buffer": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+      "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+    },
+    "sqlstring": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
+      "integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A="
+    },
+    "string_decoder": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
+      "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+      "requires": {
+        "safe-buffer": "~5.1.0"
+      }
+    },
+    "util-deprecate": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+      "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+    }
+  }
+}

+ 56 - 0
test_two_list/package.json

@@ -0,0 +1,56 @@
+{
+  "_from": "util-deprecate@~1.0.1",
+  "_id": "util-deprecate@1.0.2",
+  "_inBundle": false,
+  "_integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
+  "_location": "/util-deprecate",
+  "_phantomChildren": {},
+  "_requested": {
+    "type": "range",
+    "registry": true,
+    "raw": "util-deprecate@~1.0.1",
+    "name": "util-deprecate",
+    "escapedName": "util-deprecate",
+    "rawSpec": "~1.0.1",
+    "saveSpec": null,
+    "fetchSpec": "~1.0.1"
+  },
+  "_requiredBy": [
+    "/readable-stream"
+  ],
+  "_resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+  "_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf",
+  "_spec": "util-deprecate@~1.0.1",
+  "_where": "D:\\fatwolf\\company_files\\flask\\test_two_list\\templates\\node_modules\\readable-stream",
+  "author": {
+    "name": "Nathan Rajlich",
+    "email": "nathan@tootallnate.net",
+    "url": "http://n8.io/"
+  },
+  "browser": "browser.js",
+  "bugs": {
+    "url": "https://github.com/TooTallNate/util-deprecate/issues"
+  },
+  "bundleDependencies": false,
+  "deprecated": false,
+  "description": "The Node.js `util.deprecate()` function with browser support",
+  "homepage": "https://github.com/TooTallNate/util-deprecate",
+  "keywords": [
+    "util",
+    "deprecate",
+    "browserify",
+    "browser",
+    "node"
+  ],
+  "license": "MIT",
+  "main": "node.js",
+  "name": "util-deprecate",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/TooTallNate/util-deprecate.git"
+  },
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "version": "1.0.2"
+}

+ 1 - 0
test_two_list/passthrough.js

@@ -0,0 +1 @@
+module.exports = require('./readable').PassThrough

+ 7 - 0
test_two_list/readable-browser.js

@@ -0,0 +1,7 @@
+exports = module.exports = require('./lib/_stream_readable.js');
+exports.Stream = exports;
+exports.Readable = exports;
+exports.Writable = require('./lib/_stream_writable.js');
+exports.Duplex = require('./lib/_stream_duplex.js');
+exports.Transform = require('./lib/_stream_transform.js');
+exports.PassThrough = require('./lib/_stream_passthrough.js');

+ 19 - 0
test_two_list/readable.js

@@ -0,0 +1,19 @@
+var Stream = require('stream');
+if (process.env.READABLE_STREAM === 'disable' && Stream) {
+  module.exports = Stream;
+  exports = module.exports = Stream.Readable;
+  exports.Readable = Stream.Readable;
+  exports.Writable = Stream.Writable;
+  exports.Duplex = Stream.Duplex;
+  exports.Transform = Stream.Transform;
+  exports.PassThrough = Stream.PassThrough;
+  exports.Stream = Stream;
+} else {
+  exports = module.exports = require('./lib/_stream_readable.js');
+  exports.Stream = Stream || exports;
+  exports.Readable = exports;
+  exports.Writable = require('./lib/_stream_writable.js');
+  exports.Duplex = require('./lib/_stream_duplex.js');
+  exports.Transform = require('./lib/_stream_transform.js');
+  exports.PassThrough = require('./lib/_stream_passthrough.js');
+}

+ 18 - 0
test_two_list/readme.md

@@ -0,0 +1,18 @@
+process-nextick-args
+=====
+
+[![Build Status](https://travis-ci.org/calvinmetcalf/process-nextick-args.svg?branch=master)](https://travis-ci.org/calvinmetcalf/process-nextick-args)
+
+```bash
+npm install --save process-nextick-args
+```
+
+Always be able to pass arguments to process.nextTick, no matter the platform
+
+```js
+var pna = require('process-nextick-args');
+
+pna.nextTick(function (a, b, c) {
+  console.log(a, b, c);
+}, 'step', 3,  'profit');
+```

+ 39 - 0
test_two_list/server_status.js

@@ -0,0 +1,39 @@
+// Manually extracted from mysql-5.5.23/include/mysql_com.h
+
+/**
+  Is raised when a multi-statement transaction
+  has been started, either explicitly, by means
+  of BEGIN or COMMIT AND CHAIN, or
+  implicitly, by the first transactional
+  statement, when autocommit=off.
+*/
+exports.SERVER_STATUS_IN_TRANS          = 1;
+exports.SERVER_STATUS_AUTOCOMMIT        = 2;  /* Server in auto_commit mode */
+exports.SERVER_MORE_RESULTS_EXISTS      = 8;    /* Multi query - next query exists */
+exports.SERVER_QUERY_NO_GOOD_INDEX_USED = 16;
+exports.SERVER_QUERY_NO_INDEX_USED      = 32;
+/**
+  The server was able to fulfill the clients request and opened a
+  read-only non-scrollable cursor for a query. This flag comes
+  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
+*/
+exports.SERVER_STATUS_CURSOR_EXISTS = 64;
+/**
+  This flag is sent when a read-only cursor is exhausted, in reply to
+  COM_STMT_FETCH command.
+*/
+exports.SERVER_STATUS_LAST_ROW_SENT        = 128;
+exports.SERVER_STATUS_DB_DROPPED           = 256; /* A database was dropped */
+exports.SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512;
+/**
+  Sent to the client if after a prepared statement reprepare
+  we discovered that the new statement returns a different
+  number of result set columns.
+*/
+exports.SERVER_STATUS_METADATA_CHANGED = 1024;
+exports.SERVER_QUERY_WAS_SLOW          = 2048;
+
+/**
+  To mark ResultSet containing output parameter values.
+*/
+exports.SERVER_PS_OUT_PARAMS = 4096;

Файловите разлики са ограничени, защото са твърде много
+ 1480 - 0
test_two_list/ssl_profiles.js


+ 1 - 0
test_two_list/stream-browser.js

@@ -0,0 +1 @@
+module.exports = require('events').EventEmitter;

+ 1 - 0
test_two_list/stream.js

@@ -0,0 +1 @@
+module.exports = require('stream');

+ 296 - 0
test_two_list/string_decoder.js

@@ -0,0 +1,296 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+/*<replacement>*/
+
+var Buffer = require('safe-buffer').Buffer;
+/*</replacement>*/
+
+var isEncoding = Buffer.isEncoding || function (encoding) {
+  encoding = '' + encoding;
+  switch (encoding && encoding.toLowerCase()) {
+    case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
+      return true;
+    default:
+      return false;
+  }
+};
+
+function _normalizeEncoding(enc) {
+  if (!enc) return 'utf8';
+  var retried;
+  while (true) {
+    switch (enc) {
+      case 'utf8':
+      case 'utf-8':
+        return 'utf8';
+      case 'ucs2':
+      case 'ucs-2':
+      case 'utf16le':
+      case 'utf-16le':
+        return 'utf16le';
+      case 'latin1':
+      case 'binary':
+        return 'latin1';
+      case 'base64':
+      case 'ascii':
+      case 'hex':
+        return enc;
+      default:
+        if (retried) return; // undefined
+        enc = ('' + enc).toLowerCase();
+        retried = true;
+    }
+  }
+};
+
+// Do not cache `Buffer.isEncoding` when checking encoding names as some
+// modules monkey-patch it to support additional encodings
+function normalizeEncoding(enc) {
+  var nenc = _normalizeEncoding(enc);
+  if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
+  return nenc || enc;
+}
+
+// StringDecoder provides an interface for efficiently splitting a series of
+// buffers into a series of JS strings without breaking apart multi-byte
+// characters.
+exports.StringDecoder = StringDecoder;
+function StringDecoder(encoding) {
+  this.encoding = normalizeEncoding(encoding);
+  var nb;
+  switch (this.encoding) {
+    case 'utf16le':
+      this.text = utf16Text;
+      this.end = utf16End;
+      nb = 4;
+      break;
+    case 'utf8':
+      this.fillLast = utf8FillLast;
+      nb = 4;
+      break;
+    case 'base64':
+      this.text = base64Text;
+      this.end = base64End;
+      nb = 3;
+      break;
+    default:
+      this.write = simpleWrite;
+      this.end = simpleEnd;
+      return;
+  }
+  this.lastNeed = 0;
+  this.lastTotal = 0;
+  this.lastChar = Buffer.allocUnsafe(nb);
+}
+
+StringDecoder.prototype.write = function (buf) {
+  if (buf.length === 0) return '';
+  var r;
+  var i;
+  if (this.lastNeed) {
+    r = this.fillLast(buf);
+    if (r === undefined) return '';
+    i = this.lastNeed;
+    this.lastNeed = 0;
+  } else {
+    i = 0;
+  }
+  if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
+  return r || '';
+};
+
+StringDecoder.prototype.end = utf8End;
+
+// Returns only complete characters in a Buffer
+StringDecoder.prototype.text = utf8Text;
+
+// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
+StringDecoder.prototype.fillLast = function (buf) {
+  if (this.lastNeed <= buf.length) {
+    buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
+    return this.lastChar.toString(this.encoding, 0, this.lastTotal);
+  }
+  buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
+  this.lastNeed -= buf.length;
+};
+
+// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
+// continuation byte. If an invalid byte is detected, -2 is returned.
+function utf8CheckByte(byte) {
+  if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
+  return byte >> 6 === 0x02 ? -1 : -2;
+}
+
+// Checks at most 3 bytes at the end of a Buffer in order to detect an
+// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
+// needed to complete the UTF-8 character (if applicable) are returned.
+function utf8CheckIncomplete(self, buf, i) {
+  var j = buf.length - 1;
+  if (j < i) return 0;
+  var nb = utf8CheckByte(buf[j]);
+  if (nb >= 0) {
+    if (nb > 0) self.lastNeed = nb - 1;
+    return nb;
+  }
+  if (--j < i || nb === -2) return 0;
+  nb = utf8CheckByte(buf[j]);
+  if (nb >= 0) {
+    if (nb > 0) self.lastNeed = nb - 2;
+    return nb;
+  }
+  if (--j < i || nb === -2) return 0;
+  nb = utf8CheckByte(buf[j]);
+  if (nb >= 0) {
+    if (nb > 0) {
+      if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
+    }
+    return nb;
+  }
+  return 0;
+}
+
+// Validates as many continuation bytes for a multi-byte UTF-8 character as
+// needed or are available. If we see a non-continuation byte where we expect
+// one, we "replace" the validated continuation bytes we've seen so far with
+// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
+// behavior. The continuation byte check is included three times in the case
+// where all of the continuation bytes for a character exist in the same buffer.
+// It is also done this way as a slight performance increase instead of using a
+// loop.
+function utf8CheckExtraBytes(self, buf, p) {
+  if ((buf[0] & 0xC0) !== 0x80) {
+    self.lastNeed = 0;
+    return '\ufffd';
+  }
+  if (self.lastNeed > 1 && buf.length > 1) {
+    if ((buf[1] & 0xC0) !== 0x80) {
+      self.lastNeed = 1;
+      return '\ufffd';
+    }
+    if (self.lastNeed > 2 && buf.length > 2) {
+      if ((buf[2] & 0xC0) !== 0x80) {
+        self.lastNeed = 2;
+        return '\ufffd';
+      }
+    }
+  }
+}
+
+// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
+function utf8FillLast(buf) {
+  var p = this.lastTotal - this.lastNeed;
+  var r = utf8CheckExtraBytes(this, buf, p);
+  if (r !== undefined) return r;
+  if (this.lastNeed <= buf.length) {
+    buf.copy(this.lastChar, p, 0, this.lastNeed);
+    return this.lastChar.toString(this.encoding, 0, this.lastTotal);
+  }
+  buf.copy(this.lastChar, p, 0, buf.length);
+  this.lastNeed -= buf.length;
+}
+
+// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
+// partial character, the character's bytes are buffered until the required
+// number of bytes are available.
+function utf8Text(buf, i) {
+  var total = utf8CheckIncomplete(this, buf, i);
+  if (!this.lastNeed) return buf.toString('utf8', i);
+  this.lastTotal = total;
+  var end = buf.length - (total - this.lastNeed);
+  buf.copy(this.lastChar, 0, end);
+  return buf.toString('utf8', i, end);
+}
+
+// For UTF-8, a replacement character is added when ending on a partial
+// character.
+function utf8End(buf) {
+  var r = buf && buf.length ? this.write(buf) : '';
+  if (this.lastNeed) return r + '\ufffd';
+  return r;
+}
+
+// UTF-16LE typically needs two bytes per character, but even if we have an even
+// number of bytes available, we need to check if we end on a leading/high
+// surrogate. In that case, we need to wait for the next two bytes in order to
+// decode the last character properly.
+function utf16Text(buf, i) {
+  if ((buf.length - i) % 2 === 0) {
+    var r = buf.toString('utf16le', i);
+    if (r) {
+      var c = r.charCodeAt(r.length - 1);
+      if (c >= 0xD800 && c <= 0xDBFF) {
+        this.lastNeed = 2;
+        this.lastTotal = 4;
+        this.lastChar[0] = buf[buf.length - 2];
+        this.lastChar[1] = buf[buf.length - 1];
+        return r.slice(0, -1);
+      }
+    }
+    return r;
+  }
+  this.lastNeed = 1;
+  this.lastTotal = 2;
+  this.lastChar[0] = buf[buf.length - 1];
+  return buf.toString('utf16le', i, buf.length - 1);
+}
+
+// For UTF-16LE we do not explicitly append special replacement characters if we
+// end on a partial character, we simply let v8 handle that.
+function utf16End(buf) {
+  var r = buf && buf.length ? this.write(buf) : '';
+  if (this.lastNeed) {
+    var end = this.lastTotal - this.lastNeed;
+    return r + this.lastChar.toString('utf16le', 0, end);
+  }
+  return r;
+}
+
+function base64Text(buf, i) {
+  var n = (buf.length - i) % 3;
+  if (n === 0) return buf.toString('base64', i);
+  this.lastNeed = 3 - n;
+  this.lastTotal = 3;
+  if (n === 1) {
+    this.lastChar[0] = buf[buf.length - 1];
+  } else {
+    this.lastChar[0] = buf[buf.length - 2];
+    this.lastChar[1] = buf[buf.length - 1];
+  }
+  return buf.toString('base64', i, buf.length - n);
+}
+
+function base64End(buf) {
+  var r = buf && buf.length ? this.write(buf) : '';
+  if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
+  return r;
+}
+
+// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
+function simpleWrite(buf) {
+  return buf.toString(this.encoding);
+}
+
+function simpleEnd(buf) {
+  return buf && buf.length ? this.write(buf) : '';
+}

+ 0 - 0
test_two_list/test.html


Някои файлове не бяха показани, защото твърде много файлове са промени