You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5421 lines
187 KiB

5 years ago
  1. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. (function (Buffer){
  3. exports.code = new Buffer("AGFzbQEAAAABPApgAn9/AGABfwBgAX8Bf2ACf38Bf2ADf39/AX9gA39/fwBgA39+fwBgAn9+AGAEf39/fwBgBX9/f39/AAIQAQNlbnYGbWVtb3J5AgDoBwNgXwABAgEDAwQEBQYHCAUFBQAABQAAAAEFBQAABQAAAAEFAAIBAAAFAAUAAAAIAQIAAgUICQMABQUFBQACBQUIAAgCAQEABQUFAAAAAwACAQAABQAFAAAACAECAAIFCAkFB+4IXAhpbnRfY29weQAACGludF96ZXJvAAEHaW50X29uZQADCmludF9pc1plcm8AAgZpbnRfZXEABAdpbnRfZ3RlAAUHaW50X2FkZAAGB2ludF9zdWIABwdpbnRfbXVsAAgHaW50X2RpdgALDmludF9pbnZlcnNlTW9kAAwHZjFtX2FkZAANB2YxbV9zdWIADgdmMW1fbmVnAA8LZjFtX21SZWR1Y3QAEAdmMW1fbXVsABESZjFtX2Zyb21Nb250Z29tZXJ5ABMQZjFtX3RvTW9udGdvbWVyeQASC2YxbV9pbnZlcnNlABQIZjFtX2NvcHkAAAhmMW1femVybwABCmYxbV9pc1plcm8AAgZmMW1fZXEABAdmMW1fb25lABUHZnJtX2FkZAAWB2ZybV9zdWIAFwdmcm1fbmVnABgLZnJtX21SZWR1Y3QAGQdmcm1fbXVsABoSZnJtX2Zyb21Nb250Z29tZXJ5ABwQZ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ACkDGDcDGAseACAAQgA3AwAgAEIANwMIIABCADcDECAAQgA3AxgLMwAgACkDGFAEQCAAKQMQUARAIAApAwhQBEAgACkDAFAPBUEADwsFQQAPCwVBAA8LQQAPCx4AIABCATcDACAAQgA3AwggAEIANwMQIABCADcDGAtHACAAKQMYIAEpAxhRBEAgACkDECABKQMQUQRAIAApAwggASkDCFEEQCAAKQMAIAEpAwBRDwVBAA8LBUEADwsFQQAPC0EADwt9ACAAKQMYIAEpAxhUBEBBAA8FIAApAxggASkDGFYEQEEBDwUgACkDECABKQMQVARAQQAPBSAAKQMQIAEpAxBWBEBBAQ8FIAApAwggASkDCFQEQEEADwUgACkDCCABKQMIVgRAQQEPBSAAKQMAIAEpAwBaDwsLCwsLC0EADwvUAQEBfiAANQIAIAE1AgB8IQMgAiADPgIAIAA1AgQgATUCBHwgA0IgiHwhAyACIAM+AgQgADUCCCABNQIIfCADQiCIfCEDIAIgAz4CCCAANQIMIAE1Agx8IANCIIh8IQMgAiADPgIMIAA1AhAgATUCEHwgA0IgiHwhAyACIAM+AhAgADUCFCABNQIUfCADQiCIfCEDIAIgAz4CFCAANQIYIAE1Ahh8IANCIIh8IQMgAiADPgIYIAA1AhwgATUCHHwgA0IgiHwhAyACIAM+AhwgA0IgiKcLjAIBAX4gADUCACABNQIAfSEDIAIgA0L/////D4M+AgAgADUCBCABNQIEfSADQiCHfCEDIAIgA0L/////D4M+AgQgADUCCCABNQIIfSADQiCHfCEDIAIgA0L/////D4M+AgggADUCDCABNQIMfSADQiCHfCEDIAIgA0L/////D4M+AgwgADUCECABNQIQfSADQiCHfCEDIAIgA0L/////D4M+AhAgADUCFCABNQIUfSADQiCHfCEDIAIgA0L/////D4M+AhQgADUCGCABNQIYfSADQiCHfCEDIAIgA0L/////D4M+AhggADUCHCABNQIcfSADQiCHfCEDIAIgA0L/////D4M+AhwgA0Igh6cL9BABAX5BKCAANQIAIAE1AgB+NwMAQSggADUCACABNQIEfjcDCEEoIAA1AgAgATUCCH43AxBBKCAANQIAIAE1Agx+NwMYQSggADUCACABNQIQfjcDIEEoIAA1AgAgATUCFH43AyhBKCAANQIAIAE1Ahh+NwMwQSggADUCACABNQIcfjcDOEEoIAA1AgQgATUCAH43A0BBKCAANQIEIAE1AgR+NwNIQSggADUCBCABNQIIfjcDUEEoIAA1AgQgATUCDH43A1hBKCAANQIEIAE1AhB+NwNgQSggADUCBCABNQIUfjcDaEEoIAA1AgQgATUCGH43A3BBKCAANQIEIAE1Ahx+NwN4QSggADUCCCABNQIAfjcDgAFBKCAANQIIIAE1AgR+NwOIAUEoIAA1AgggATUCCH43A5ABQSggADUCCCABNQIMfjcDmAFBKCAANQIIIAE1AhB+NwOgAUEoIAA1AgggATUCFH43A6gBQSggADUCCCABNQIYfjcDsAFBKCAANQIIIAE1Ahx+NwO4AUEoIAA1AgwgATUCAH43A8ABQSggADUCDCABNQIEfjcDyAFBKCAANQIMIAE1Agh+NwPQAUEoIAA1AgwgATUCDH43A9gBQSggADUCDCABNQIQfjcD4AFBKCAANQIMIAE1AhR+NwPoAUEoIAA1AgwgATUCGH43A/ABQSggADUCDCABNQIcfjcD+AFBKCAANQIQIAE1AgB+NwOAAkEoIAA1AhAgATUCBH43A4gCQSggADUCECABNQIIfjcDkAJBKCAANQIQIAE1Agx+NwOYAkEoIAA1AhAgATUCEH43A6ACQSggADUCECABNQIUfjcDqAJBKCAANQIQIAE1Ahh+NwOwAkEoIAA1AhAgATUCHH43A7gCQSggADUCFCABNQIAfjcDwAJBKCAANQIUIAE1AgR+NwPIAkEoIAA1AhQgATUCCH43A9ACQSggADUCFCABNQIMfjcD2AJBKCAANQIUIAE1AhB+NwPgAkEoIAA1AhQgATUCFH43A+gCQSggADUCFCABNQIYfjcD8AJBKCAANQIUIAE1Ahx+NwP4AkEoIAA1AhggATUCAH43A4ADQSggADUCGCABNQIEfjcDiANBKCAANQIYIAE1Agh+NwOQA0EoIAA1AhggATUCDH43A5gDQSggADUCGCABNQIQfjcDoANBKCAANQIYIAE1A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yEEIAA1AgQgA0IgiHxB6A01AgAgBH58IQMgACADPgIEIAA1AgggA0IgiHxB6A01AgQgBH58IQMgACADPgIIIAA1AgwgA0IgiHxB6A01AgggBH58IQMgACADPgIMIAA1AhAgA0IgiHxB6A01AgwgBH58IQMgACADPgIQIAA1AhQgA0IgiHxB6A01AhAgBH58IQMgACADPgIUIAA1AhggA0IgiHxB6A01AhQgBH58IQMgACADPgIYIAA1AhwgA0IgiHxB6A01AhggBH58IQMgACADPgIcIAA1AiAgA0IgiHxB6A01AhwgBH58IQMgACADPgIgQegOIANCIIg+AgRCACEDIAA1AgggAn5C/////w+DIQQgADUCCCADQiCIfEHoDTUCACAEfnwhAyAAIAM+AgggADUCDCADQiCIfEHoDTUCBCAEfnwhAyAAIAM+AgwgADUCECADQiCIfEHoDTUCCCAEfnwhAyAAIAM+AhAgADUCFCADQiCIfEHoDTUCDCAEfnwhAyAAIAM+AhQgADUCGCADQiCIfEHoDTUCECAEfnwhAyAAIAM+AhggADUCHCADQiCIfEHoDTUCFCAEfnwhAyAAIAM+AhwgADUCICADQiCIfEHoDTUCGCAEfnwhAyAAIAM+AiAgADUCJCADQiCIfEHoDTUCHCAEfnwhAyAAIAM+AiRB6A4gA0IgiD4CCEIAIQMgADUCDCACfkL/////D4MhBCAANQIMIANCIIh8QegNNQIAIAR+fCEDIAAgAz4CDCAANQIQIANCIIh8QegNNQIEIAR+fCEDIAAgAz4CECAANQIUIANCIIh8QegNNQIIIAR+fCEDIAAgAz4CFCAANQIYIANCIIh8QegNNQIMIAR+fCEDIAAgAz4CGCAANQIcIANCIIh8QegNNQIQIAR+fCEDIAAgAz4CHCAANQIgIANCIIh8QegNNQIUIAR+fCEDIAAgAz4CICAANQIkIANCIIh8QegNNQIYIAR+fCEDIAAgAz4CJCAANQIoIANCIIh8QegNNQIcIAR+fCEDIAAgAz4CKEHoDiADQiCIPgIMQgAhAyAANQIQIAJ+Qv////8PgyEEIAA1AhAgA0IgiHxB6A01AgAgBH58IQMgACAD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MgACADPgIgIAA1AiQgA0IgiHxB6A01AgggBH58IQMgACADPgIkIAA1AiggA0IgiHxB6A01AgwgBH58IQMgACADPgIoIAA1AiwgA0IgiHxB6A01AhAgBH58IQMgACADPgIsIAA1AjAgA0IgiHxB6A01AhQgBH58IQMgACADPgIwIAA1AjQgA0IgiHxB6A01AhggBH58IQMgACADPgI0IAA1AjggA0IgiHxB6A01AhwgBH58IQMgACADPgI4QegOIANCIIg+AhxB6A4gAEEgaiABEBYLEgAgACABQegSEAhB6BIgAhAZCwsAIABBiA4gARAaCxUAIABBqBMQAEHIExABQagTIAEQGQsXACAAIAEQHCABQegNIAEQDCABIAEQGwsJAEGoDiAAEAALFQAgACABQegTEBpB6BNBiA4gAhAaCwsAIABB6A0gARAMCwoAIABBwABqEAILFQAgABABIABBIGoQFSAAQcAAahABCyIAIAAgARAAIABBIGogAUEgahAAIABBwABqIAFBwABqEAALhgIAIAAQIQRAIAAgARAjDwsgACAAQYgUEBEgAEEgaiAAQSBqQagUEBFBqBRBqBRByBQQESAAQagUQegUEA1B6BRB6BRB6BQQEUHoFEGIFEHoFBAOQegUQcgUQegUEA5B6BRB6BRB6BQQDUGIFEGIFEGIFRANQYgVQYgUQYgVEA1BiBVBiBVBqBUQESAAQSBqIABBwABqQcgVEBFB6BRB6BQgARANQagVIAEgARAOQcgUQcgUQegVEA1B6BVB6BVB6BUQDUHoFUHoFUHoFRANQegUIAEgAUEgahAOIAFBIGpBiBUgAUEgahARIAFBIGpB6BUgAUEgahAOQcgVQcgVIAFBwABqEA0LrAMCAX8BfyAAQcAAaiEDIAFBwABqIQQgABAhBEAgASACECMPCyABECEEQCAAIAIQIw8LIAMgA0GIFhARIAQgBEGoFhARIABBqBZByBYQESABQYgWQegWEBEgA0GIFkGIFxARIARBqBZBqBcQESAAQSBqQagXQcgXEBEgAUEgakGIF0HoFxARQcgWQegWEAQEQEHIF0HoFxAEBEAgACACECQPCwtB6BZByBZBiBgQDkHoF0HIF0GoGBAOQYgYQYgYQcgYEA1ByBhByBhByBgQEUGIGEHIGEHoGBARQagYQagYQYgZEA1ByBZByBhByBkQEUGIGUGIGUGoGRARQcgZQcgZQegZEA1BqBlB6BggAhAOIAJB6BkgAhAOQcgXQegYQYgaEBFBiBpBiBpBiBoQDUHIGSACIAJBIGoQDiACQSBqQYgZIAJBIGoQESACQSBqQYgaIAJBIGoQDiADIAQgAkHAAGoQDSACQcAAaiACQcAAaiACQcAAahARIAJBwABqQYgWIAJBwABqEA4gAkHAAGpBqBYgAkHAAGoQDiACQcAAakGIGCACQcAAahARCyIAIAAgARAAIABBIGogAUEgahAPIABBwABqIAFBwABqEAALEAAgASACECYgACACIAIQJQsiACAAIAEQEyAAQSBqIAFBIGoQEyAAQcAAaiABQcAAahATCyIAIAAgARASIABBIGogAUEgahASIABBwABqIAFBwABqEBILTwAgABAhBEAgARAiBSAAQcAAakGoGhAUQagaQagaQcgaEBFBqBpByBpB6BoQESAAQcgaIAEQESAAQSBqQegaIAFBIGoQESABQcAAahAVCwunAgIBfwF/IABBiBsQIyADECIgAiEEAkADQCAEQQFrIQQgASAEai0AACEFIAMgAxAkIAVBgAFPBEAgBUGAAWshBUGIGyADIAMQJQsgAyADECQgBUHAAE8EQCAFQcAAayEFQYgbIAMgAxAlCyADIAMQJCAFQSBPBEAgBUEgayEFQYgbIAMgAxAlCyADIAMQJCAFQRBPBEAgBUEQayEFQYgbIAMgAxAlCyADIAMQJCAFQQhPBEAgBUEIayEFQYgbIAMgAxAlCyADIAMQJCAFQQRPBEAgBUEEayEFQYgbIAMgAxAlCyADIAMQJCAFQQJPBEAgBUECayEFQYgbIAMgAxAlCyADIAMQJCAFQQFPBEAgBUEBayEFQYgbIAMgAxAlCyAERQ0BDAALCwsrAgF/AX8gAEEFdkECdCEBQQEgAEEfcXQhAiABIAEoAujbASACcjYC6NsBCyQCAX8BfyAAQQV2QQJ0IQFBASAAQR9xdCECIAEoAujbASACcQugAQQBfwF/AX8BfyAAIQJB6BsQIkEAIQQCQANAI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gAEBAYACAgKCAwMDAAQEBIQFBQUEBgYGBgYGBwAICAiICQkJCAoKCgoKCgsIDAwMDAwMDQwMDA4MDg4OABAQEJAREREQEhISEhISExAUFBQUFBQVFBQUFhQWFhYQGBgYGBgYGRgYGBoYGhoaGBgYHBgcHBwYHBwcHBwcHgAgICCgISEhICIiIiIiIiMgJCQkJCQkJSQkJCYkJiYmICgoKCgoKCkoKCgqKCoqKigoKCwoLCwsKCwsLCwsLC4gMDAwMDAwMTAwMDIwMjIyMDAwNDA0NDQwNDQ0NDQ0NjAwMDgwODg4MDg4ODg4ODowODg4ODg4PDg4ODw4PDw8ABB6IgFC4ACAAAAAQABAgEAAQIBBAECAwABAgEEAQIDCAECAwQFBgMAAQIBBAECAwgBAgMEBQYDEAECAwQFBgMICQoDDAUGBwABAgEEAQIDCAECAwQFBgMQAQIDBAUGAwgJCgMMBQYHIAECAwQFBgMICQoDDAUGBxAREgMUBQYHGAkKCwwNDgcAAQIBBAECAwgBAgMEBQYDEAECAwQFBgMICQoDDAUGByABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HQAECAwQFBgMICQoDDAUGBxAREgMUBQYHGAkKCwwNDgcgISIDJAUGBygJCgsMDQ4HMBESExQVFgcYGRoLHA0ODw==", "base64");
  4. exports.pq = 1000;
  5. exports.pr = 1768;
  6. }).call(this,require("buffer").Buffer)
  7. },{"buffer":10}],2:[function(require,module,exports){
  8. /*
  9. Copyright 2019 0KIMS association.
  10. This file is part of websnark (Web Assembly zkSnark Prover).
  11. websnark is a free software: you can redistribute it and/or modify it
  12. under the terms of the GNU General Public License as published by
  13. the Free Software Foundation, either version 3 of the License, or
  14. (at your option) any later version.
  15. websnark is distributed in the hope that it will be useful, but WITHOUT
  16. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  18. License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with websnark. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /* globals window */
  23. const buildGroth16 = require("./src/groth16.js");
  24. buildGroth16().then( (groth16) => {
  25. window.genZKSnarkProof = function(witness, provingKey, cb) {
  26. const p = groth16.proof(witness, provingKey);
  27. if (cb) {
  28. p.then( (proof) => {
  29. cb(null, proof);
  30. }, (err) => {
  31. cb(err);
  32. });
  33. } else {
  34. return p;
  35. }
  36. };
  37. });
  38. },{"./src/groth16.js":4}],3:[function(require,module,exports){
  39. var bigInt = (function (undefined) {
  40. "use strict";
  41. var BASE = 1e7,
  42. LOG_BASE = 7,
  43. MAX_INT = 9007199254740992,
  44. MAX_INT_ARR = smallToArray(MAX_INT),
  45. DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
  46. var supportsNativeBigInt = typeof BigInt === "function";
  47. function Integer(v, radix, alphabet, caseSensitive) {
  48. if (typeof v === "undefined") return Integer[0];
  49. if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive);
  50. return parseValue(v);
  51. }
  52. function BigInteger(value, sign) {
  53. this.value = value;
  54. this.sign = sign;
  55. this.isSmall = false;
  56. }
  57. BigInteger.prototype = Object.create(Integer.prototype);
  58. function SmallInteger(value) {
  59. this.value = value;
  60. this.sign = value < 0;
  61. this.isSmall = true;
  62. }
  63. SmallInteger.prototype = Object.create(Integer.prototype);
  64. function NativeBigInt(value) {
  65. this.value = value;
  66. }
  67. NativeBigInt.prototype = Object.create(Integer.prototype);
  68. function isPrecise(n) {
  69. return -MAX_INT < n && n < MAX_INT;
  70. }
  71. function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes
  72. if (n < 1e7)
  73. return [n];
  74. if (n < 1e14)
  75. return [n % 1e7, Math.floor(n / 1e7)];
  76. return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)];
  77. }
  78. function arrayToSmall(arr) { // If BASE changes this function may need to change
  79. trim(arr);
  80. var length = arr.length;
  81. if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) {
  82. switch (length) {
  83. case 0: return 0;
  84. case 1: return arr[0];
  85. case 2: return arr[0] + arr[1] * BASE;
  86. default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE;
  87. }
  88. }
  89. return arr;
  90. }
  91. function trim(v) {
  92. var i = v.length;
  93. while (v[--i] === 0);
  94. v.length = i + 1;
  95. }
  96. function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger
  97. var x = new Array(length);
  98. var i = -1;
  99. while (++i < length) {
  100. x[i] = 0;
  101. }
  102. return x;
  103. }
  104. function truncate(n) {
  105. if (n > 0) return Math.floor(n);
  106. return Math.ceil(n);
  107. }
  108. function add(a, b) { // assumes a and b are arrays with a.length >= b.length
  109. var l_a = a.length,
  110. l_b = b.length,
  111. r = new Array(l_a),
  112. carry = 0,
  113. base = BASE,
  114. sum, i;
  115. for (i = 0; i < l_b; i++) {
  116. sum = a[i] + b[i] + carry;
  117. carry = sum >= base ? 1 : 0;
  118. r[i] = sum - carry * base;
  119. }
  120. while (i < l_a) {
  121. sum = a[i] + carry;
  122. carry = sum === base ? 1 : 0;
  123. r[i++] = sum - carry * base;
  124. }
  125. if (carry > 0) r.push(carry);
  126. return r;
  127. }
  128. function addAny(a, b) {
  129. if (a.length >= b.length) return add(a, b);
  130. return add(b, a);
  131. }
  132. function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT
  133. var l = a.length,
  134. r = new Array(l),
  135. base = BASE,
  136. sum, i;
  137. for (i = 0; i < l; i++) {
  138. sum = a[i] - base + carry;
  139. carry = Math.floor(sum / base);
  140. r[i] = sum - carry * base;
  141. carry += 1;
  142. }
  143. while (carry > 0) {
  144. r[i++] = carry % base;
  145. carry = Math.floor(carry / base);
  146. }
  147. return r;
  148. }
  149. BigInteger.prototype.add = function (v) {
  150. var n = parseValue(v);
  151. if (this.sign !== n.sign) {
  152. return this.subtract(n.negate());
  153. }
  154. var a = this.value, b = n.value;
  155. if (n.isSmall) {
  156. return new BigInteger(addSmall(a, Math.abs(b)), this.sign);
  157. }
  158. return new BigInteger(addAny(a, b), this.sign);
  159. };
  160. BigInteger.prototype.plus = BigInteger.prototype.add;
  161. SmallInteger.prototype.add = function (v) {
  162. var n = parseValue(v);
  163. var a = this.value;
  164. if (a < 0 !== n.sign) {
  165. return this.subtract(n.negate());
  166. }
  167. var b = n.value;
  168. if (n.isSmall) {
  169. if (isPrecise(a + b)) return new SmallInteger(a + b);
  170. b = smallToArray(Math.abs(b));
  171. }
  172. return new BigInteger(addSmall(b, Math.abs(a)), a < 0);
  173. };
  174. SmallInteger.prototype.plus = SmallInteger.prototype.add;
  175. NativeBigInt.prototype.add = function (v) {
  176. return new NativeBigInt(this.value + parseValue(v).value);
  177. }
  178. NativeBigInt.prototype.plus = NativeBigInt.prototype.add;
  179. function subtract(a, b) { // assumes a and b are arrays with a >= b
  180. var a_l = a.length,
  181. b_l = b.length,
  182. r = new Array(a_l),
  183. borrow = 0,
  184. base = BASE,
  185. i, difference;
  186. for (i = 0; i < b_l; i++) {
  187. difference = a[i] - borrow - b[i];
  188. if (difference < 0) {
  189. difference += base;
  190. borrow = 1;
  191. } else borrow = 0;
  192. r[i] = difference;
  193. }
  194. for (i = b_l; i < a_l; i++) {
  195. difference = a[i] - borrow;
  196. if (difference < 0) difference += base;
  197. else {
  198. r[i++] = difference;
  199. break;
  200. }
  201. r[i] = difference;
  202. }
  203. for (; i < a_l; i++) {
  204. r[i] = a[i];
  205. }
  206. trim(r);
  207. return r;
  208. }
  209. function subtractAny(a, b, sign) {
  210. var value;
  211. if (compareAbs(a, b) >= 0) {
  212. value = subtract(a, b);
  213. } else {
  214. value = subtract(b, a);
  215. sign = !sign;
  216. }
  217. value = arrayToSmall(value);
  218. if (typeof value === "number") {
  219. if (sign) value = -value;
  220. return new SmallInteger(value);
  221. }
  222. return new BigInteger(value, sign);
  223. }
  224. function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT
  225. var l = a.length,
  226. r = new Array(l),
  227. carry = -b,
  228. base = BASE,
  229. i, difference;
  230. for (i = 0; i < l; i++) {
  231. difference = a[i] + carry;
  232. carry = Math.floor(difference / base);
  233. difference %= base;
  234. r[i] = difference < 0 ? difference + base : difference;
  235. }
  236. r = arrayToSmall(r);
  237. if (typeof r === "number") {
  238. if (sign) r = -r;
  239. return new SmallInteger(r);
  240. } return new BigInteger(r, sign);
  241. }
  242. BigInteger.prototype.subtract = function (v) {
  243. var n = parseValue(v);
  244. if (this.sign !== n.sign) {
  245. return this.add(n.negate());
  246. }
  247. var a = this.value, b = n.value;
  248. if (n.isSmall)
  249. return subtractSmall(a, Math.abs(b), this.sign);
  250. return subtractAny(a, b, this.sign);
  251. };
  252. BigInteger.prototype.minus = BigInteger.prototype.subtract;
  253. SmallInteger.prototype.subtract = function (v) {
  254. var n = parseValue(v);
  255. var a = this.value;
  256. if (a < 0 !== n.sign) {
  257. return this.add(n.negate());
  258. }
  259. var b = n.value;
  260. if (n.isSmall) {
  261. return new SmallInteger(a - b);
  262. }
  263. return subtractSmall(b, Math.abs(a), a >= 0);
  264. };
  265. SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
  266. NativeBigInt.prototype.subtract = function (v) {
  267. return new NativeBigInt(this.value - parseValue(v).value);
  268. }
  269. NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract;
  270. BigInteger.prototype.negate = function () {
  271. return new BigInteger(this.value, !this.sign);
  272. };
  273. SmallInteger.prototype.negate = function () {
  274. var sign = this.sign;
  275. var small = new SmallInteger(-this.value);
  276. small.sign = !sign;
  277. return small;
  278. };
  279. NativeBigInt.prototype.negate = function () {
  280. return new NativeBigInt(-this.value);
  281. }
  282. BigInteger.prototype.abs = function () {
  283. return new BigInteger(this.value, false);
  284. };
  285. SmallInteger.prototype.abs = function () {
  286. return new SmallInteger(Math.abs(this.value));
  287. };
  288. NativeBigInt.prototype.abs = function () {
  289. return new NativeBigInt(this.value >= 0 ? this.value : -this.value);
  290. }
  291. function multiplyLong(a, b) {
  292. var a_l = a.length,
  293. b_l = b.length,
  294. l = a_l + b_l,
  295. r = createArray(l),
  296. base = BASE,
  297. product, carry, i, a_i, b_j;
  298. for (i = 0; i < a_l; ++i) {
  299. a_i = a[i];
  300. for (var j = 0; j < b_l; ++j) {
  301. b_j = b[j];
  302. product = a_i * b_j + r[i + j];
  303. carry = Math.floor(product / base);
  304. r[i + j] = product - carry * base;
  305. r[i + j + 1] += carry;
  306. }
  307. }
  308. trim(r);
  309. return r;
  310. }
  311. function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE
  312. var l = a.length,
  313. r = new Array(l),
  314. base = BASE,
  315. carry = 0,
  316. product, i;
  317. for (i = 0; i < l; i++) {
  318. product = a[i] * b + carry;
  319. carry = Math.floor(product / base);
  320. r[i] = product - carry * base;
  321. }
  322. while (carry > 0) {
  323. r[i++] = carry % base;
  324. carry = Math.floor(carry / base);
  325. }
  326. return r;
  327. }
  328. function shiftLeft(x, n) {
  329. var r = [];
  330. while (n-- > 0) r.push(0);
  331. return r.concat(x);
  332. }
  333. function multiplyKaratsuba(x, y) {
  334. var n = Math.max(x.length, y.length);
  335. if (n <= 30) return multiplyLong(x, y);
  336. n = Math.ceil(n / 2);
  337. var b = x.slice(n),
  338. a = x.slice(0, n),
  339. d = y.slice(n),
  340. c = y.slice(0, n);
  341. var ac = multiplyKaratsuba(a, c),
  342. bd = multiplyKaratsuba(b, d),
  343. abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d));
  344. var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n));
  345. trim(product);
  346. return product;
  347. }
  348. // The following function is derived from a surface fit of a graph plotting the performance difference
  349. // between long multiplication and karatsuba multiplication versus the lengths of the two arrays.
  350. function useKaratsuba(l1, l2) {
  351. return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0;
  352. }
  353. BigInteger.prototype.multiply = function (v) {
  354. var n = parseValue(v),
  355. a = this.value, b = n.value,
  356. sign = this.sign !== n.sign,
  357. abs;
  358. if (n.isSmall) {
  359. if (b === 0) return Integer[0];
  360. if (b === 1) return this;
  361. if (b === -1) return this.negate();
  362. abs = Math.abs(b);
  363. if (abs < BASE) {
  364. return new BigInteger(multiplySmall(a, abs), sign);
  365. }
  366. b = smallToArray(abs);
  367. }
  368. if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes
  369. return new BigInteger(multiplyKaratsuba(a, b), sign);
  370. return new BigInteger(multiplyLong(a, b), sign);
  371. };
  372. BigInteger.prototype.times = BigInteger.prototype.multiply;
  373. function multiplySmallAndArray(a, b, sign) { // a >= 0
  374. if (a < BASE) {
  375. return new BigInteger(multiplySmall(b, a), sign);
  376. }
  377. return new BigInteger(multiplyLong(b, smallToArray(a)), sign);
  378. }
  379. SmallInteger.prototype._multiplyBySmall = function (a) {
  380. if (isPrecise(a.value * this.value)) {
  381. return new SmallInteger(a.value * this.value);
  382. }
  383. return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign);
  384. };
  385. BigInteger.prototype._multiplyBySmall = function (a) {
  386. if (a.value === 0) return Integer[0];
  387. if (a.value === 1) return this;
  388. if (a.value === -1) return this.negate();
  389. return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign);
  390. };
  391. SmallInteger.prototype.multiply = function (v) {
  392. return parseValue(v)._multiplyBySmall(this);
  393. };
  394. SmallInteger.prototype.times = SmallInteger.prototype.multiply;
  395. NativeBigInt.prototype.multiply = function (v) {
  396. return new NativeBigInt(this.value * parseValue(v).value);
  397. }
  398. NativeBigInt.prototype.times = NativeBigInt.prototype.multiply;
  399. function square(a) {
  400. //console.assert(2 * BASE * BASE < MAX_INT);
  401. var l = a.length,
  402. r = createArray(l + l),
  403. base = BASE,
  404. product, carry, i, a_i, a_j;
  405. for (i = 0; i < l; i++) {
  406. a_i = a[i];
  407. carry = 0 - a_i * a_i;
  408. for (var j = i; j < l; j++) {
  409. a_j = a[j];
  410. product = 2 * (a_i * a_j) + r[i + j] + carry;
  411. carry = Math.floor(product / base);
  412. r[i + j] = product - carry * base;
  413. }
  414. r[i + l] = carry;
  415. }
  416. trim(r);
  417. return r;
  418. }
  419. BigInteger.prototype.square = function () {
  420. return new BigInteger(square(this.value), false);
  421. };
  422. SmallInteger.prototype.square = function () {
  423. var value = this.value * this.value;
  424. if (isPrecise(value)) return new SmallInteger(value);
  425. return new BigInteger(square(smallToArray(Math.abs(this.value))), false);
  426. };
  427. NativeBigInt.prototype.square = function (v) {
  428. return new NativeBigInt(this.value * this.value);
  429. }
  430. function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes.
  431. var a_l = a.length,
  432. b_l = b.length,
  433. base = BASE,
  434. result = createArray(b.length),
  435. divisorMostSignificantDigit = b[b_l - 1],
  436. // normalization
  437. lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)),
  438. remainder = multiplySmall(a, lambda),
  439. divisor = multiplySmall(b, lambda),
  440. quotientDigit, shift, carry, borrow, i, l, q;
  441. if (remainder.length <= a_l) remainder.push(0);
  442. divisor.push(0);
  443. divisorMostSignificantDigit = divisor[b_l - 1];
  444. for (shift = a_l - b_l; shift >= 0; shift--) {
  445. quotientDigit = base - 1;
  446. if (remainder[shift + b_l] !== divisorMostSignificantDigit) {
  447. quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit);
  448. }
  449. // quotientDigit <= base - 1
  450. carry = 0;
  451. borrow = 0;
  452. l = divisor.length;
  453. for (i = 0; i < l; i++) {
  454. carry += quotientDigit * divisor[i];
  455. q = Math.floor(carry / base);
  456. borrow += remainder[shift + i] - (carry - q * base);
  457. carry = q;
  458. if (borrow < 0) {
  459. remainder[shift + i] = borrow + base;
  460. borrow = -1;
  461. } else {
  462. remainder[shift + i] = borrow;
  463. borrow = 0;
  464. }
  465. }
  466. while (borrow !== 0) {
  467. quotientDigit -= 1;
  468. carry = 0;
  469. for (i = 0; i < l; i++) {
  470. carry += remainder[shift + i] - base + divisor[i];
  471. if (carry < 0) {
  472. remainder[shift + i] = carry + base;
  473. carry = 0;
  474. } else {
  475. remainder[shift + i] = carry;
  476. carry = 1;
  477. }
  478. }
  479. borrow += carry;
  480. }
  481. result[shift] = quotientDigit;
  482. }
  483. // denormalization
  484. remainder = divModSmall(remainder, lambda)[0];
  485. return [arrayToSmall(result), arrayToSmall(remainder)];
  486. }
  487. function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/
  488. // Performs faster than divMod1 on larger input sizes.
  489. var a_l = a.length,
  490. b_l = b.length,
  491. result = [],
  492. part = [],
  493. base = BASE,
  494. guess, xlen, highx, highy, check;
  495. while (a_l) {
  496. part.unshift(a[--a_l]);
  497. trim(part);
  498. if (compareAbs(part, b) < 0) {
  499. result.push(0);
  500. continue;
  501. }
  502. xlen = part.length;
  503. highx = part[xlen - 1] * base + part[xlen - 2];
  504. highy = b[b_l - 1] * base + b[b_l - 2];
  505. if (xlen > b_l) {
  506. highx = (highx + 1) * base;
  507. }
  508. guess = Math.ceil(highx / highy);
  509. do {
  510. check = multiplySmall(b, guess);
  511. if (compareAbs(check, part) <= 0) break;
  512. guess--;
  513. } while (guess);
  514. result.push(guess);
  515. part = subtract(part, check);
  516. }
  517. result.reverse();
  518. return [arrayToSmall(result), arrayToSmall(part)];
  519. }
  520. function divModSmall(value, lambda) {
  521. var length = value.length,
  522. quotient = createArray(length),
  523. base = BASE,
  524. i, q, remainder, divisor;
  525. remainder = 0;
  526. for (i = length - 1; i >= 0; --i) {
  527. divisor = remainder * base + value[i];
  528. q = truncate(divisor / lambda);
  529. remainder = divisor - q * lambda;
  530. quotient[i] = q | 0;
  531. }
  532. return [quotient, remainder | 0];
  533. }
  534. function divModAny(self, v) {
  535. var value, n = parseValue(v);
  536. if (supportsNativeBigInt) {
  537. return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)];
  538. }
  539. var a = self.value, b = n.value;
  540. var quotient;
  541. if (b === 0) throw new Error("Cannot divide by zero");
  542. if (self.isSmall) {
  543. if (n.isSmall) {
  544. return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
  545. }
  546. return [Integer[0], self];
  547. }
  548. if (n.isSmall) {
  549. if (b === 1) return [self, Integer[0]];
  550. if (b == -1) return [self.negate(), Integer[0]];
  551. var abs = Math.abs(b);
  552. if (abs < BASE) {
  553. value = divModSmall(a, abs);
  554. quotient = arrayToSmall(value[0]);
  555. var remainder = value[1];
  556. if (self.sign) remainder = -remainder;
  557. if (typeof quotient === "number") {
  558. if (self.sign !== n.sign) quotient = -quotient;
  559. return [new SmallInteger(quotient), new SmallInteger(remainder)];
  560. }
  561. return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)];
  562. }
  563. b = smallToArray(abs);
  564. }
  565. var comparison = compareAbs(a, b);
  566. if (comparison === -1) return [Integer[0], self];
  567. if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]];
  568. // divMod1 is faster on smaller input sizes
  569. if (a.length + b.length <= 200)
  570. value = divMod1(a, b);
  571. else value = divMod2(a, b);
  572. quotient = value[0];
  573. var qSign = self.sign !== n.sign,
  574. mod = value[1],
  575. mSign = self.sign;
  576. if (typeof quotient === "number") {
  577. if (qSign) quotient = -quotient;
  578. quotient = new SmallInteger(quotient);
  579. } else quotient = new BigInteger(quotient, qSign);
  580. if (typeof mod === "number") {
  581. if (mSign) mod = -mod;
  582. mod = new SmallInteger(mod);
  583. } else mod = new BigInteger(mod, mSign);
  584. return [quotient, mod];
  585. }
  586. BigInteger.prototype.divmod = function (v) {
  587. var result = divModAny(this, v);
  588. return {
  589. quotient: result[0],
  590. remainder: result[1]
  591. };
  592. };
  593. NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod;
  594. BigInteger.prototype.divide = function (v) {
  595. return divModAny(this, v)[0];
  596. };
  597. NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) {
  598. return new NativeBigInt(this.value / parseValue(v).value);
  599. };
  600. SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide;
  601. BigInteger.prototype.mod = function (v) {
  602. return divModAny(this, v)[1];
  603. };
  604. NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) {
  605. return new NativeBigInt(this.value % parseValue(v).value);
  606. };
  607. SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod;
  608. BigInteger.prototype.pow = function (v) {
  609. var n = parseValue(v),
  610. a = this.value,
  611. b = n.value,
  612. value, x, y;
  613. if (b === 0) return Integer[1];
  614. if (a === 0) return Integer[0];
  615. if (a === 1) return Integer[1];
  616. if (a === -1) return n.isEven() ? Integer[1] : Integer[-1];
  617. if (n.sign) {
  618. return Integer[0];
  619. }
  620. if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
  621. if (this.isSmall) {
  622. if (isPrecise(value = Math.pow(a, b)))
  623. return new SmallInteger(truncate(value));
  624. }
  625. x = this;
  626. y = Integer[1];
  627. while (true) {
  628. if (b & 1 === 1) {
  629. y = y.times(x);
  630. --b;
  631. }
  632. if (b === 0) break;
  633. b /= 2;
  634. x = x.square();
  635. }
  636. return y;
  637. };
  638. SmallInteger.prototype.pow = BigInteger.prototype.pow;
  639. NativeBigInt.prototype.pow = function (v) {
  640. var n = parseValue(v);
  641. var a = this.value, b = n.value;
  642. var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2);
  643. if (b === _0) return Integer[1];
  644. if (a === _0) return Integer[0];
  645. if (a === _1) return Integer[1];
  646. if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1];
  647. if (n.isNegative()) return new NativeBigInt(_0);
  648. var x = this;
  649. var y = Integer[1];
  650. while (true) {
  651. if ((b & _1) === _1) {
  652. y = y.times(x);
  653. --b;
  654. }
  655. if (b === _0) break;
  656. b /= _2;
  657. x = x.square();
  658. }
  659. return y;
  660. }
  661. BigInteger.prototype.modPow = function (exp, mod) {
  662. exp = parseValue(exp);
  663. mod = parseValue(mod);
  664. if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
  665. var r = Integer[1],
  666. base = this.mod(mod);
  667. while (exp.isPositive()) {
  668. if (base.isZero()) return Integer[0];
  669. if (exp.isOdd()) r = r.multiply(base).mod(mod);
  670. exp = exp.divide(2);
  671. base = base.square().mod(mod);
  672. }
  673. return r;
  674. };
  675. NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow;
  676. function compareAbs(a, b) {
  677. if (a.length !== b.length) {
  678. return a.length > b.length ? 1 : -1;
  679. }
  680. for (var i = a.length - 1; i >= 0; i--) {
  681. if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
  682. }
  683. return 0;
  684. }
  685. BigInteger.prototype.compareAbs = function (v) {
  686. var n = parseValue(v),
  687. a = this.value,
  688. b = n.value;
  689. if (n.isSmall) return 1;
  690. return compareAbs(a, b);
  691. };
  692. SmallInteger.prototype.compareAbs = function (v) {
  693. var n = parseValue(v),
  694. a = Math.abs(this.value),
  695. b = n.value;
  696. if (n.isSmall) {
  697. b = Math.abs(b);
  698. return a === b ? 0 : a > b ? 1 : -1;
  699. }
  700. return -1;
  701. };
  702. NativeBigInt.prototype.compareAbs = function (v) {
  703. var a = this.value;
  704. var b = parseValue(v).value;
  705. a = a >= 0 ? a : -a;
  706. b = b >= 0 ? b : -b;
  707. return a === b ? 0 : a > b ? 1 : -1;
  708. }
  709. BigInteger.prototype.compare = function (v) {
  710. // See discussion about comparison with Infinity:
  711. // https://github.com/peterolson/BigInteger.js/issues/61
  712. if (v === Infinity) {
  713. return -1;
  714. }
  715. if (v === -Infinity) {
  716. return 1;
  717. }
  718. var n = parseValue(v),
  719. a = this.value,
  720. b = n.value;
  721. if (this.sign !== n.sign) {
  722. return n.sign ? 1 : -1;
  723. }
  724. if (n.isSmall) {
  725. return this.sign ? -1 : 1;
  726. }
  727. return compareAbs(a, b) * (this.sign ? -1 : 1);
  728. };
  729. BigInteger.prototype.compareTo = BigInteger.prototype.compare;
  730. SmallInteger.prototype.compare = function (v) {
  731. if (v === Infinity) {
  732. return -1;
  733. }
  734. if (v === -Infinity) {
  735. return 1;
  736. }
  737. var n = parseValue(v),
  738. a = this.value,
  739. b = n.value;
  740. if (n.isSmall) {
  741. return a == b ? 0 : a > b ? 1 : -1;
  742. }
  743. if (a < 0 !== n.sign) {
  744. return a < 0 ? -1 : 1;
  745. }
  746. return a < 0 ? 1 : -1;
  747. };
  748. SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
  749. NativeBigInt.prototype.compare = function (v) {
  750. if (v === Infinity) {
  751. return -1;
  752. }
  753. if (v === -Infinity) {
  754. return 1;
  755. }
  756. var a = this.value;
  757. var b = parseValue(v).value;
  758. return a === b ? 0 : a > b ? 1 : -1;
  759. }
  760. NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare;
  761. BigInteger.prototype.equals = function (v) {
  762. return this.compare(v) === 0;
  763. };
  764. NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals;
  765. BigInteger.prototype.notEquals = function (v) {
  766. return this.compare(v) !== 0;
  767. };
  768. NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals;
  769. BigInteger.prototype.greater = function (v) {
  770. return this.compare(v) > 0;
  771. };
  772. NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater;
  773. BigInteger.prototype.lesser = function (v) {
  774. return this.compare(v) < 0;
  775. };
  776. NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser;
  777. BigInteger.prototype.greaterOrEquals = function (v) {
  778. return this.compare(v) >= 0;
  779. };
  780. NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals;
  781. BigInteger.prototype.lesserOrEquals = function (v) {
  782. return this.compare(v) <= 0;
  783. };
  784. NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals;
  785. BigInteger.prototype.isEven = function () {
  786. return (this.value[0] & 1) === 0;
  787. };
  788. SmallInteger.prototype.isEven = function () {
  789. return (this.value & 1) === 0;
  790. };
  791. NativeBigInt.prototype.isEven = function () {
  792. return (this.value & BigInt(1)) === BigInt(0);
  793. }
  794. BigInteger.prototype.isOdd = function () {
  795. return (this.value[0] & 1) === 1;
  796. };
  797. SmallInteger.prototype.isOdd = function () {
  798. return (this.value & 1) === 1;
  799. };
  800. NativeBigInt.prototype.isOdd = function () {
  801. return (this.value & BigInt(1)) === BigInt(1);
  802. }
  803. BigInteger.prototype.isPositive = function () {
  804. return !this.sign;
  805. };
  806. SmallInteger.prototype.isPositive = function () {
  807. return this.value > 0;
  808. };
  809. NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive;
  810. BigInteger.prototype.isNegative = function () {
  811. return this.sign;
  812. };
  813. SmallInteger.prototype.isNegative = function () {
  814. return this.value < 0;
  815. };
  816. NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative;
  817. BigInteger.prototype.isUnit = function () {
  818. return false;
  819. };
  820. SmallInteger.prototype.isUnit = function () {
  821. return Math.abs(this.value) === 1;
  822. };
  823. NativeBigInt.prototype.isUnit = function () {
  824. return this.abs().value === BigInt(1);
  825. }
  826. BigInteger.prototype.isZero = function () {
  827. return false;
  828. };
  829. SmallInteger.prototype.isZero = function () {
  830. return this.value === 0;
  831. };
  832. NativeBigInt.prototype.isZero = function () {
  833. return this.value === BigInt(0);
  834. }
  835. BigInteger.prototype.isDivisibleBy = function (v) {
  836. var n = parseValue(v);
  837. if (n.isZero()) return false;
  838. if (n.isUnit()) return true;
  839. if (n.compareAbs(2) === 0) return this.isEven();
  840. return this.mod(n).isZero();
  841. };
  842. NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
  843. function isBasicPrime(v) {
  844. var n = v.abs();
  845. if (n.isUnit()) return false;
  846. if (n.equals(2) || n.equals(3) || n.equals(5)) return true;
  847. if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
  848. if (n.lesser(49)) return true;
  849. // we don't know if it's prime: let the other functions figure it out
  850. }
  851. function millerRabinTest(n, a) {
  852. var nPrev = n.prev(),
  853. b = nPrev,
  854. r = 0,
  855. d, t, i, x;
  856. while (b.isEven()) b = b.divide(2), r++;
  857. next: for (i = 0; i < a.length; i++) {
  858. if (n.lesser(a[i])) continue;
  859. x = bigInt(a[i]).modPow(b, n);
  860. if (x.isUnit() || x.equals(nPrev)) continue;
  861. for (d = r - 1; d != 0; d--) {
  862. x = x.square().mod(n);
  863. if (x.isUnit()) return false;
  864. if (x.equals(nPrev)) continue next;
  865. }
  866. return false;
  867. }
  868. return true;
  869. }
  870. // Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2
  871. BigInteger.prototype.isPrime = function (strict) {
  872. var isPrime = isBasicPrime(this);
  873. if (isPrime !== undefined) return isPrime;
  874. var n = this.abs();
  875. var bits = n.bitLength();
  876. if (bits <= 64)
  877. return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
  878. var logN = Math.log(2) * bits.toJSNumber();
  879. var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN);
  880. for (var a = [], i = 0; i < t; i++) {
  881. a.push(bigInt(i + 2));
  882. }
  883. return millerRabinTest(n, a);
  884. };
  885. NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
  886. BigInteger.prototype.isProbablePrime = function (iterations) {
  887. var isPrime = isBasicPrime(this);
  888. if (isPrime !== undefined) return isPrime;
  889. var n = this.abs();
  890. var t = iterations === undefined ? 5 : iterations;
  891. for (var a = [], i = 0; i < t; i++) {
  892. a.push(bigInt.randBetween(2, n.minus(2)));
  893. }
  894. return millerRabinTest(n, a);
  895. };
  896. NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime;
  897. BigInteger.prototype.modInv = function (n) {
  898. var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR;
  899. while (!newR.isZero()) {
  900. q = r.divide(newR);
  901. lastT = t;
  902. lastR = r;
  903. t = newT;
  904. r = newR;
  905. newT = lastT.subtract(q.multiply(newT));
  906. newR = lastR.subtract(q.multiply(newR));
  907. }
  908. if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
  909. if (t.compare(0) === -1) {
  910. t = t.add(n);
  911. }
  912. if (this.isNegative()) {
  913. return t.negate();
  914. }
  915. return t;
  916. };
  917. NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
  918. BigInteger.prototype.next = function () {
  919. var value = this.value;
  920. if (this.sign) {
  921. return subtractSmall(value, 1, this.sign);
  922. }
  923. return new BigInteger(addSmall(value, 1), this.sign);
  924. };
  925. SmallInteger.prototype.next = function () {
  926. var value = this.value;
  927. if (value + 1 < MAX_INT) return new SmallInteger(value + 1);
  928. return new BigInteger(MAX_INT_ARR, false);
  929. };
  930. NativeBigInt.prototype.next = function () {
  931. return new NativeBigInt(this.value + BigInt(1));
  932. }
  933. BigInteger.prototype.prev = function () {
  934. var value = this.value;
  935. if (this.sign) {
  936. return new BigInteger(addSmall(value, 1), true);
  937. }
  938. return subtractSmall(value, 1, this.sign);
  939. };
  940. SmallInteger.prototype.prev = function () {
  941. var value = this.value;
  942. if (value - 1 > -MAX_INT) return new SmallInteger(value - 1);
  943. return new BigInteger(MAX_INT_ARR, true);
  944. };
  945. NativeBigInt.prototype.prev = function () {
  946. return new NativeBigInt(this.value - BigInt(1));
  947. }
  948. var powersOfTwo = [1];
  949. while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]);
  950. var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1];
  951. function shift_isSmall(n) {
  952. return Math.abs(n) <= BASE;
  953. }
  954. BigInteger.prototype.shiftLeft = function (v) {
  955. var n = parseValue(v).toJSNumber();
  956. if (!shift_isSmall(n)) {
  957. throw new Error(String(n) + " is too large for shifting.");
  958. }
  959. if (n < 0) return this.shiftRight(-n);
  960. var result = this;
  961. if (result.isZero()) return result;
  962. while (n >= powers2Length) {
  963. result = result.multiply(highestPower2);
  964. n -= powers2Length - 1;
  965. }
  966. return result.multiply(powersOfTwo[n]);
  967. };
  968. NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft;
  969. BigInteger.prototype.shiftRight = function (v) {
  970. var remQuo;
  971. var n = parseValue(v).toJSNumber();
  972. if (!shift_isSmall(n)) {
  973. throw new Error(String(n) + " is too large for shifting.");
  974. }
  975. if (n < 0) return this.shiftLeft(-n);
  976. var result = this;
  977. while (n >= powers2Length) {
  978. if (result.isZero() || (result.isNegative() && result.isUnit())) return result;
  979. remQuo = divModAny(result, highestPower2);
  980. result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
  981. n -= powers2Length - 1;
  982. }
  983. remQuo = divModAny(result, powersOfTwo[n]);
  984. return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
  985. };
  986. NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight;
  987. function bitwise(x, y, fn) {
  988. y = parseValue(y);
  989. var xSign = x.isNegative(), ySign = y.isNegative();
  990. var xRem = xSign ? x.not() : x,
  991. yRem = ySign ? y.not() : y;
  992. var xDigit = 0, yDigit = 0;
  993. var xDivMod = null, yDivMod = null;
  994. var result = [];
  995. while (!xRem.isZero() || !yRem.isZero()) {
  996. xDivMod = divModAny(xRem, highestPower2);
  997. xDigit = xDivMod[1].toJSNumber();
  998. if (xSign) {
  999. xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers
  1000. }
  1001. yDivMod = divModAny(yRem, highestPower2);
  1002. yDigit = yDivMod[1].toJSNumber();
  1003. if (ySign) {
  1004. yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers
  1005. }
  1006. xRem = xDivMod[0];
  1007. yRem = yDivMod[0];
  1008. result.push(fn(xDigit, yDigit));
  1009. }
  1010. var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0);
  1011. for (var i = result.length - 1; i >= 0; i -= 1) {
  1012. sum = sum.multiply(highestPower2).add(bigInt(result[i]));
  1013. }
  1014. return sum;
  1015. }
  1016. BigInteger.prototype.not = function () {
  1017. return this.negate().prev();
  1018. };
  1019. NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not;
  1020. BigInteger.prototype.and = function (n) {
  1021. return bitwise(this, n, function (a, b) { return a & b; });
  1022. };
  1023. NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and;
  1024. BigInteger.prototype.or = function (n) {
  1025. return bitwise(this, n, function (a, b) { return a | b; });
  1026. };
  1027. NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or;
  1028. BigInteger.prototype.xor = function (n) {
  1029. return bitwise(this, n, function (a, b) { return a ^ b; });
  1030. };
  1031. NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor;
  1032. var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I;
  1033. function roughLOB(n) { // get lowestOneBit (rough)
  1034. // SmallInteger: return Min(lowestOneBit(n), 1 << 30)
  1035. // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7]
  1036. var v = n.value,
  1037. x = typeof v === "number" ? v | LOBMASK_I :
  1038. typeof v === "bigint" ? v | BigInt(LOBMASK_I) :
  1039. v[0] + v[1] * BASE | LOBMASK_BI;
  1040. return x & -x;
  1041. }
  1042. function integerLogarithm(value, base) {
  1043. if (base.compareTo(value) <= 0) {
  1044. var tmp = integerLogarithm(value, base.square(base));
  1045. var p = tmp.p;
  1046. var e = tmp.e;
  1047. var t = p.multiply(base);
  1048. return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 };
  1049. }
  1050. return { p: bigInt(1), e: 0 };
  1051. }
  1052. BigInteger.prototype.bitLength = function () {
  1053. var n = this;
  1054. if (n.compareTo(bigInt(0)) < 0) {
  1055. n = n.negate().subtract(bigInt(1));
  1056. }
  1057. if (n.compareTo(bigInt(0)) === 0) {
  1058. return bigInt(0);
  1059. }
  1060. return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1));
  1061. }
  1062. NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength;
  1063. function max(a, b) {
  1064. a = parseValue(a);
  1065. b = parseValue(b);
  1066. return a.greater(b) ? a : b;
  1067. }
  1068. function min(a, b) {
  1069. a = parseValue(a);
  1070. b = parseValue(b);
  1071. return a.lesser(b) ? a : b;
  1072. }
  1073. function gcd(a, b) {
  1074. a = parseValue(a).abs();
  1075. b = parseValue(b).abs();
  1076. if (a.equals(b)) return a;
  1077. if (a.isZero()) return b;
  1078. if (b.isZero()) return a;
  1079. var c = Integer[1], d, t;
  1080. while (a.isEven() && b.isEven()) {
  1081. d = min(roughLOB(a), roughLOB(b));
  1082. a = a.divide(d);
  1083. b = b.divide(d);
  1084. c = c.multiply(d);
  1085. }
  1086. while (a.isEven()) {
  1087. a = a.divide(roughLOB(a));
  1088. }
  1089. do {
  1090. while (b.isEven()) {
  1091. b = b.divide(roughLOB(b));
  1092. }
  1093. if (a.greater(b)) {
  1094. t = b; b = a; a = t;
  1095. }
  1096. b = b.subtract(a);
  1097. } while (!b.isZero());
  1098. return c.isUnit() ? a : a.multiply(c);
  1099. }
  1100. function lcm(a, b) {
  1101. a = parseValue(a).abs();
  1102. b = parseValue(b).abs();
  1103. return a.divide(gcd(a, b)).multiply(b);
  1104. }
  1105. function randBetween(a, b) {
  1106. a = parseValue(a);
  1107. b = parseValue(b);
  1108. var low = min(a, b), high = max(a, b);
  1109. var range = high.subtract(low).add(1);
  1110. if (range.isSmall) return low.add(Math.floor(Math.random() * range));
  1111. var digits = toBase(range, BASE).value;
  1112. var result = [], restricted = true;
  1113. for (var i = 0; i < digits.length; i++) {
  1114. var top = restricted ? digits[i] : BASE;
  1115. var digit = truncate(Math.random() * top);
  1116. result.push(digit);
  1117. if (digit < top) restricted = false;
  1118. }
  1119. return low.add(Integer.fromArray(result, BASE, false));
  1120. }
  1121. var parseBase = function (text, base, alphabet, caseSensitive) {
  1122. alphabet = alphabet || DEFAULT_ALPHABET;
  1123. text = String(text);
  1124. if (!caseSensitive) {
  1125. text = text.toLowerCase();
  1126. alphabet = alphabet.toLowerCase();
  1127. }
  1128. var length = text.length;
  1129. var i;
  1130. var absBase = Math.abs(base);
  1131. var alphabetValues = {};
  1132. for (i = 0; i < alphabet.length; i++) {
  1133. alphabetValues[alphabet[i]] = i;
  1134. }
  1135. for (i = 0; i < length; i++) {
  1136. var c = text[i];
  1137. if (c === "-") continue;
  1138. if (c in alphabetValues) {
  1139. if (alphabetValues[c] >= absBase) {
  1140. if (c === "1" && absBase === 1) continue;
  1141. throw new Error(c + " is not a valid digit in base " + base + ".");
  1142. }
  1143. }
  1144. }
  1145. base = parseValue(base);
  1146. var digits = [];
  1147. var isNegative = text[0] === "-";
  1148. for (i = isNegative ? 1 : 0; i < text.length; i++) {
  1149. var c = text[i];
  1150. if (c in alphabetValues) digits.push(parseValue(alphabetValues[c]));
  1151. else if (c === "<") {
  1152. var start = i;
  1153. do { i++; } while (text[i] !== ">" && i < text.length);
  1154. digits.push(parseValue(text.slice(start + 1, i)));
  1155. }
  1156. else throw new Error(c + " is not a valid character");
  1157. }
  1158. return parseBaseFromArray(digits, base, isNegative);
  1159. };
  1160. function parseBaseFromArray(digits, base, isNegative) {
  1161. var val = Integer[0], pow = Integer[1], i;
  1162. for (i = digits.length - 1; i >= 0; i--) {
  1163. val = val.add(digits[i].times(pow));
  1164. pow = pow.times(base);
  1165. }
  1166. return isNegative ? val.negate() : val;
  1167. }
  1168. function stringify(digit, alphabet) {
  1169. alphabet = alphabet || DEFAULT_ALPHABET;
  1170. if (digit < alphabet.length) {
  1171. return alphabet[digit];
  1172. }
  1173. return "<" + digit + ">";
  1174. }
  1175. function toBase(n, base) {
  1176. base = bigInt(base);
  1177. if (base.isZero()) {
  1178. if (n.isZero()) return { value: [0], isNegative: false };
  1179. throw new Error("Cannot convert nonzero numbers to base 0.");
  1180. }
  1181. if (base.equals(-1)) {
  1182. if (n.isZero()) return { value: [0], isNegative: false };
  1183. if (n.isNegative())
  1184. return {
  1185. value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber()))
  1186. .map(Array.prototype.valueOf, [1, 0])
  1187. ),
  1188. isNegative: false
  1189. };
  1190. var arr = Array.apply(null, Array(n.toJSNumber() - 1))
  1191. .map(Array.prototype.valueOf, [0, 1]);
  1192. arr.unshift([1]);
  1193. return {
  1194. value: [].concat.apply([], arr),
  1195. isNegative: false
  1196. };
  1197. }
  1198. var neg = false;
  1199. if (n.isNegative() && base.isPositive()) {
  1200. neg = true;
  1201. n = n.abs();
  1202. }
  1203. if (base.isUnit()) {
  1204. if (n.isZero()) return { value: [0], isNegative: false };
  1205. return {
  1206. value: Array.apply(null, Array(n.toJSNumber()))
  1207. .map(Number.prototype.valueOf, 1),
  1208. isNegative: neg
  1209. };
  1210. }
  1211. var out = [];
  1212. var left = n, divmod;
  1213. while (left.isNegative() || left.compareAbs(base) >= 0) {
  1214. divmod = left.divmod(base);
  1215. left = divmod.quotient;
  1216. var digit = divmod.remainder;
  1217. if (digit.isNegative()) {
  1218. digit = base.minus(digit).abs();
  1219. left = left.next();
  1220. }
  1221. out.push(digit.toJSNumber());
  1222. }
  1223. out.push(left.toJSNumber());
  1224. return { value: out.reverse(), isNegative: neg };
  1225. }
  1226. function toBaseString(n, base, alphabet) {
  1227. var arr = toBase(n, base);
  1228. return (arr.isNegative ? "-" : "") + arr.value.map(function (x) {
  1229. return stringify(x, alphabet);
  1230. }).join('');
  1231. }
  1232. BigInteger.prototype.toArray = function (radix) {
  1233. return toBase(this, radix);
  1234. };
  1235. SmallInteger.prototype.toArray = function (radix) {
  1236. return toBase(this, radix);
  1237. };
  1238. NativeBigInt.prototype.toArray = function (radix) {
  1239. return toBase(this, radix);
  1240. };
  1241. BigInteger.prototype.toString = function (radix, alphabet) {
  1242. if (radix === undefined) radix = 10;
  1243. if (radix !== 10) return toBaseString(this, radix, alphabet);
  1244. var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
  1245. while (--l >= 0) {
  1246. digit = String(v[l]);
  1247. str += zeros.slice(digit.length) + digit;
  1248. }
  1249. var sign = this.sign ? "-" : "";
  1250. return sign + str;
  1251. };
  1252. SmallInteger.prototype.toString = function (radix, alphabet) {
  1253. if (radix === undefined) radix = 10;
  1254. if (radix != 10) return toBaseString(this, radix, alphabet);
  1255. return String(this.value);
  1256. };
  1257. NativeBigInt.prototype.toString = SmallInteger.prototype.toString;
  1258. NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }
  1259. BigInteger.prototype.valueOf = function () {
  1260. return parseInt(this.toString(), 10);
  1261. };
  1262. BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
  1263. SmallInteger.prototype.valueOf = function () {
  1264. return this.value;
  1265. };
  1266. SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf;
  1267. NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () {
  1268. return parseInt(this.toString(), 10);
  1269. }
  1270. function parseStringValue(v) {
  1271. if (isPrecise(+v)) {
  1272. var x = +v;
  1273. if (x === truncate(x))
  1274. return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x);
  1275. throw new Error("Invalid integer: " + v);
  1276. }
  1277. var sign = v[0] === "-";
  1278. if (sign) v = v.slice(1);
  1279. var split = v.split(/e/i);
  1280. if (split.length > 2) throw new Error("Invalid integer: " + split.join("e"));
  1281. if (split.length === 2) {
  1282. var exp = split[1];
  1283. if (exp[0] === "+") exp = exp.slice(1);
  1284. exp = +exp;
  1285. if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent.");
  1286. var text = split[0];
  1287. var decimalPlace = text.indexOf(".");
  1288. if (decimalPlace >= 0) {
  1289. exp -= text.length - decimalPlace - 1;
  1290. text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1);
  1291. }
  1292. if (exp < 0) throw new Error("Cannot include negative exponent part for integers");
  1293. text += (new Array(exp + 1)).join("0");
  1294. v = text;
  1295. }
  1296. var isValid = /^([0-9][0-9]*)$/.test(v);
  1297. if (!isValid) throw new Error("Invalid integer: " + v);
  1298. if (supportsNativeBigInt) {
  1299. return new NativeBigInt(BigInt(sign ? "-" + v : v));
  1300. }
  1301. var r = [], max = v.length, l = LOG_BASE, min = max - l;
  1302. while (max > 0) {
  1303. r.push(+v.slice(min, max));
  1304. min -= l;
  1305. if (min < 0) min = 0;
  1306. max -= l;
  1307. }
  1308. trim(r);
  1309. return new BigInteger(r, sign);
  1310. }
  1311. function parseNumberValue(v) {
  1312. if (supportsNativeBigInt) {
  1313. return new NativeBigInt(BigInt(v));
  1314. }
  1315. if (isPrecise(v)) {
  1316. if (v !== truncate(v)) throw new Error(v + " is not an integer.");
  1317. return new SmallInteger(v);
  1318. }
  1319. return parseStringValue(v.toString());
  1320. }
  1321. function parseValue(v) {
  1322. if (typeof v === "number") {
  1323. return parseNumberValue(v);
  1324. }
  1325. if (typeof v === "string") {
  1326. return parseStringValue(v);
  1327. }
  1328. if (typeof v === "bigint") {
  1329. return new NativeBigInt(v);
  1330. }
  1331. return v;
  1332. }
  1333. // Pre-define numbers in range [-999,999]
  1334. for (var i = 0; i < 1000; i++) {
  1335. Integer[i] = parseValue(i);
  1336. if (i > 0) Integer[-i] = parseValue(-i);
  1337. }
  1338. // Backwards compatibility
  1339. Integer.one = Integer[1];
  1340. Integer.zero = Integer[0];
  1341. Integer.minusOne = Integer[-1];
  1342. Integer.max = max;
  1343. Integer.min = min;
  1344. Integer.gcd = gcd;
  1345. Integer.lcm = lcm;
  1346. Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; };
  1347. Integer.randBetween = randBetween;
  1348. Integer.fromArray = function (digits, base, isNegative) {
  1349. return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
  1350. };
  1351. return Integer;
  1352. })();
  1353. // Node.js check
  1354. if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
  1355. module.exports = bigInt;
  1356. }
  1357. //amd check
  1358. if (typeof define === "function" && define.amd) {
  1359. define("big-integer", [], function () {
  1360. return bigInt;
  1361. });
  1362. }
  1363. },{}],4:[function(require,module,exports){
  1364. (function (process){
  1365. /*
  1366. Copyright 2019 0KIMS association.
  1367. This file is part of websnark (Web Assembly zkSnark Prover).
  1368. websnark is a free software: you can redistribute it and/or modify it
  1369. under the terms of the GNU General Public License as published by
  1370. the Free Software Foundation, either version 3 of the License, or
  1371. (at your option) any later version.
  1372. websnark is distributed in the hope that it will be useful, but WITHOUT
  1373. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  1374. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  1375. License for more details.
  1376. You should have received a copy of the GNU General Public License
  1377. along with websnark. If not, see <https://www.gnu.org/licenses/>.
  1378. */
  1379. /* globals WebAssembly, Blob, Worker, navigator, Promise, window */
  1380. const bigInt = require("big-integer");
  1381. const groth16_wasm = require("../build/groth16_wasm.js");
  1382. const assert = require("assert");
  1383. const inBrowser = (typeof window !== "undefined");
  1384. let NodeWorker;
  1385. let NodeCrypto;
  1386. if (!inBrowser) {
  1387. NodeWorker = require("worker_threads").Worker;
  1388. NodeCrypto = require("crypto");
  1389. }
  1390. class Deferred {
  1391. constructor() {
  1392. this.promise = new Promise((resolve, reject)=> {
  1393. this.reject = reject;
  1394. this.resolve = resolve;
  1395. });
  1396. }
  1397. }
  1398. /*
  1399. function delay(ms) {
  1400. return new Promise(resolve => setTimeout(resolve, ms));
  1401. }
  1402. */
  1403. function thread(self) {
  1404. let instance;
  1405. let memory;
  1406. let i32;
  1407. async function init(data) {
  1408. const code = new Uint8Array(data.code);
  1409. const wasmModule = await WebAssembly.compile(code);
  1410. memory = new WebAssembly.Memory({initial:data.init});
  1411. i32 = new Uint32Array(memory.buffer);
  1412. instance = await WebAssembly.instantiate(wasmModule, {
  1413. env: {
  1414. "memory": memory
  1415. }
  1416. });
  1417. }
  1418. function alloc(length) {
  1419. while (i32[0] & 3) i32[0]++; // Return always aligned pointers
  1420. const res = i32[0];
  1421. i32[0] += length;
  1422. return res;
  1423. }
  1424. function putBin(b) {
  1425. const p = alloc(b.byteLength);
  1426. const s32 = new Uint32Array(b);
  1427. i32.set(s32, p/4);
  1428. return p;
  1429. }
  1430. function getBin(p, l) {
  1431. return memory.buffer.slice(p, p+l);
  1432. }
  1433. self.onmessage = function(e) {
  1434. let data;
  1435. if (e.data) {
  1436. data = e.data;
  1437. } else {
  1438. data = e;
  1439. }
  1440. if (data.command == "INIT") {
  1441. init(data).then(function() {
  1442. self.postMessage(data.result);
  1443. });
  1444. } else if (data.command == "G1_MULTIEXP") {
  1445. const oldAlloc = i32[0];
  1446. const pScalars = putBin(data.scalars);
  1447. const pPoints = putBin(data.points);
  1448. const pRes = alloc(96);
  1449. instance.exports.g1_zero(pRes);
  1450. instance.exports.g1_multiexp(pScalars, pPoints, data.n, 5, pRes);
  1451. data.result = getBin(pRes, 96);
  1452. i32[0] = oldAlloc;
  1453. self.postMessage(data.result, [data.result]);
  1454. } else if (data.command == "G2_MULTIEXP") {
  1455. const oldAlloc = i32[0];
  1456. const pScalars = putBin(data.scalars);
  1457. const pPoints = putBin(data.points);
  1458. const pRes = alloc(192);
  1459. instance.exports.g2_zero(pRes);
  1460. instance.exports.g2_multiexp(pScalars, pPoints, data.n, 5, pRes);
  1461. data.result = getBin(pRes, 192);
  1462. i32[0] = oldAlloc;
  1463. self.postMessage(data.result, [data.result]);
  1464. } else if (data.command == "CALC_H") {
  1465. const oldAlloc = i32[0];
  1466. const pSignals = putBin(data.signals);
  1467. const pPolsA = putBin(data.polsA);
  1468. const pPolsB = putBin(data.polsB);
  1469. const nSignals = data.nSignals;
  1470. const domainSize = data.domainSize;
  1471. const pSignalsM = alloc(nSignals*32);
  1472. const pPolA = alloc(domainSize*32);
  1473. const pPolB = alloc(domainSize*32);
  1474. const pPolA2 = alloc(domainSize*32*2);
  1475. const pPolB2 = alloc(domainSize*32*2);
  1476. instance.exports.fft_toMontgomeryN(pSignals, pSignalsM, nSignals);
  1477. instance.exports.pol_zero(pPolA, domainSize);
  1478. instance.exports.pol_zero(pPolB, domainSize);
  1479. instance.exports.pol_constructLC(pPolsA, pSignalsM, nSignals, pPolA);
  1480. instance.exports.pol_constructLC(pPolsB, pSignalsM, nSignals, pPolB);
  1481. instance.exports.fft_copyNInterleaved(pPolA, pPolA2, domainSize);
  1482. instance.exports.fft_copyNInterleaved(pPolB, pPolB2, domainSize);
  1483. instance.exports.fft_ifft(pPolA, domainSize, 0);
  1484. instance.exports.fft_ifft(pPolB, domainSize, 0);
  1485. instance.exports.fft_fft(pPolA, domainSize, 1);
  1486. instance.exports.fft_fft(pPolB, domainSize, 1);
  1487. instance.exports.fft_copyNInterleaved(pPolA, pPolA2+32, domainSize);
  1488. instance.exports.fft_copyNInterleaved(pPolB, pPolB2+32, domainSize);
  1489. instance.exports.fft_mulN(pPolA2, pPolB2, domainSize*2, pPolA2);
  1490. instance.exports.fft_ifft(pPolA2, domainSize*2, 0);
  1491. instance.exports.fft_fromMontgomeryN(pPolA2+domainSize*32, pPolA2+domainSize*32, nSignals);
  1492. data.result = getBin(pPolA2+domainSize*32, domainSize*32);
  1493. i32[0] = oldAlloc;
  1494. self.postMessage(data.result, [data.result]);
  1495. } else if (data.command == "TERMINATE") {
  1496. process.exit();
  1497. }
  1498. };
  1499. }
  1500. async function build() {
  1501. const groth16 = new Groth16();
  1502. groth16.q = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583");
  1503. groth16.r = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
  1504. groth16.n64 = Math.floor((groth16.q.minus(1).bitLength() - 1)/64) +1;
  1505. groth16.n32 = groth16.n64*2;
  1506. groth16.n8 = groth16.n64*8;
  1507. groth16.memory = new WebAssembly.Memory({initial:1000});
  1508. groth16.i32 = new Uint32Array(groth16.memory.buffer);
  1509. const wasmModule = await WebAssembly.compile(groth16_wasm.code);
  1510. groth16.instance = await WebAssembly.instantiate(wasmModule, {
  1511. env: {
  1512. "memory": groth16.memory
  1513. }
  1514. });
  1515. groth16.pq = groth16_wasm.pq;
  1516. groth16.pr = groth16_wasm.pr;
  1517. groth16.pr0 = groth16.alloc(192);
  1518. groth16.pr1 = groth16.alloc(192);
  1519. groth16.workers = [];
  1520. groth16.pendingDeferreds = [];
  1521. groth16.working = [];
  1522. let concurrency;
  1523. if ((typeof(navigator) === "object") && navigator.hardwareConcurrency) {
  1524. concurrency = navigator.hardwareConcurrency;
  1525. } else {
  1526. concurrency = 8;
  1527. }
  1528. function getOnMsg(i) {
  1529. return function(e) {
  1530. let data;
  1531. if ((e)&&(e.data)) {
  1532. data = e.data;
  1533. } else {
  1534. data = e;
  1535. }
  1536. groth16.working[i]=false;
  1537. groth16.pendingDeferreds[i].resolve(data);
  1538. groth16.processWorks();
  1539. };
  1540. }
  1541. for (let i = 0; i<concurrency; i++) {
  1542. if (inBrowser) {
  1543. const blob = new Blob(["(", thread.toString(), ")(self);"], { type: "text/javascript" });
  1544. const url = URL.createObjectURL(blob);
  1545. groth16.workers[i] = new Worker(url);
  1546. groth16.workers[i].onmessage = getOnMsg(i);
  1547. } else {
  1548. groth16.workers[i] = new NodeWorker("(" + thread.toString()+ ")(require('worker_threads').parentPort);", {eval: true});
  1549. groth16.workers[i].on("message", getOnMsg(i));
  1550. }
  1551. groth16.working[i]=false;
  1552. }
  1553. const initPromises = [];
  1554. for (let i=0; i<groth16.workers.length;i++) {
  1555. const copyCode = groth16_wasm.code.buffer.slice(0);
  1556. initPromises.push(groth16.postAction(i, {
  1557. command: "INIT",
  1558. init: 1000,
  1559. code: copyCode
  1560. }, [copyCode]));
  1561. }
  1562. await Promise.all(initPromises);
  1563. return groth16;
  1564. }
  1565. class Groth16 {
  1566. constructor() {
  1567. this.actionQueue = [];
  1568. }
  1569. postAction(workerId, e, transfers, _deferred) {
  1570. assert(this.working[workerId] == false);
  1571. this.working[workerId] = true;
  1572. this.pendingDeferreds[workerId] = _deferred ? _deferred : new Deferred();
  1573. this.workers[workerId].postMessage(e, transfers);
  1574. return this.pendingDeferreds[workerId].promise;
  1575. }
  1576. processWorks() {
  1577. for (let i=0; (i<this.workers.length)&&(this.actionQueue.length > 0); i++) {
  1578. if (this.working[i] == false) {
  1579. const work = this.actionQueue.shift();
  1580. this.postAction(i, work.data, work.transfers, work.deferred);
  1581. }
  1582. }
  1583. }
  1584. queueAction(actionData, transfers) {
  1585. const d = new Deferred();
  1586. this.actionQueue.push({
  1587. data: actionData,
  1588. transfers: transfers,
  1589. deferred: d
  1590. });
  1591. this.processWorks();
  1592. return d.promise;
  1593. }
  1594. alloc(length) {
  1595. while (this.i32[0] & 3) this.i32[0]++; // Return always aligned pointers
  1596. const res = this.i32[0];
  1597. this.i32[0] += length;
  1598. return res;
  1599. }
  1600. putBin(p, b) {
  1601. const s32 = new Uint32Array(b);
  1602. this.i32.set(s32, p/4);
  1603. }
  1604. getBin(p, l) {
  1605. return this.memory.buffer.slice(p, p+l);
  1606. }
  1607. bin2int(b) {
  1608. const i32 = new Uint32Array(b);
  1609. let acc = bigInt(i32[7]);
  1610. for (let i=6; i>=0; i--) {
  1611. acc = acc.shiftLeft(32);
  1612. acc = acc.add(i32[i]);
  1613. }
  1614. return acc.toString();
  1615. }
  1616. bin2g1(b) {
  1617. return [
  1618. this.bin2int(b.slice(0,32)),
  1619. this.bin2int(b.slice(32,64)),
  1620. this.bin2int(b.slice(64,96)),
  1621. ];
  1622. }
  1623. bin2g2(b) {
  1624. return [
  1625. [
  1626. this.bin2int(b.slice(0,32)),
  1627. this.bin2int(b.slice(32,64))
  1628. ],
  1629. [
  1630. this.bin2int(b.slice(64,96)),
  1631. this.bin2int(b.slice(96,128))
  1632. ],
  1633. [
  1634. this.bin2int(b.slice(128,160)),
  1635. this.bin2int(b.slice(160,192))
  1636. ],
  1637. ];
  1638. }
  1639. async g1_multiexp(scalars, points) {
  1640. const nPoints = scalars.byteLength /32;
  1641. const nPointsPerThread = Math.floor(nPoints / this.workers.length);
  1642. const opPromises = [];
  1643. for (let i=0; i<this.workers.length; i++) {
  1644. const th_nPoints =
  1645. i < this.workers.length -1 ?
  1646. nPointsPerThread :
  1647. nPoints - (nPointsPerThread * (this.workers.length -1));
  1648. const scalars_th = scalars.slice(i*nPointsPerThread*32, i*nPointsPerThread*32 + th_nPoints*32);
  1649. const points_th = points.slice(i*nPointsPerThread*64, i*nPointsPerThread*64 + th_nPoints*64);
  1650. opPromises.push(
  1651. this.queueAction({
  1652. command: "G1_MULTIEXP",
  1653. scalars: scalars_th,
  1654. points: points_th,
  1655. n: th_nPoints
  1656. }, [scalars_th, points_th])
  1657. );
  1658. }
  1659. const results = await Promise.all(opPromises);
  1660. this.instance.exports.g1_zero(this.pr0);
  1661. for (let i=0; i<results.length; i++) {
  1662. this.putBin(this.pr1, results[i]);
  1663. this.instance.exports.g1_add(this.pr0, this.pr1, this.pr0);
  1664. }
  1665. return this.getBin(this.pr0, 96);
  1666. }
  1667. async g2_multiexp(scalars, points) {
  1668. const nPoints = scalars.byteLength /32;
  1669. const nPointsPerThread = Math.floor(nPoints / this.workers.length);
  1670. const opPromises = [];
  1671. for (let i=0; i<this.workers.length; i++) {
  1672. const th_nPoints =
  1673. i < this.workers.length -1 ?
  1674. nPointsPerThread :
  1675. nPoints - (nPointsPerThread * (this.workers.length -1));
  1676. const scalars_th = scalars.slice(i*nPointsPerThread*32, i*nPointsPerThread*32 + th_nPoints*32);
  1677. const points_th = points.slice(i*nPointsPerThread*128, i*nPointsPerThread*128 + th_nPoints*128);
  1678. opPromises.push(
  1679. this.queueAction({
  1680. command: "G2_MULTIEXP",
  1681. scalars: scalars_th,
  1682. points: points_th,
  1683. n: th_nPoints
  1684. }, [scalars_th, points_th])
  1685. );
  1686. }
  1687. const results = await Promise.all(opPromises);
  1688. this.instance.exports.g2_zero(this.pr0);
  1689. for (let i=0; i<results.length; i++) {
  1690. this.putBin(this.pr1, results[i]);
  1691. this.instance.exports.g2_add(this.pr0, this.pr1, this.pr0);
  1692. }
  1693. return this.getBin(this.pr0, 192);
  1694. }
  1695. g1_affine(p) {
  1696. this.putBin(this.pr0, p);
  1697. this.instance.exports.g1_affine(this.pr0, this.pr0);
  1698. return this.getBin(this.pr0, 96);
  1699. }
  1700. g2_affine(p) {
  1701. this.putBin(this.pr0, p);
  1702. this.instance.exports.g2_affine(this.pr0, this.pr0);
  1703. return this.getBin(this.pr0, 192);
  1704. }
  1705. g1_fromMontgomery(p) {
  1706. this.putBin(this.pr0, p);
  1707. this.instance.exports.g1_fromMontgomery(this.pr0, this.pr0);
  1708. return this.getBin(this.pr0, 96);
  1709. }
  1710. g2_fromMontgomery(p) {
  1711. this.putBin(this.pr0, p);
  1712. this.instance.exports.g2_fromMontgomery(this.pr0, this.pr0);
  1713. return this.getBin(this.pr0, 192);
  1714. }
  1715. loadPoint1(b) {
  1716. const p = this.alloc(96);
  1717. this.putBin(p, b);
  1718. this.instance.exports.f1m_one(p+64);
  1719. return p;
  1720. }
  1721. loadPoint2(b) {
  1722. const p = this.alloc(192);
  1723. this.putBin(p, b);
  1724. this.instance.exports.f2m_one(p+128);
  1725. return p;
  1726. }
  1727. terminate() {
  1728. for (let i=0; i<this.workers.length; i++) {
  1729. this.workers[i].postMessage({command: "TERMINATE"});
  1730. }
  1731. }
  1732. async calcH(signals, polsA, polsB, nSignals, domainSize) {
  1733. return this.queueAction({
  1734. command: "CALC_H",
  1735. signals: signals,
  1736. polsA: polsA,
  1737. polsB: polsB,
  1738. nSignals: nSignals,
  1739. domainSize: domainSize
  1740. }, [signals, polsA, polsB]);
  1741. }
  1742. async proof(signals, pkey) {
  1743. const pkey32 = new Uint32Array(pkey);
  1744. const nSignals = pkey32[0];
  1745. const nPublic = pkey32[1];
  1746. const domainSize = pkey32[2];
  1747. const pPolsA = pkey32[3];
  1748. const pPolsB = pkey32[4];
  1749. const pPointsA = pkey32[5];
  1750. const pPointsB1 = pkey32[6];
  1751. const pPointsB2 = pkey32[7];
  1752. const pPointsC = pkey32[8];
  1753. const pHExps = pkey32[9];
  1754. const polsA = pkey.slice(pPolsA, pPolsA + pPolsB);
  1755. const polsB = pkey.slice(pPolsB, pPolsB + pPointsA);
  1756. const pointsA = pkey.slice(pPointsA, pPointsA + nSignals*64);
  1757. const pointsB1 = pkey.slice(pPointsB1, pPointsB1 + nSignals*64);
  1758. const pointsB2 = pkey.slice(pPointsB2, pPointsB2 + nSignals*128);
  1759. const pointsC = pkey.slice(pPointsC, pPointsC + (nSignals-nPublic-1)*64);
  1760. const pointsHExps = pkey.slice(pHExps, pHExps + domainSize*64);
  1761. const alfa1 = pkey.slice(10*4, 10*4 + 64);
  1762. const beta1 = pkey.slice(10*4 + 64, 10*4 + 128);
  1763. const delta1 = pkey.slice(10*4 + 128, 10*4 + 192);
  1764. const beta2 = pkey.slice(10*4 + 192, 10*4 + 320);
  1765. const delta2 = pkey.slice(10*4 + 320, 10*4 + 448);
  1766. const pH = this.calcH(signals.slice(0), polsA, polsB, nSignals, domainSize).then( (h) => {
  1767. return this.g1_multiexp(h, pointsHExps);
  1768. });
  1769. const pA = this.g1_multiexp(signals.slice(0), pointsA);
  1770. const pB1 = this.g1_multiexp(signals.slice(0), pointsB1);
  1771. const pB2 = this.g2_multiexp(signals.slice(0), pointsB2);
  1772. const pC = this.g1_multiexp(signals.slice((nPublic+1)*32), pointsC);
  1773. const res = await Promise.all([pA, pB1, pB2, pC, pH]);
  1774. const pi_a = this.alloc(96);
  1775. const pi_b = this.alloc(192);
  1776. const pi_c = this.alloc(96);
  1777. const pib1 = this.alloc(96);
  1778. this.putBin(pi_a, res[0]);
  1779. this.putBin(pib1, res[1]);
  1780. this.putBin(pi_b, res[2]);
  1781. this.putBin(pi_c, res[3]);
  1782. const pAlfa1 = this.loadPoint1(alfa1);
  1783. const pBeta1 = this.loadPoint1(beta1);
  1784. const pDelta1 = this.loadPoint1(delta1);
  1785. const pBeta2 = this.loadPoint2(beta2);
  1786. const pDelta2 = this.loadPoint2(delta2);
  1787. let rnd = new Uint32Array(8);
  1788. const aux1 = this.alloc(96);
  1789. const aux2 = this.alloc(192);
  1790. const pr = this.alloc(32);
  1791. const ps = this.alloc(32);
  1792. if (inBrowser) {
  1793. window.crypto.getRandomValues(rnd);
  1794. this.putBin(pr, rnd);
  1795. window.crypto.getRandomValues(rnd);
  1796. this.putBin(ps, rnd);
  1797. } else {
  1798. const br = NodeCrypto.randomBytes(32);
  1799. this.putBin(pr, br);
  1800. const bs = NodeCrypto.randomBytes(32);
  1801. this.putBin(ps, bs);
  1802. }
  1803. // pi_a = pi_a + Alfa1 + r*Delta1
  1804. this.instance.exports.g1_add(pAlfa1, pi_a, pi_a);
  1805. this.instance.exports.g1_timesScalar(pDelta1, pr, 32, aux1);
  1806. this.instance.exports.g1_add(aux1, pi_a, pi_a);
  1807. // pi_b = pi_b + Beta2 + s*Delta2
  1808. this.instance.exports.g2_add(pBeta2, pi_b, pi_b);
  1809. this.instance.exports.g2_timesScalar(pDelta2, ps, 32, aux2);
  1810. this.instance.exports.g2_add(aux2, pi_b, pi_b);
  1811. // pib1 = pib1 + Beta1 + s*Delta1
  1812. this.instance.exports.g1_add(pBeta1, pib1, pib1);
  1813. this.instance.exports.g1_timesScalar(pDelta1, ps, 32, aux1);
  1814. this.instance.exports.g1_add(aux1, pib1, pib1);
  1815. // pi_c = pi_c + pH
  1816. this.putBin(aux1, res[4]);
  1817. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1818. // pi_c = pi_c + s*pi_a
  1819. this.instance.exports.g1_timesScalar(pi_a, ps, 32, aux1);
  1820. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1821. // pi_c = pi_c + r*pib1
  1822. this.instance.exports.g1_timesScalar(pib1, pr, 32, aux1);
  1823. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1824. // pi_c = pi_c - r*s*delta1
  1825. const prs = this.alloc(64);
  1826. this.instance.exports.int_mul(pr, ps, prs);
  1827. this.instance.exports.g1_timesScalar(pDelta1, prs, 64, aux1);
  1828. this.instance.exports.g1_neg(aux1, aux1);
  1829. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1830. this.instance.exports.g1_affine(pi_a, pi_a);
  1831. this.instance.exports.g2_affine(pi_b, pi_b);
  1832. this.instance.exports.g1_affine(pi_c, pi_c);
  1833. this.instance.exports.g1_fromMontgomery(pi_a, pi_a);
  1834. this.instance.exports.g2_fromMontgomery(pi_b, pi_b);
  1835. this.instance.exports.g1_fromMontgomery(pi_c, pi_c);
  1836. return {
  1837. pi_a: this.bin2g1(this.getBin(pi_a, 96)),
  1838. pi_b: this.bin2g2(this.getBin(pi_b, 192)),
  1839. pi_c: this.bin2g1(this.getBin(pi_c, 96)),
  1840. };
  1841. }
  1842. }
  1843. module.exports = build;
  1844. }).call(this,require('_process'))
  1845. },{"../build/groth16_wasm.js":1,"_process":12,"assert":5,"big-integer":3,"crypto":undefined,"worker_threads":undefined}],5:[function(require,module,exports){
  1846. (function (global){
  1847. 'use strict';
  1848. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  1849. // original notice:
  1850. /*!
  1851. * The buffer module from node.js, for the browser.
  1852. *
  1853. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  1854. * @license MIT
  1855. */
  1856. function compare(a, b) {
  1857. if (a === b) {
  1858. return 0;
  1859. }
  1860. var x = a.length;
  1861. var y = b.length;
  1862. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  1863. if (a[i] !== b[i]) {
  1864. x = a[i];
  1865. y = b[i];
  1866. break;
  1867. }
  1868. }
  1869. if (x < y) {
  1870. return -1;
  1871. }
  1872. if (y < x) {
  1873. return 1;
  1874. }
  1875. return 0;
  1876. }
  1877. function isBuffer(b) {
  1878. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  1879. return global.Buffer.isBuffer(b);
  1880. }
  1881. return !!(b != null && b._isBuffer);
  1882. }
  1883. // based on node assert, original notice:
  1884. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  1885. //
  1886. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  1887. //
  1888. // Originally from narwhal.js (http://narwhaljs.org)
  1889. // Copyright (c) 2009 Thomas Robinson <280north.com>
  1890. //
  1891. // Permission is hereby granted, free of charge, to any person obtaining a copy
  1892. // of this software and associated documentation files (the 'Software'), to
  1893. // deal in the Software without restriction, including without limitation the
  1894. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  1895. // sell copies of the Software, and to permit persons to whom the Software is
  1896. // furnished to do so, subject to the following conditions:
  1897. //
  1898. // The above copyright notice and this permission notice shall be included in
  1899. // all copies or substantial portions of the Software.
  1900. //
  1901. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1902. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1903. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1904. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  1905. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  1906. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  1907. var util = require('util/');
  1908. var hasOwn = Object.prototype.hasOwnProperty;
  1909. var pSlice = Array.prototype.slice;
  1910. var functionsHaveNames = (function () {
  1911. return function foo() {}.name === 'foo';
  1912. }());
  1913. function pToString (obj) {
  1914. return Object.prototype.toString.call(obj);
  1915. }
  1916. function isView(arrbuf) {
  1917. if (isBuffer(arrbuf)) {
  1918. return false;
  1919. }
  1920. if (typeof global.ArrayBuffer !== 'function') {
  1921. return false;
  1922. }
  1923. if (typeof ArrayBuffer.isView === 'function') {
  1924. return ArrayBuffer.isView(arrbuf);
  1925. }
  1926. if (!arrbuf) {
  1927. return false;
  1928. }
  1929. if (arrbuf instanceof DataView) {
  1930. return true;
  1931. }
  1932. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  1933. return true;
  1934. }
  1935. return false;
  1936. }
  1937. // 1. The assert module provides functions that throw
  1938. // AssertionError's when particular conditions are not met. The
  1939. // assert module must conform to the following interface.
  1940. var assert = module.exports = ok;
  1941. // 2. The AssertionError is defined in assert.
  1942. // new assert.AssertionError({ message: message,
  1943. // actual: actual,
  1944. // expected: expected })
  1945. var regex = /\s*function\s+([^\(\s]*)\s*/;
  1946. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  1947. function getName(func) {
  1948. if (!util.isFunction(func)) {
  1949. return;
  1950. }
  1951. if (functionsHaveNames) {
  1952. return func.name;
  1953. }
  1954. var str = func.toString();
  1955. var match = str.match(regex);
  1956. return match && match[1];
  1957. }
  1958. assert.AssertionError = function AssertionError(options) {
  1959. this.name = 'AssertionError';
  1960. this.actual = options.actual;
  1961. this.expected = options.expected;
  1962. this.operator = options.operator;
  1963. if (options.message) {
  1964. this.message = options.message;
  1965. this.generatedMessage = false;
  1966. } else {
  1967. this.message = getMessage(this);
  1968. this.generatedMessage = true;
  1969. }
  1970. var stackStartFunction = options.stackStartFunction || fail;
  1971. if (Error.captureStackTrace) {
  1972. Error.captureStackTrace(this, stackStartFunction);
  1973. } else {
  1974. // non v8 browsers so we can have a stacktrace
  1975. var err = new Error();
  1976. if (err.stack) {
  1977. var out = err.stack;
  1978. // try to strip useless frames
  1979. var fn_name = getName(stackStartFunction);
  1980. var idx = out.indexOf('\n' + fn_name);
  1981. if (idx >= 0) {
  1982. // once we have located the function frame
  1983. // we need to strip out everything before it (and its line)
  1984. var next_line = out.indexOf('\n', idx + 1);
  1985. out = out.substring(next_line + 1);
  1986. }
  1987. this.stack = out;
  1988. }
  1989. }
  1990. };
  1991. // assert.AssertionError instanceof Error
  1992. util.inherits(assert.AssertionError, Error);
  1993. function truncate(s, n) {
  1994. if (typeof s === 'string') {
  1995. return s.length < n ? s : s.slice(0, n);
  1996. } else {
  1997. return s;
  1998. }
  1999. }
  2000. function inspect(something) {
  2001. if (functionsHaveNames || !util.isFunction(something)) {
  2002. return util.inspect(something);
  2003. }
  2004. var rawname = getName(something);
  2005. var name = rawname ? ': ' + rawname : '';
  2006. return '[Function' + name + ']';
  2007. }
  2008. function getMessage(self) {
  2009. return truncate(inspect(self.actual), 128) + ' ' +
  2010. self.operator + ' ' +
  2011. truncate(inspect(self.expected), 128);
  2012. }
  2013. // At present only the three keys mentioned above are used and
  2014. // understood by the spec. Implementations or sub modules can pass
  2015. // other keys to the AssertionError's constructor - they will be
  2016. // ignored.
  2017. // 3. All of the following functions must throw an AssertionError
  2018. // when a corresponding condition is not met, with a message that
  2019. // may be undefined if not provided. All assertion methods provide
  2020. // both the actual and expected values to the assertion error for
  2021. // display purposes.
  2022. function fail(actual, expected, message, operator, stackStartFunction) {
  2023. throw new assert.AssertionError({
  2024. message: message,
  2025. actual: actual,
  2026. expected: expected,
  2027. operator: operator,
  2028. stackStartFunction: stackStartFunction
  2029. });
  2030. }
  2031. // EXTENSION! allows for well behaved errors defined elsewhere.
  2032. assert.fail = fail;
  2033. // 4. Pure assertion tests whether a value is truthy, as determined
  2034. // by !!guard.
  2035. // assert.ok(guard, message_opt);
  2036. // This statement is equivalent to assert.equal(true, !!guard,
  2037. // message_opt);. To test strictly for the value true, use
  2038. // assert.strictEqual(true, guard, message_opt);.
  2039. function ok(value, message) {
  2040. if (!value) fail(value, true, message, '==', assert.ok);
  2041. }
  2042. assert.ok = ok;
  2043. // 5. The equality assertion tests shallow, coercive equality with
  2044. // ==.
  2045. // assert.equal(actual, expected, message_opt);
  2046. assert.equal = function equal(actual, expected, message) {
  2047. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  2048. };
  2049. // 6. The non-equality assertion tests for whether two objects are not equal
  2050. // with != assert.notEqual(actual, expected, message_opt);
  2051. assert.notEqual = function notEqual(actual, expected, message) {
  2052. if (actual == expected) {
  2053. fail(actual, expected, message, '!=', assert.notEqual);
  2054. }
  2055. };
  2056. // 7. The equivalence assertion tests a deep equality relation.
  2057. // assert.deepEqual(actual, expected, message_opt);
  2058. assert.deepEqual = function deepEqual(actual, expected, message) {
  2059. if (!_deepEqual(actual, expected, false)) {
  2060. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  2061. }
  2062. };
  2063. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  2064. if (!_deepEqual(actual, expected, true)) {
  2065. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  2066. }
  2067. };
  2068. function _deepEqual(actual, expected, strict, memos) {
  2069. // 7.1. All identical values are equivalent, as determined by ===.
  2070. if (actual === expected) {
  2071. return true;
  2072. } else if (isBuffer(actual) && isBuffer(expected)) {
  2073. return compare(actual, expected) === 0;
  2074. // 7.2. If the expected value is a Date object, the actual value is
  2075. // equivalent if it is also a Date object that refers to the same time.
  2076. } else if (util.isDate(actual) && util.isDate(expected)) {
  2077. return actual.getTime() === expected.getTime();
  2078. // 7.3 If the expected value is a RegExp object, the actual value is
  2079. // equivalent if it is also a RegExp object with the same source and
  2080. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  2081. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  2082. return actual.source === expected.source &&
  2083. actual.global === expected.global &&
  2084. actual.multiline === expected.multiline &&
  2085. actual.lastIndex === expected.lastIndex &&
  2086. actual.ignoreCase === expected.ignoreCase;
  2087. // 7.4. Other pairs that do not both pass typeof value == 'object',
  2088. // equivalence is determined by ==.
  2089. } else if ((actual === null || typeof actual !== 'object') &&
  2090. (expected === null || typeof expected !== 'object')) {
  2091. return strict ? actual === expected : actual == expected;
  2092. // If both values are instances of typed arrays, wrap their underlying
  2093. // ArrayBuffers in a Buffer each to increase performance
  2094. // This optimization requires the arrays to have the same type as checked by
  2095. // Object.prototype.toString (aka pToString). Never perform binary
  2096. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  2097. // bit patterns are not identical.
  2098. } else if (isView(actual) && isView(expected) &&
  2099. pToString(actual) === pToString(expected) &&
  2100. !(actual instanceof Float32Array ||
  2101. actual instanceof Float64Array)) {
  2102. return compare(new Uint8Array(actual.buffer),
  2103. new Uint8Array(expected.buffer)) === 0;
  2104. // 7.5 For all other Object pairs, including Array objects, equivalence is
  2105. // determined by having the same number of owned properties (as verified
  2106. // with Object.prototype.hasOwnProperty.call), the same set of keys
  2107. // (although not necessarily the same order), equivalent values for every
  2108. // corresponding key, and an identical 'prototype' property. Note: this
  2109. // accounts for both named and indexed properties on Arrays.
  2110. } else if (isBuffer(actual) !== isBuffer(expected)) {
  2111. return false;
  2112. } else {
  2113. memos = memos || {actual: [], expected: []};
  2114. var actualIndex = memos.actual.indexOf(actual);
  2115. if (actualIndex !== -1) {
  2116. if (actualIndex === memos.expected.indexOf(expected)) {
  2117. return true;
  2118. }
  2119. }
  2120. memos.actual.push(actual);
  2121. memos.expected.push(expected);
  2122. return objEquiv(actual, expected, strict, memos);
  2123. }
  2124. }
  2125. function isArguments(object) {
  2126. return Object.prototype.toString.call(object) == '[object Arguments]';
  2127. }
  2128. function objEquiv(a, b, strict, actualVisitedObjects) {
  2129. if (a === null || a === undefined || b === null || b === undefined)
  2130. return false;
  2131. // if one is a primitive, the other must be same
  2132. if (util.isPrimitive(a) || util.isPrimitive(b))
  2133. return a === b;
  2134. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  2135. return false;
  2136. var aIsArgs = isArguments(a);
  2137. var bIsArgs = isArguments(b);
  2138. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  2139. return false;
  2140. if (aIsArgs) {
  2141. a = pSlice.call(a);
  2142. b = pSlice.call(b);
  2143. return _deepEqual(a, b, strict);
  2144. }
  2145. var ka = objectKeys(a);
  2146. var kb = objectKeys(b);
  2147. var key, i;
  2148. // having the same number of owned properties (keys incorporates
  2149. // hasOwnProperty)
  2150. if (ka.length !== kb.length)
  2151. return false;
  2152. //the same set of keys (although not necessarily the same order),
  2153. ka.sort();
  2154. kb.sort();
  2155. //~~~cheap key test
  2156. for (i = ka.length - 1; i >= 0; i--) {
  2157. if (ka[i] !== kb[i])
  2158. return false;
  2159. }
  2160. //equivalent values for every corresponding key, and
  2161. //~~~possibly expensive deep test
  2162. for (i = ka.length - 1; i >= 0; i--) {
  2163. key = ka[i];
  2164. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  2165. return false;
  2166. }
  2167. return true;
  2168. }
  2169. // 8. The non-equivalence assertion tests for any deep inequality.
  2170. // assert.notDeepEqual(actual, expected, message_opt);
  2171. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  2172. if (_deepEqual(actual, expected, false)) {
  2173. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  2174. }
  2175. };
  2176. assert.notDeepStrictEqual = notDeepStrictEqual;
  2177. function notDeepStrictEqual(actual, expected, message) {
  2178. if (_deepEqual(actual, expected, true)) {
  2179. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  2180. }
  2181. }
  2182. // 9. The strict equality assertion tests strict equality, as determined by ===.
  2183. // assert.strictEqual(actual, expected, message_opt);
  2184. assert.strictEqual = function strictEqual(actual, expected, message) {
  2185. if (actual !== expected) {
  2186. fail(actual, expected, message, '===', assert.strictEqual);
  2187. }
  2188. };
  2189. // 10. The strict non-equality assertion tests for strict inequality, as
  2190. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  2191. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  2192. if (actual === expected) {
  2193. fail(actual, expected, message, '!==', assert.notStrictEqual);
  2194. }
  2195. };
  2196. function expectedException(actual, expected) {
  2197. if (!actual || !expected) {
  2198. return false;
  2199. }
  2200. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  2201. return expected.test(actual);
  2202. }
  2203. try {
  2204. if (actual instanceof expected) {
  2205. return true;
  2206. }
  2207. } catch (e) {
  2208. // Ignore. The instanceof check doesn't work for arrow functions.
  2209. }
  2210. if (Error.isPrototypeOf(expected)) {
  2211. return false;
  2212. }
  2213. return expected.call({}, actual) === true;
  2214. }
  2215. function _tryBlock(block) {
  2216. var error;
  2217. try {
  2218. block();
  2219. } catch (e) {
  2220. error = e;
  2221. }
  2222. return error;
  2223. }
  2224. function _throws(shouldThrow, block, expected, message) {
  2225. var actual;
  2226. if (typeof block !== 'function') {
  2227. throw new TypeError('"block" argument must be a function');
  2228. }
  2229. if (typeof expected === 'string') {
  2230. message = expected;
  2231. expected = null;
  2232. }
  2233. actual = _tryBlock(block);
  2234. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  2235. (message ? ' ' + message : '.');
  2236. if (shouldThrow && !actual) {
  2237. fail(actual, expected, 'Missing expected exception' + message);
  2238. }
  2239. var userProvidedMessage = typeof message === 'string';
  2240. var isUnwantedException = !shouldThrow && util.isError(actual);
  2241. var isUnexpectedException = !shouldThrow && actual && !expected;
  2242. if ((isUnwantedException &&
  2243. userProvidedMessage &&
  2244. expectedException(actual, expected)) ||
  2245. isUnexpectedException) {
  2246. fail(actual, expected, 'Got unwanted exception' + message);
  2247. }
  2248. if ((shouldThrow && actual && expected &&
  2249. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  2250. throw actual;
  2251. }
  2252. }
  2253. // 11. Expected to throw an error:
  2254. // assert.throws(block, Error_opt, message_opt);
  2255. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  2256. _throws(true, block, error, message);
  2257. };
  2258. // EXTENSION! This is annoying to write outside this module.
  2259. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  2260. _throws(false, block, error, message);
  2261. };
  2262. assert.ifError = function(err) { if (err) throw err; };
  2263. var objectKeys = Object.keys || function (obj) {
  2264. var keys = [];
  2265. for (var key in obj) {
  2266. if (hasOwn.call(obj, key)) keys.push(key);
  2267. }
  2268. return keys;
  2269. };
  2270. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2271. },{"util/":8}],6:[function(require,module,exports){
  2272. if (typeof Object.create === 'function') {
  2273. // implementation from standard node.js 'util' module
  2274. module.exports = function inherits(ctor, superCtor) {
  2275. ctor.super_ = superCtor
  2276. ctor.prototype = Object.create(superCtor.prototype, {
  2277. constructor: {
  2278. value: ctor,
  2279. enumerable: false,
  2280. writable: true,
  2281. configurable: true
  2282. }
  2283. });
  2284. };
  2285. } else {
  2286. // old school shim for old browsers
  2287. module.exports = function inherits(ctor, superCtor) {
  2288. ctor.super_ = superCtor
  2289. var TempCtor = function () {}
  2290. TempCtor.prototype = superCtor.prototype
  2291. ctor.prototype = new TempCtor()
  2292. ctor.prototype.constructor = ctor
  2293. }
  2294. }
  2295. },{}],7:[function(require,module,exports){
  2296. module.exports = function isBuffer(arg) {
  2297. return arg && typeof arg === 'object'
  2298. && typeof arg.copy === 'function'
  2299. && typeof arg.fill === 'function'
  2300. && typeof arg.readUInt8 === 'function';
  2301. }
  2302. },{}],8:[function(require,module,exports){
  2303. (function (process,global){
  2304. // Copyright Joyent, Inc. and other Node contributors.
  2305. //
  2306. // Permission is hereby granted, free of charge, to any person obtaining a
  2307. // copy of this software and associated documentation files (the
  2308. // "Software"), to deal in the Software without restriction, including
  2309. // without limitation the rights to use, copy, modify, merge, publish,
  2310. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2311. // persons to whom the Software is furnished to do so, subject to the
  2312. // following conditions:
  2313. //
  2314. // The above copyright notice and this permission notice shall be included
  2315. // in all copies or substantial portions of the Software.
  2316. //
  2317. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2318. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2319. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2320. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2321. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2322. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2323. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2324. var formatRegExp = /%[sdj%]/g;
  2325. exports.format = function(f) {
  2326. if (!isString(f)) {
  2327. var objects = [];
  2328. for (var i = 0; i < arguments.length; i++) {
  2329. objects.push(inspect(arguments[i]));
  2330. }
  2331. return objects.join(' ');
  2332. }
  2333. var i = 1;
  2334. var args = arguments;
  2335. var len = args.length;
  2336. var str = String(f).replace(formatRegExp, function(x) {
  2337. if (x === '%%') return '%';
  2338. if (i >= len) return x;
  2339. switch (x) {
  2340. case '%s': return String(args[i++]);
  2341. case '%d': return Number(args[i++]);
  2342. case '%j':
  2343. try {
  2344. return JSON.stringify(args[i++]);
  2345. } catch (_) {
  2346. return '[Circular]';
  2347. }
  2348. default:
  2349. return x;
  2350. }
  2351. });
  2352. for (var x = args[i]; i < len; x = args[++i]) {
  2353. if (isNull(x) || !isObject(x)) {
  2354. str += ' ' + x;
  2355. } else {
  2356. str += ' ' + inspect(x);
  2357. }
  2358. }
  2359. return str;
  2360. };
  2361. // Mark that a method should not be used.
  2362. // Returns a modified function which warns once by default.
  2363. // If --no-deprecation is set, then it is a no-op.
  2364. exports.deprecate = function(fn, msg) {
  2365. // Allow for deprecating things in the process of starting up.
  2366. if (isUndefined(global.process)) {
  2367. return function() {
  2368. return exports.deprecate(fn, msg).apply(this, arguments);
  2369. };
  2370. }
  2371. if (process.noDeprecation === true) {
  2372. return fn;
  2373. }
  2374. var warned = false;
  2375. function deprecated() {
  2376. if (!warned) {
  2377. if (process.throwDeprecation) {
  2378. throw new Error(msg);
  2379. } else if (process.traceDeprecation) {
  2380. console.trace(msg);
  2381. } else {
  2382. console.error(msg);
  2383. }
  2384. warned = true;
  2385. }
  2386. return fn.apply(this, arguments);
  2387. }
  2388. return deprecated;
  2389. };
  2390. var debugs = {};
  2391. var debugEnviron;
  2392. exports.debuglog = function(set) {
  2393. if (isUndefined(debugEnviron))
  2394. debugEnviron = process.env.NODE_DEBUG || '';
  2395. set = set.toUpperCase();
  2396. if (!debugs[set]) {
  2397. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  2398. var pid = process.pid;
  2399. debugs[set] = function() {
  2400. var msg = exports.format.apply(exports, arguments);
  2401. console.error('%s %d: %s', set, pid, msg);
  2402. };
  2403. } else {
  2404. debugs[set] = function() {};
  2405. }
  2406. }
  2407. return debugs[set];
  2408. };
  2409. /**
  2410. * Echos the value of a value. Trys to print the value out
  2411. * in the best way possible given the different types.
  2412. *
  2413. * @param {Object} obj The object to print out.
  2414. * @param {Object} opts Optional options object that alters the output.
  2415. */
  2416. /* legacy: obj, showHidden, depth, colors*/
  2417. function inspect(obj, opts) {
  2418. // default options
  2419. var ctx = {
  2420. seen: [],
  2421. stylize: stylizeNoColor
  2422. };
  2423. // legacy...
  2424. if (arguments.length >= 3) ctx.depth = arguments[2];
  2425. if (arguments.length >= 4) ctx.colors = arguments[3];
  2426. if (isBoolean(opts)) {
  2427. // legacy...
  2428. ctx.showHidden = opts;
  2429. } else if (opts) {
  2430. // got an "options" object
  2431. exports._extend(ctx, opts);
  2432. }
  2433. // set default options
  2434. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  2435. if (isUndefined(ctx.depth)) ctx.depth = 2;
  2436. if (isUndefined(ctx.colors)) ctx.colors = false;
  2437. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  2438. if (ctx.colors) ctx.stylize = stylizeWithColor;
  2439. return formatValue(ctx, obj, ctx.depth);
  2440. }
  2441. exports.inspect = inspect;
  2442. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  2443. inspect.colors = {
  2444. 'bold' : [1, 22],
  2445. 'italic' : [3, 23],
  2446. 'underline' : [4, 24],
  2447. 'inverse' : [7, 27],
  2448. 'white' : [37, 39],
  2449. 'grey' : [90, 39],
  2450. 'black' : [30, 39],
  2451. 'blue' : [34, 39],
  2452. 'cyan' : [36, 39],
  2453. 'green' : [32, 39],
  2454. 'magenta' : [35, 39],
  2455. 'red' : [31, 39],
  2456. 'yellow' : [33, 39]
  2457. };
  2458. // Don't use 'blue' not visible on cmd.exe
  2459. inspect.styles = {
  2460. 'special': 'cyan',
  2461. 'number': 'yellow',
  2462. 'boolean': 'yellow',
  2463. 'undefined': 'grey',
  2464. 'null': 'bold',
  2465. 'string': 'green',
  2466. 'date': 'magenta',
  2467. // "name": intentionally not styling
  2468. 'regexp': 'red'
  2469. };
  2470. function stylizeWithColor(str, styleType) {
  2471. var style = inspect.styles[styleType];
  2472. if (style) {
  2473. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  2474. '\u001b[' + inspect.colors[style][1] + 'm';
  2475. } else {
  2476. return str;
  2477. }
  2478. }
  2479. function stylizeNoColor(str, styleType) {
  2480. return str;
  2481. }
  2482. function arrayToHash(array) {
  2483. var hash = {};
  2484. array.forEach(function(val, idx) {
  2485. hash[val] = true;
  2486. });
  2487. return hash;
  2488. }
  2489. function formatValue(ctx, value, recurseTimes) {
  2490. // Provide a hook for user-specified inspect functions.
  2491. // Check that value is an object with an inspect function on it
  2492. if (ctx.customInspect &&
  2493. value &&
  2494. isFunction(value.inspect) &&
  2495. // Filter out the util module, it's inspect function is special
  2496. value.inspect !== exports.inspect &&
  2497. // Also filter out any prototype objects using the circular check.
  2498. !(value.constructor && value.constructor.prototype === value)) {
  2499. var ret = value.inspect(recurseTimes, ctx);
  2500. if (!isString(ret)) {
  2501. ret = formatValue(ctx, ret, recurseTimes);
  2502. }
  2503. return ret;
  2504. }
  2505. // Primitive types cannot have properties
  2506. var primitive = formatPrimitive(ctx, value);
  2507. if (primitive) {
  2508. return primitive;
  2509. }
  2510. // Look up the keys of the object.
  2511. var keys = Object.keys(value);
  2512. var visibleKeys = arrayToHash(keys);
  2513. if (ctx.showHidden) {
  2514. keys = Object.getOwnPropertyNames(value);
  2515. }
  2516. // IE doesn't make error fields non-enumerable
  2517. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  2518. if (isError(value)
  2519. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  2520. return formatError(value);
  2521. }
  2522. // Some type of object without properties can be shortcutted.
  2523. if (keys.length === 0) {
  2524. if (isFunction(value)) {
  2525. var name = value.name ? ': ' + value.name : '';
  2526. return ctx.stylize('[Function' + name + ']', 'special');
  2527. }
  2528. if (isRegExp(value)) {
  2529. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2530. }
  2531. if (isDate(value)) {
  2532. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  2533. }
  2534. if (isError(value)) {
  2535. return formatError(value);
  2536. }
  2537. }
  2538. var base = '', array = false, braces = ['{', '}'];
  2539. // Make Array say that they are Array
  2540. if (isArray(value)) {
  2541. array = true;
  2542. braces = ['[', ']'];
  2543. }
  2544. // Make functions say that they are functions
  2545. if (isFunction(value)) {
  2546. var n = value.name ? ': ' + value.name : '';
  2547. base = ' [Function' + n + ']';
  2548. }
  2549. // Make RegExps say that they are RegExps
  2550. if (isRegExp(value)) {
  2551. base = ' ' + RegExp.prototype.toString.call(value);
  2552. }
  2553. // Make dates with properties first say the date
  2554. if (isDate(value)) {
  2555. base = ' ' + Date.prototype.toUTCString.call(value);
  2556. }
  2557. // Make error with message first say the error
  2558. if (isError(value)) {
  2559. base = ' ' + formatError(value);
  2560. }
  2561. if (keys.length === 0 && (!array || value.length == 0)) {
  2562. return braces[0] + base + braces[1];
  2563. }
  2564. if (recurseTimes < 0) {
  2565. if (isRegExp(value)) {
  2566. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2567. } else {
  2568. return ctx.stylize('[Object]', 'special');
  2569. }
  2570. }
  2571. ctx.seen.push(value);
  2572. var output;
  2573. if (array) {
  2574. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  2575. } else {
  2576. output = keys.map(function(key) {
  2577. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  2578. });
  2579. }
  2580. ctx.seen.pop();
  2581. return reduceToSingleString(output, base, braces);
  2582. }
  2583. function formatPrimitive(ctx, value) {
  2584. if (isUndefined(value))
  2585. return ctx.stylize('undefined', 'undefined');
  2586. if (isString(value)) {
  2587. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  2588. .replace(/'/g, "\\'")
  2589. .replace(/\\"/g, '"') + '\'';
  2590. return ctx.stylize(simple, 'string');
  2591. }
  2592. if (isNumber(value))
  2593. return ctx.stylize('' + value, 'number');
  2594. if (isBoolean(value))
  2595. return ctx.stylize('' + value, 'boolean');
  2596. // For some reason typeof null is "object", so special case here.
  2597. if (isNull(value))
  2598. return ctx.stylize('null', 'null');
  2599. }
  2600. function formatError(value) {
  2601. return '[' + Error.prototype.toString.call(value) + ']';
  2602. }
  2603. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  2604. var output = [];
  2605. for (var i = 0, l = value.length; i < l; ++i) {
  2606. if (hasOwnProperty(value, String(i))) {
  2607. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2608. String(i), true));
  2609. } else {
  2610. output.push('');
  2611. }
  2612. }
  2613. keys.forEach(function(key) {
  2614. if (!key.match(/^\d+$/)) {
  2615. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2616. key, true));
  2617. }
  2618. });
  2619. return output;
  2620. }
  2621. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  2622. var name, str, desc;
  2623. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  2624. if (desc.get) {
  2625. if (desc.set) {
  2626. str = ctx.stylize('[Getter/Setter]', 'special');
  2627. } else {
  2628. str = ctx.stylize('[Getter]', 'special');
  2629. }
  2630. } else {
  2631. if (desc.set) {
  2632. str = ctx.stylize('[Setter]', 'special');
  2633. }
  2634. }
  2635. if (!hasOwnProperty(visibleKeys, key)) {
  2636. name = '[' + key + ']';
  2637. }
  2638. if (!str) {
  2639. if (ctx.seen.indexOf(desc.value) < 0) {
  2640. if (isNull(recurseTimes)) {
  2641. str = formatValue(ctx, desc.value, null);
  2642. } else {
  2643. str = formatValue(ctx, desc.value, recurseTimes - 1);
  2644. }
  2645. if (str.indexOf('\n') > -1) {
  2646. if (array) {
  2647. str = str.split('\n').map(function(line) {
  2648. return ' ' + line;
  2649. }).join('\n').substr(2);
  2650. } else {
  2651. str = '\n' + str.split('\n').map(function(line) {
  2652. return ' ' + line;
  2653. }).join('\n');
  2654. }
  2655. }
  2656. } else {
  2657. str = ctx.stylize('[Circular]', 'special');
  2658. }
  2659. }
  2660. if (isUndefined(name)) {
  2661. if (array && key.match(/^\d+$/)) {
  2662. return str;
  2663. }
  2664. name = JSON.stringify('' + key);
  2665. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  2666. name = name.substr(1, name.length - 2);
  2667. name = ctx.stylize(name, 'name');
  2668. } else {
  2669. name = name.replace(/'/g, "\\'")
  2670. .replace(/\\"/g, '"')
  2671. .replace(/(^"|"$)/g, "'");
  2672. name = ctx.stylize(name, 'string');
  2673. }
  2674. }
  2675. return name + ': ' + str;
  2676. }
  2677. function reduceToSingleString(output, base, braces) {
  2678. var numLinesEst = 0;
  2679. var length = output.reduce(function(prev, cur) {
  2680. numLinesEst++;
  2681. if (cur.indexOf('\n') >= 0) numLinesEst++;
  2682. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  2683. }, 0);
  2684. if (length > 60) {
  2685. return braces[0] +
  2686. (base === '' ? '' : base + '\n ') +
  2687. ' ' +
  2688. output.join(',\n ') +
  2689. ' ' +
  2690. braces[1];
  2691. }
  2692. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  2693. }
  2694. // NOTE: These type checking functions intentionally don't use `instanceof`
  2695. // because it is fragile and can be easily faked with `Object.create()`.
  2696. function isArray(ar) {
  2697. return Array.isArray(ar);
  2698. }
  2699. exports.isArray = isArray;
  2700. function isBoolean(arg) {
  2701. return typeof arg === 'boolean';
  2702. }
  2703. exports.isBoolean = isBoolean;
  2704. function isNull(arg) {
  2705. return arg === null;
  2706. }
  2707. exports.isNull = isNull;
  2708. function isNullOrUndefined(arg) {
  2709. return arg == null;
  2710. }
  2711. exports.isNullOrUndefined = isNullOrUndefined;
  2712. function isNumber(arg) {
  2713. return typeof arg === 'number';
  2714. }
  2715. exports.isNumber = isNumber;
  2716. function isString(arg) {
  2717. return typeof arg === 'string';
  2718. }
  2719. exports.isString = isString;
  2720. function isSymbol(arg) {
  2721. return typeof arg === 'symbol';
  2722. }
  2723. exports.isSymbol = isSymbol;
  2724. function isUndefined(arg) {
  2725. return arg === void 0;
  2726. }
  2727. exports.isUndefined = isUndefined;
  2728. function isRegExp(re) {
  2729. return isObject(re) && objectToString(re) === '[object RegExp]';
  2730. }
  2731. exports.isRegExp = isRegExp;
  2732. function isObject(arg) {
  2733. return typeof arg === 'object' && arg !== null;
  2734. }
  2735. exports.isObject = isObject;
  2736. function isDate(d) {
  2737. return isObject(d) && objectToString(d) === '[object Date]';
  2738. }
  2739. exports.isDate = isDate;
  2740. function isError(e) {
  2741. return isObject(e) &&
  2742. (objectToString(e) === '[object Error]' || e instanceof Error);
  2743. }
  2744. exports.isError = isError;
  2745. function isFunction(arg) {
  2746. return typeof arg === 'function';
  2747. }
  2748. exports.isFunction = isFunction;
  2749. function isPrimitive(arg) {
  2750. return arg === null ||
  2751. typeof arg === 'boolean' ||
  2752. typeof arg === 'number' ||
  2753. typeof arg === 'string' ||
  2754. typeof arg === 'symbol' || // ES6 symbol
  2755. typeof arg === 'undefined';
  2756. }
  2757. exports.isPrimitive = isPrimitive;
  2758. exports.isBuffer = require('./support/isBuffer');
  2759. function objectToString(o) {
  2760. return Object.prototype.toString.call(o);
  2761. }
  2762. function pad(n) {
  2763. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  2764. }
  2765. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  2766. 'Oct', 'Nov', 'Dec'];
  2767. // 26 Feb 16:19:34
  2768. function timestamp() {
  2769. var d = new Date();
  2770. var time = [pad(d.getHours()),
  2771. pad(d.getMinutes()),
  2772. pad(d.getSeconds())].join(':');
  2773. return [d.getDate(), months[d.getMonth()], time].join(' ');
  2774. }
  2775. // log is just a thin wrapper to console.log that prepends a timestamp
  2776. exports.log = function() {
  2777. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  2778. };
  2779. /**
  2780. * Inherit the prototype methods from one constructor into another.
  2781. *
  2782. * The Function.prototype.inherits from lang.js rewritten as a standalone
  2783. * function (not on Function.prototype). NOTE: If this file is to be loaded
  2784. * during bootstrapping this function needs to be rewritten using some native
  2785. * functions as prototype setup using normal JavaScript does not work as
  2786. * expected during bootstrapping (see mirror.js in r114903).
  2787. *
  2788. * @param {function} ctor Constructor function which needs to inherit the
  2789. * prototype.
  2790. * @param {function} superCtor Constructor function to inherit prototype from.
  2791. */
  2792. exports.inherits = require('inherits');
  2793. exports._extend = function(origin, add) {
  2794. // Don't do anything if add isn't an object
  2795. if (!add || !isObject(add)) return origin;
  2796. var keys = Object.keys(add);
  2797. var i = keys.length;
  2798. while (i--) {
  2799. origin[keys[i]] = add[keys[i]];
  2800. }
  2801. return origin;
  2802. };
  2803. function hasOwnProperty(obj, prop) {
  2804. return Object.prototype.hasOwnProperty.call(obj, prop);
  2805. }
  2806. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2807. },{"./support/isBuffer":7,"_process":12,"inherits":6}],9:[function(require,module,exports){
  2808. 'use strict'
  2809. exports.byteLength = byteLength
  2810. exports.toByteArray = toByteArray
  2811. exports.fromByteArray = fromByteArray
  2812. var lookup = []
  2813. var revLookup = []
  2814. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  2815. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  2816. for (var i = 0, len = code.length; i < len; ++i) {
  2817. lookup[i] = code[i]
  2818. revLookup[code.charCodeAt(i)] = i
  2819. }
  2820. // Support decoding URL-safe base64 strings, as Node.js does.
  2821. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  2822. revLookup['-'.charCodeAt(0)] = 62
  2823. revLookup['_'.charCodeAt(0)] = 63
  2824. function getLens (b64) {
  2825. var len = b64.length
  2826. if (len % 4 > 0) {
  2827. throw new Error('Invalid string. Length must be a multiple of 4')
  2828. }
  2829. // Trim off extra bytes after placeholder bytes are found
  2830. // See: https://github.com/beatgammit/base64-js/issues/42
  2831. var validLen = b64.indexOf('=')
  2832. if (validLen === -1) validLen = len
  2833. var placeHoldersLen = validLen === len
  2834. ? 0
  2835. : 4 - (validLen % 4)
  2836. return [validLen, placeHoldersLen]
  2837. }
  2838. // base64 is 4/3 + up to two characters of the original data
  2839. function byteLength (b64) {
  2840. var lens = getLens(b64)
  2841. var validLen = lens[0]
  2842. var placeHoldersLen = lens[1]
  2843. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  2844. }
  2845. function _byteLength (b64, validLen, placeHoldersLen) {
  2846. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  2847. }
  2848. function toByteArray (b64) {
  2849. var tmp
  2850. var lens = getLens(b64)
  2851. var validLen = lens[0]
  2852. var placeHoldersLen = lens[1]
  2853. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  2854. var curByte = 0
  2855. // if there are placeholders, only get up to the last complete 4 chars
  2856. var len = placeHoldersLen > 0
  2857. ? validLen - 4
  2858. : validLen
  2859. for (var i = 0; i < len; i += 4) {
  2860. tmp =
  2861. (revLookup[b64.charCodeAt(i)] << 18) |
  2862. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  2863. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  2864. revLookup[b64.charCodeAt(i + 3)]
  2865. arr[curByte++] = (tmp >> 16) & 0xFF
  2866. arr[curByte++] = (tmp >> 8) & 0xFF
  2867. arr[curByte++] = tmp & 0xFF
  2868. }
  2869. if (placeHoldersLen === 2) {
  2870. tmp =
  2871. (revLookup[b64.charCodeAt(i)] << 2) |
  2872. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  2873. arr[curByte++] = tmp & 0xFF
  2874. }
  2875. if (placeHoldersLen === 1) {
  2876. tmp =
  2877. (revLookup[b64.charCodeAt(i)] << 10) |
  2878. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  2879. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  2880. arr[curByte++] = (tmp >> 8) & 0xFF
  2881. arr[curByte++] = tmp & 0xFF
  2882. }
  2883. return arr
  2884. }
  2885. function tripletToBase64 (num) {
  2886. return lookup[num >> 18 & 0x3F] +
  2887. lookup[num >> 12 & 0x3F] +
  2888. lookup[num >> 6 & 0x3F] +
  2889. lookup[num & 0x3F]
  2890. }
  2891. function encodeChunk (uint8, start, end) {
  2892. var tmp
  2893. var output = []
  2894. for (var i = start; i < end; i += 3) {
  2895. tmp =
  2896. ((uint8[i] << 16) & 0xFF0000) +
  2897. ((uint8[i + 1] << 8) & 0xFF00) +
  2898. (uint8[i + 2] & 0xFF)
  2899. output.push(tripletToBase64(tmp))
  2900. }
  2901. return output.join('')
  2902. }
  2903. function fromByteArray (uint8) {
  2904. var tmp
  2905. var len = uint8.length
  2906. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  2907. var parts = []
  2908. var maxChunkLength = 16383 // must be multiple of 3
  2909. // go through the array every three bytes, we'll deal with trailing stuff later
  2910. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  2911. parts.push(encodeChunk(
  2912. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  2913. ))
  2914. }
  2915. // pad the end with zeros, but make sure to not forget the extra bytes
  2916. if (extraBytes === 1) {
  2917. tmp = uint8[len - 1]
  2918. parts.push(
  2919. lookup[tmp >> 2] +
  2920. lookup[(tmp << 4) & 0x3F] +
  2921. '=='
  2922. )
  2923. } else if (extraBytes === 2) {
  2924. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  2925. parts.push(
  2926. lookup[tmp >> 10] +
  2927. lookup[(tmp >> 4) & 0x3F] +
  2928. lookup[(tmp << 2) & 0x3F] +
  2929. '='
  2930. )
  2931. }
  2932. return parts.join('')
  2933. }
  2934. },{}],10:[function(require,module,exports){
  2935. (function (Buffer){
  2936. /*!
  2937. * The buffer module from node.js, for the browser.
  2938. *
  2939. * @author Feross Aboukhadijeh <https://feross.org>
  2940. * @license MIT
  2941. */
  2942. /* eslint-disable no-proto */
  2943. 'use strict'
  2944. var base64 = require('base64-js')
  2945. var ieee754 = require('ieee754')
  2946. exports.Buffer = Buffer
  2947. exports.SlowBuffer = SlowBuffer
  2948. exports.INSPECT_MAX_BYTES = 50
  2949. var K_MAX_LENGTH = 0x7fffffff
  2950. exports.kMaxLength = K_MAX_LENGTH
  2951. /**
  2952. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  2953. * === true Use Uint8Array implementation (fastest)
  2954. * === false Print warning and recommend using `buffer` v4.x which has an Object
  2955. * implementation (most compatible, even IE6)
  2956. *
  2957. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  2958. * Opera 11.6+, iOS 4.2+.
  2959. *
  2960. * We report that the browser does not support typed arrays if the are not subclassable
  2961. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  2962. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  2963. * for __proto__ and has a buggy typed array implementation.
  2964. */
  2965. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  2966. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  2967. typeof console.error === 'function') {
  2968. console.error(
  2969. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  2970. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  2971. )
  2972. }
  2973. function typedArraySupport () {
  2974. // Can typed array instances can be augmented?
  2975. try {
  2976. var arr = new Uint8Array(1)
  2977. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  2978. return arr.foo() === 42
  2979. } catch (e) {
  2980. return false
  2981. }
  2982. }
  2983. Object.defineProperty(Buffer.prototype, 'parent', {
  2984. enumerable: true,
  2985. get: function () {
  2986. if (!Buffer.isBuffer(this)) return undefined
  2987. return this.buffer
  2988. }
  2989. })
  2990. Object.defineProperty(Buffer.prototype, 'offset', {
  2991. enumerable: true,
  2992. get: function () {
  2993. if (!Buffer.isBuffer(this)) return undefined
  2994. return this.byteOffset
  2995. }
  2996. })
  2997. function createBuffer (length) {
  2998. if (length > K_MAX_LENGTH) {
  2999. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  3000. }
  3001. // Return an augmented `Uint8Array` instance
  3002. var buf = new Uint8Array(length)
  3003. buf.__proto__ = Buffer.prototype
  3004. return buf
  3005. }
  3006. /**
  3007. * The Buffer constructor returns instances of `Uint8Array` that have their
  3008. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  3009. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  3010. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  3011. * returns a single octet.
  3012. *
  3013. * The `Uint8Array` prototype remains unmodified.
  3014. */
  3015. function Buffer (arg, encodingOrOffset, length) {
  3016. // Common case.
  3017. if (typeof arg === 'number') {
  3018. if (typeof encodingOrOffset === 'string') {
  3019. throw new TypeError(
  3020. 'The "string" argument must be of type string. Received type number'
  3021. )
  3022. }
  3023. return allocUnsafe(arg)
  3024. }
  3025. return from(arg, encodingOrOffset, length)
  3026. }
  3027. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  3028. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  3029. Buffer[Symbol.species] === Buffer) {
  3030. Object.defineProperty(Buffer, Symbol.species, {
  3031. value: null,
  3032. configurable: true,
  3033. enumerable: false,
  3034. writable: false
  3035. })
  3036. }
  3037. Buffer.poolSize = 8192 // not used by this implementation
  3038. function from (value, encodingOrOffset, length) {
  3039. if (typeof value === 'string') {
  3040. return fromString(value, encodingOrOffset)
  3041. }
  3042. if (ArrayBuffer.isView(value)) {
  3043. return fromArrayLike(value)
  3044. }
  3045. if (value == null) {
  3046. throw TypeError(
  3047. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  3048. 'or Array-like Object. Received type ' + (typeof value)
  3049. )
  3050. }
  3051. if (isInstance(value, ArrayBuffer) ||
  3052. (value && isInstance(value.buffer, ArrayBuffer))) {
  3053. return fromArrayBuffer(value, encodingOrOffset, length)
  3054. }
  3055. if (typeof value === 'number') {
  3056. throw new TypeError(
  3057. 'The "value" argument must not be of type number. Received type number'
  3058. )
  3059. }
  3060. var valueOf = value.valueOf && value.valueOf()
  3061. if (valueOf != null && valueOf !== value) {
  3062. return Buffer.from(valueOf, encodingOrOffset, length)
  3063. }
  3064. var b = fromObject(value)
  3065. if (b) return b
  3066. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  3067. typeof value[Symbol.toPrimitive] === 'function') {
  3068. return Buffer.from(
  3069. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  3070. )
  3071. }
  3072. throw new TypeError(
  3073. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  3074. 'or Array-like Object. Received type ' + (typeof value)
  3075. )
  3076. }
  3077. /**
  3078. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  3079. * if value is a number.
  3080. * Buffer.from(str[, encoding])
  3081. * Buffer.from(array)
  3082. * Buffer.from(buffer)
  3083. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  3084. **/
  3085. Buffer.from = function (value, encodingOrOffset, length) {
  3086. return from(value, encodingOrOffset, length)
  3087. }
  3088. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  3089. // https://github.com/feross/buffer/pull/148
  3090. Buffer.prototype.__proto__ = Uint8Array.prototype
  3091. Buffer.__proto__ = Uint8Array
  3092. function assertSize (size) {
  3093. if (typeof size !== 'number') {
  3094. throw new TypeError('"size" argument must be of type number')
  3095. } else if (size < 0) {
  3096. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  3097. }
  3098. }
  3099. function alloc (size, fill, encoding) {
  3100. assertSize(size)
  3101. if (size <= 0) {
  3102. return createBuffer(size)
  3103. }
  3104. if (fill !== undefined) {
  3105. // Only pay attention to encoding if it's a string. This
  3106. // prevents accidentally sending in a number that would
  3107. // be interpretted as a start offset.
  3108. return typeof encoding === 'string'
  3109. ? createBuffer(size).fill(fill, encoding)
  3110. : createBuffer(size).fill(fill)
  3111. }
  3112. return createBuffer(size)
  3113. }
  3114. /**
  3115. * Creates a new filled Buffer instance.
  3116. * alloc(size[, fill[, encoding]])
  3117. **/
  3118. Buffer.alloc = function (size, fill, encoding) {
  3119. return alloc(size, fill, encoding)
  3120. }
  3121. function allocUnsafe (size) {
  3122. assertSize(size)
  3123. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  3124. }
  3125. /**
  3126. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  3127. * */
  3128. Buffer.allocUnsafe = function (size) {
  3129. return allocUnsafe(size)
  3130. }
  3131. /**
  3132. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  3133. */
  3134. Buffer.allocUnsafeSlow = function (size) {
  3135. return allocUnsafe(size)
  3136. }
  3137. function fromString (string, encoding) {
  3138. if (typeof encoding !== 'string' || encoding === '') {
  3139. encoding = 'utf8'
  3140. }
  3141. if (!Buffer.isEncoding(encoding)) {
  3142. throw new TypeError('Unknown encoding: ' + encoding)
  3143. }
  3144. var length = byteLength(string, encoding) | 0
  3145. var buf = createBuffer(length)
  3146. var actual = buf.write(string, encoding)
  3147. if (actual !== length) {
  3148. // Writing a hex string, for example, that contains invalid characters will
  3149. // cause everything after the first invalid character to be ignored. (e.g.
  3150. // 'abxxcd' will be treated as 'ab')
  3151. buf = buf.slice(0, actual)
  3152. }
  3153. return buf
  3154. }
  3155. function fromArrayLike (array) {
  3156. var length = array.length < 0 ? 0 : checked(array.length) | 0
  3157. var buf = createBuffer(length)
  3158. for (var i = 0; i < length; i += 1) {
  3159. buf[i] = array[i] & 255
  3160. }
  3161. return buf
  3162. }
  3163. function fromArrayBuffer (array, byteOffset, length) {
  3164. if (byteOffset < 0 || array.byteLength < byteOffset) {
  3165. throw new RangeError('"offset" is outside of buffer bounds')
  3166. }
  3167. if (array.byteLength < byteOffset + (length || 0)) {
  3168. throw new RangeError('"length" is outside of buffer bounds')
  3169. }
  3170. var buf
  3171. if (byteOffset === undefined && length === undefined) {
  3172. buf = new Uint8Array(array)
  3173. } else if (length === undefined) {
  3174. buf = new Uint8Array(array, byteOffset)
  3175. } else {
  3176. buf = new Uint8Array(array, byteOffset, length)
  3177. }
  3178. // Return an augmented `Uint8Array` instance
  3179. buf.__proto__ = Buffer.prototype
  3180. return buf
  3181. }
  3182. function fromObject (obj) {
  3183. if (Buffer.isBuffer(obj)) {
  3184. var len = checked(obj.length) | 0
  3185. var buf = createBuffer(len)
  3186. if (buf.length === 0) {
  3187. return buf
  3188. }
  3189. obj.copy(buf, 0, 0, len)
  3190. return buf
  3191. }
  3192. if (obj.length !== undefined) {
  3193. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  3194. return createBuffer(0)
  3195. }
  3196. return fromArrayLike(obj)
  3197. }
  3198. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  3199. return fromArrayLike(obj.data)
  3200. }
  3201. }
  3202. function checked (length) {
  3203. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  3204. // length is NaN (which is otherwise coerced to zero.)
  3205. if (length >= K_MAX_LENGTH) {
  3206. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  3207. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  3208. }
  3209. return length | 0
  3210. }
  3211. function SlowBuffer (length) {
  3212. if (+length != length) { // eslint-disable-line eqeqeq
  3213. length = 0
  3214. }
  3215. return Buffer.alloc(+length)
  3216. }
  3217. Buffer.isBuffer = function isBuffer (b) {
  3218. return b != null && b._isBuffer === true &&
  3219. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  3220. }
  3221. Buffer.compare = function compare (a, b) {
  3222. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  3223. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  3224. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  3225. throw new TypeError(
  3226. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  3227. )
  3228. }
  3229. if (a === b) return 0
  3230. var x = a.length
  3231. var y = b.length
  3232. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  3233. if (a[i] !== b[i]) {
  3234. x = a[i]
  3235. y = b[i]
  3236. break
  3237. }
  3238. }
  3239. if (x < y) return -1
  3240. if (y < x) return 1
  3241. return 0
  3242. }
  3243. Buffer.isEncoding = function isEncoding (encoding) {
  3244. switch (String(encoding).toLowerCase()) {
  3245. case 'hex':
  3246. case 'utf8':
  3247. case 'utf-8':
  3248. case 'ascii':
  3249. case 'latin1':
  3250. case 'binary':
  3251. case 'base64':
  3252. case 'ucs2':
  3253. case 'ucs-2':
  3254. case 'utf16le':
  3255. case 'utf-16le':
  3256. return true
  3257. default:
  3258. return false
  3259. }
  3260. }
  3261. Buffer.concat = function concat (list, length) {
  3262. if (!Array.isArray(list)) {
  3263. throw new TypeError('"list" argument must be an Array of Buffers')
  3264. }
  3265. if (list.length === 0) {
  3266. return Buffer.alloc(0)
  3267. }
  3268. var i
  3269. if (length === undefined) {
  3270. length = 0
  3271. for (i = 0; i < list.length; ++i) {
  3272. length += list[i].length
  3273. }
  3274. }
  3275. var buffer = Buffer.allocUnsafe(length)
  3276. var pos = 0
  3277. for (i = 0; i < list.length; ++i) {
  3278. var buf = list[i]
  3279. if (isInstance(buf, Uint8Array)) {
  3280. buf = Buffer.from(buf)
  3281. }
  3282. if (!Buffer.isBuffer(buf)) {
  3283. throw new TypeError('"list" argument must be an Array of Buffers')
  3284. }
  3285. buf.copy(buffer, pos)
  3286. pos += buf.length
  3287. }
  3288. return buffer
  3289. }
  3290. function byteLength (string, encoding) {
  3291. if (Buffer.isBuffer(string)) {
  3292. return string.length
  3293. }
  3294. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  3295. return string.byteLength
  3296. }
  3297. if (typeof string !== 'string') {
  3298. throw new TypeError(
  3299. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  3300. 'Received type ' + typeof string
  3301. )
  3302. }
  3303. var len = string.length
  3304. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  3305. if (!mustMatch && len === 0) return 0
  3306. // Use a for loop to avoid recursion
  3307. var loweredCase = false
  3308. for (;;) {
  3309. switch (encoding) {
  3310. case 'ascii':
  3311. case 'latin1':
  3312. case 'binary':
  3313. return len
  3314. case 'utf8':
  3315. case 'utf-8':
  3316. return utf8ToBytes(string).length
  3317. case 'ucs2':
  3318. case 'ucs-2':
  3319. case 'utf16le':
  3320. case 'utf-16le':
  3321. return len * 2
  3322. case 'hex':
  3323. return len >>> 1
  3324. case 'base64':
  3325. return base64ToBytes(string).length
  3326. default:
  3327. if (loweredCase) {
  3328. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  3329. }
  3330. encoding = ('' + encoding).toLowerCase()
  3331. loweredCase = true
  3332. }
  3333. }
  3334. }
  3335. Buffer.byteLength = byteLength
  3336. function slowToString (encoding, start, end) {
  3337. var loweredCase = false
  3338. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  3339. // property of a typed array.
  3340. // This behaves neither like String nor Uint8Array in that we set start/end
  3341. // to their upper/lower bounds if the value passed is out of range.
  3342. // undefined is handled specially as per ECMA-262 6th Edition,
  3343. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  3344. if (start === undefined || start < 0) {
  3345. start = 0
  3346. }
  3347. // Return early if start > this.length. Done here to prevent potential uint32
  3348. // coercion fail below.
  3349. if (start > this.length) {
  3350. return ''
  3351. }
  3352. if (end === undefined || end > this.length) {
  3353. end = this.length
  3354. }
  3355. if (end <= 0) {
  3356. return ''
  3357. }
  3358. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  3359. end >>>= 0
  3360. start >>>= 0
  3361. if (end <= start) {
  3362. return ''
  3363. }
  3364. if (!encoding) encoding = 'utf8'
  3365. while (true) {
  3366. switch (encoding) {
  3367. case 'hex':
  3368. return hexSlice(this, start, end)
  3369. case 'utf8':
  3370. case 'utf-8':
  3371. return utf8Slice(this, start, end)
  3372. case 'ascii':
  3373. return asciiSlice(this, start, end)
  3374. case 'latin1':
  3375. case 'binary':
  3376. return latin1Slice(this, start, end)
  3377. case 'base64':
  3378. return base64Slice(this, start, end)
  3379. case 'ucs2':
  3380. case 'ucs-2':
  3381. case 'utf16le':
  3382. case 'utf-16le':
  3383. return utf16leSlice(this, start, end)
  3384. default:
  3385. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3386. encoding = (encoding + '').toLowerCase()
  3387. loweredCase = true
  3388. }
  3389. }
  3390. }
  3391. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  3392. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  3393. // reliably in a browserify context because there could be multiple different
  3394. // copies of the 'buffer' package in use. This method works even for Buffer
  3395. // instances that were created from another copy of the `buffer` package.
  3396. // See: https://github.com/feross/buffer/issues/154
  3397. Buffer.prototype._isBuffer = true
  3398. function swap (b, n, m) {
  3399. var i = b[n]
  3400. b[n] = b[m]
  3401. b[m] = i
  3402. }
  3403. Buffer.prototype.swap16 = function swap16 () {
  3404. var len = this.length
  3405. if (len % 2 !== 0) {
  3406. throw new RangeError('Buffer size must be a multiple of 16-bits')
  3407. }
  3408. for (var i = 0; i < len; i += 2) {
  3409. swap(this, i, i + 1)
  3410. }
  3411. return this
  3412. }
  3413. Buffer.prototype.swap32 = function swap32 () {
  3414. var len = this.length
  3415. if (len % 4 !== 0) {
  3416. throw new RangeError('Buffer size must be a multiple of 32-bits')
  3417. }
  3418. for (var i = 0; i < len; i += 4) {
  3419. swap(this, i, i + 3)
  3420. swap(this, i + 1, i + 2)
  3421. }
  3422. return this
  3423. }
  3424. Buffer.prototype.swap64 = function swap64 () {
  3425. var len = this.length
  3426. if (len % 8 !== 0) {
  3427. throw new RangeError('Buffer size must be a multiple of 64-bits')
  3428. }
  3429. for (var i = 0; i < len; i += 8) {
  3430. swap(this, i, i + 7)
  3431. swap(this, i + 1, i + 6)
  3432. swap(this, i + 2, i + 5)
  3433. swap(this, i + 3, i + 4)
  3434. }
  3435. return this
  3436. }
  3437. Buffer.prototype.toString = function toString () {
  3438. var length = this.length
  3439. if (length === 0) return ''
  3440. if (arguments.length === 0) return utf8Slice(this, 0, length)
  3441. return slowToString.apply(this, arguments)
  3442. }
  3443. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  3444. Buffer.prototype.equals = function equals (b) {
  3445. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  3446. if (this === b) return true
  3447. return Buffer.compare(this, b) === 0
  3448. }
  3449. Buffer.prototype.inspect = function inspect () {
  3450. var str = ''
  3451. var max = exports.INSPECT_MAX_BYTES
  3452. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  3453. if (this.length > max) str += ' ... '
  3454. return '<Buffer ' + str + '>'
  3455. }
  3456. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  3457. if (isInstance(target, Uint8Array)) {
  3458. target = Buffer.from(target, target.offset, target.byteLength)
  3459. }
  3460. if (!Buffer.isBuffer(target)) {
  3461. throw new TypeError(
  3462. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  3463. 'Received type ' + (typeof target)
  3464. )
  3465. }
  3466. if (start === undefined) {
  3467. start = 0
  3468. }
  3469. if (end === undefined) {
  3470. end = target ? target.length : 0
  3471. }
  3472. if (thisStart === undefined) {
  3473. thisStart = 0
  3474. }
  3475. if (thisEnd === undefined) {
  3476. thisEnd = this.length
  3477. }
  3478. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  3479. throw new RangeError('out of range index')
  3480. }
  3481. if (thisStart >= thisEnd && start >= end) {
  3482. return 0
  3483. }
  3484. if (thisStart >= thisEnd) {
  3485. return -1
  3486. }
  3487. if (start >= end) {
  3488. return 1
  3489. }
  3490. start >>>= 0
  3491. end >>>= 0
  3492. thisStart >>>= 0
  3493. thisEnd >>>= 0
  3494. if (this === target) return 0
  3495. var x = thisEnd - thisStart
  3496. var y = end - start
  3497. var len = Math.min(x, y)
  3498. var thisCopy = this.slice(thisStart, thisEnd)
  3499. var targetCopy = target.slice(start, end)
  3500. for (var i = 0; i < len; ++i) {
  3501. if (thisCopy[i] !== targetCopy[i]) {
  3502. x = thisCopy[i]
  3503. y = targetCopy[i]
  3504. break
  3505. }
  3506. }
  3507. if (x < y) return -1
  3508. if (y < x) return 1
  3509. return 0
  3510. }
  3511. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  3512. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  3513. //
  3514. // Arguments:
  3515. // - buffer - a Buffer to search
  3516. // - val - a string, Buffer, or number
  3517. // - byteOffset - an index into `buffer`; will be clamped to an int32
  3518. // - encoding - an optional encoding, relevant is val is a string
  3519. // - dir - true for indexOf, false for lastIndexOf
  3520. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  3521. // Empty buffer means no match
  3522. if (buffer.length === 0) return -1
  3523. // Normalize byteOffset
  3524. if (typeof byteOffset === 'string') {
  3525. encoding = byteOffset
  3526. byteOffset = 0
  3527. } else if (byteOffset > 0x7fffffff) {
  3528. byteOffset = 0x7fffffff
  3529. } else if (byteOffset < -0x80000000) {
  3530. byteOffset = -0x80000000
  3531. }
  3532. byteOffset = +byteOffset // Coerce to Number.
  3533. if (numberIsNaN(byteOffset)) {
  3534. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  3535. byteOffset = dir ? 0 : (buffer.length - 1)
  3536. }
  3537. // Normalize byteOffset: negative offsets start from the end of the buffer
  3538. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  3539. if (byteOffset >= buffer.length) {
  3540. if (dir) return -1
  3541. else byteOffset = buffer.length - 1
  3542. } else if (byteOffset < 0) {
  3543. if (dir) byteOffset = 0
  3544. else return -1
  3545. }
  3546. // Normalize val
  3547. if (typeof val === 'string') {
  3548. val = Buffer.from(val, encoding)
  3549. }
  3550. // Finally, search either indexOf (if dir is true) or lastIndexOf
  3551. if (Buffer.isBuffer(val)) {
  3552. // Special case: looking for empty string/buffer always fails
  3553. if (val.length === 0) {
  3554. return -1
  3555. }
  3556. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  3557. } else if (typeof val === 'number') {
  3558. val = val & 0xFF // Search for a byte value [0-255]
  3559. if (typeof Uint8Array.prototype.indexOf === 'function') {
  3560. if (dir) {
  3561. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  3562. } else {
  3563. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  3564. }
  3565. }
  3566. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  3567. }
  3568. throw new TypeError('val must be string, number or Buffer')
  3569. }
  3570. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  3571. var indexSize = 1
  3572. var arrLength = arr.length
  3573. var valLength = val.length
  3574. if (encoding !== undefined) {
  3575. encoding = String(encoding).toLowerCase()
  3576. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  3577. encoding === 'utf16le' || encoding === 'utf-16le') {
  3578. if (arr.length < 2 || val.length < 2) {
  3579. return -1
  3580. }
  3581. indexSize = 2
  3582. arrLength /= 2
  3583. valLength /= 2
  3584. byteOffset /= 2
  3585. }
  3586. }
  3587. function read (buf, i) {
  3588. if (indexSize === 1) {
  3589. return buf[i]
  3590. } else {
  3591. return buf.readUInt16BE(i * indexSize)
  3592. }
  3593. }
  3594. var i
  3595. if (dir) {
  3596. var foundIndex = -1
  3597. for (i = byteOffset; i < arrLength; i++) {
  3598. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  3599. if (foundIndex === -1) foundIndex = i
  3600. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  3601. } else {
  3602. if (foundIndex !== -1) i -= i - foundIndex
  3603. foundIndex = -1
  3604. }
  3605. }
  3606. } else {
  3607. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  3608. for (i = byteOffset; i >= 0; i--) {
  3609. var found = true
  3610. for (var j = 0; j < valLength; j++) {
  3611. if (read(arr, i + j) !== read(val, j)) {
  3612. found = false
  3613. break
  3614. }
  3615. }
  3616. if (found) return i
  3617. }
  3618. }
  3619. return -1
  3620. }
  3621. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  3622. return this.indexOf(val, byteOffset, encoding) !== -1
  3623. }
  3624. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  3625. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  3626. }
  3627. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  3628. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  3629. }
  3630. function hexWrite (buf, string, offset, length) {
  3631. offset = Number(offset) || 0
  3632. var remaining = buf.length - offset
  3633. if (!length) {
  3634. length = remaining
  3635. } else {
  3636. length = Number(length)
  3637. if (length > remaining) {
  3638. length = remaining
  3639. }
  3640. }
  3641. var strLen = string.length
  3642. if (length > strLen / 2) {
  3643. length = strLen / 2
  3644. }
  3645. for (var i = 0; i < length; ++i) {
  3646. var parsed = parseInt(string.substr(i * 2, 2), 16)
  3647. if (numberIsNaN(parsed)) return i
  3648. buf[offset + i] = parsed
  3649. }
  3650. return i
  3651. }
  3652. function utf8Write (buf, string, offset, length) {
  3653. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  3654. }
  3655. function asciiWrite (buf, string, offset, length) {
  3656. return blitBuffer(asciiToBytes(string), buf, offset, length)
  3657. }
  3658. function latin1Write (buf, string, offset, length) {
  3659. return asciiWrite(buf, string, offset, length)
  3660. }
  3661. function base64Write (buf, string, offset, length) {
  3662. return blitBuffer(base64ToBytes(string), buf, offset, length)
  3663. }
  3664. function ucs2Write (buf, string, offset, length) {
  3665. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  3666. }
  3667. Buffer.prototype.write = function write (string, offset, length, encoding) {
  3668. // Buffer#write(string)
  3669. if (offset === undefined) {
  3670. encoding = 'utf8'
  3671. length = this.length
  3672. offset = 0
  3673. // Buffer#write(string, encoding)
  3674. } else if (length === undefined && typeof offset === 'string') {
  3675. encoding = offset
  3676. length = this.length
  3677. offset = 0
  3678. // Buffer#write(string, offset[, length][, encoding])
  3679. } else if (isFinite(offset)) {
  3680. offset = offset >>> 0
  3681. if (isFinite(length)) {
  3682. length = length >>> 0
  3683. if (encoding === undefined) encoding = 'utf8'
  3684. } else {
  3685. encoding = length
  3686. length = undefined
  3687. }
  3688. } else {
  3689. throw new Error(
  3690. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  3691. )
  3692. }
  3693. var remaining = this.length - offset
  3694. if (length === undefined || length > remaining) length = remaining
  3695. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  3696. throw new RangeError('Attempt to write outside buffer bounds')
  3697. }
  3698. if (!encoding) encoding = 'utf8'
  3699. var loweredCase = false
  3700. for (;;) {
  3701. switch (encoding) {
  3702. case 'hex':
  3703. return hexWrite(this, string, offset, length)
  3704. case 'utf8':
  3705. case 'utf-8':
  3706. return utf8Write(this, string, offset, length)
  3707. case 'ascii':
  3708. return asciiWrite(this, string, offset, length)
  3709. case 'latin1':
  3710. case 'binary':
  3711. return latin1Write(this, string, offset, length)
  3712. case 'base64':
  3713. // Warning: maxLength not taken into account in base64Write
  3714. return base64Write(this, string, offset, length)
  3715. case 'ucs2':
  3716. case 'ucs-2':
  3717. case 'utf16le':
  3718. case 'utf-16le':
  3719. return ucs2Write(this, string, offset, length)
  3720. default:
  3721. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3722. encoding = ('' + encoding).toLowerCase()
  3723. loweredCase = true
  3724. }
  3725. }
  3726. }
  3727. Buffer.prototype.toJSON = function toJSON () {
  3728. return {
  3729. type: 'Buffer',
  3730. data: Array.prototype.slice.call(this._arr || this, 0)
  3731. }
  3732. }
  3733. function base64Slice (buf, start, end) {
  3734. if (start === 0 && end === buf.length) {
  3735. return base64.fromByteArray(buf)
  3736. } else {
  3737. return base64.fromByteArray(buf.slice(start, end))
  3738. }
  3739. }
  3740. function utf8Slice (buf, start, end) {
  3741. end = Math.min(buf.length, end)
  3742. var res = []
  3743. var i = start
  3744. while (i < end) {
  3745. var firstByte = buf[i]
  3746. var codePoint = null
  3747. var bytesPerSequence = (firstByte > 0xEF) ? 4
  3748. : (firstByte > 0xDF) ? 3
  3749. : (firstByte > 0xBF) ? 2
  3750. : 1
  3751. if (i + bytesPerSequence <= end) {
  3752. var secondByte, thirdByte, fourthByte, tempCodePoint
  3753. switch (bytesPerSequence) {
  3754. case 1:
  3755. if (firstByte < 0x80) {
  3756. codePoint = firstByte
  3757. }
  3758. break
  3759. case 2:
  3760. secondByte = buf[i + 1]
  3761. if ((secondByte & 0xC0) === 0x80) {
  3762. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  3763. if (tempCodePoint > 0x7F) {
  3764. codePoint = tempCodePoint
  3765. }
  3766. }
  3767. break
  3768. case 3:
  3769. secondByte = buf[i + 1]
  3770. thirdByte = buf[i + 2]
  3771. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  3772. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  3773. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  3774. codePoint = tempCodePoint
  3775. }
  3776. }
  3777. break
  3778. case 4:
  3779. secondByte = buf[i + 1]
  3780. thirdByte = buf[i + 2]
  3781. fourthByte = buf[i + 3]
  3782. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  3783. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  3784. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  3785. codePoint = tempCodePoint
  3786. }
  3787. }
  3788. }
  3789. }
  3790. if (codePoint === null) {
  3791. // we did not generate a valid codePoint so insert a
  3792. // replacement char (U+FFFD) and advance only 1 byte
  3793. codePoint = 0xFFFD
  3794. bytesPerSequence = 1
  3795. } else if (codePoint > 0xFFFF) {
  3796. // encode to utf16 (surrogate pair dance)
  3797. codePoint -= 0x10000
  3798. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  3799. codePoint = 0xDC00 | codePoint & 0x3FF
  3800. }
  3801. res.push(codePoint)
  3802. i += bytesPerSequence
  3803. }
  3804. return decodeCodePointsArray(res)
  3805. }
  3806. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  3807. // the lowest limit is Chrome, with 0x10000 args.
  3808. // We go 1 magnitude less, for safety
  3809. var MAX_ARGUMENTS_LENGTH = 0x1000
  3810. function decodeCodePointsArray (codePoints) {
  3811. var len = codePoints.length
  3812. if (len <= MAX_ARGUMENTS_LENGTH) {
  3813. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  3814. }
  3815. // Decode in chunks to avoid "call stack size exceeded".
  3816. var res = ''
  3817. var i = 0
  3818. while (i < len) {
  3819. res += String.fromCharCode.apply(
  3820. String,
  3821. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  3822. )
  3823. }
  3824. return res
  3825. }
  3826. function asciiSlice (buf, start, end) {
  3827. var ret = ''
  3828. end = Math.min(buf.length, end)
  3829. for (var i = start; i < end; ++i) {
  3830. ret += String.fromCharCode(buf[i] & 0x7F)
  3831. }
  3832. return ret
  3833. }
  3834. function latin1Slice (buf, start, end) {
  3835. var ret = ''
  3836. end = Math.min(buf.length, end)
  3837. for (var i = start; i < end; ++i) {
  3838. ret += String.fromCharCode(buf[i])
  3839. }
  3840. return ret
  3841. }
  3842. function hexSlice (buf, start, end) {
  3843. var len = buf.length
  3844. if (!start || start < 0) start = 0
  3845. if (!end || end < 0 || end > len) end = len
  3846. var out = ''
  3847. for (var i = start; i < end; ++i) {
  3848. out += toHex(buf[i])
  3849. }
  3850. return out
  3851. }
  3852. function utf16leSlice (buf, start, end) {
  3853. var bytes = buf.slice(start, end)
  3854. var res = ''
  3855. for (var i = 0; i < bytes.length; i += 2) {
  3856. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  3857. }
  3858. return res
  3859. }
  3860. Buffer.prototype.slice = function slice (start, end) {
  3861. var len = this.length
  3862. start = ~~start
  3863. end = end === undefined ? len : ~~end
  3864. if (start < 0) {
  3865. start += len
  3866. if (start < 0) start = 0
  3867. } else if (start > len) {
  3868. start = len
  3869. }
  3870. if (end < 0) {
  3871. end += len
  3872. if (end < 0) end = 0
  3873. } else if (end > len) {
  3874. end = len
  3875. }
  3876. if (end < start) end = start
  3877. var newBuf = this.subarray(start, end)
  3878. // Return an augmented `Uint8Array` instance
  3879. newBuf.__proto__ = Buffer.prototype
  3880. return newBuf
  3881. }
  3882. /*
  3883. * Need to make sure that buffer isn't trying to write out of bounds.
  3884. */
  3885. function checkOffset (offset, ext, length) {
  3886. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  3887. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  3888. }
  3889. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  3890. offset = offset >>> 0
  3891. byteLength = byteLength >>> 0
  3892. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3893. var val = this[offset]
  3894. var mul = 1
  3895. var i = 0
  3896. while (++i < byteLength && (mul *= 0x100)) {
  3897. val += this[offset + i] * mul
  3898. }
  3899. return val
  3900. }
  3901. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  3902. offset = offset >>> 0
  3903. byteLength = byteLength >>> 0
  3904. if (!noAssert) {
  3905. checkOffset(offset, byteLength, this.length)
  3906. }
  3907. var val = this[offset + --byteLength]
  3908. var mul = 1
  3909. while (byteLength > 0 && (mul *= 0x100)) {
  3910. val += this[offset + --byteLength] * mul
  3911. }
  3912. return val
  3913. }
  3914. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  3915. offset = offset >>> 0
  3916. if (!noAssert) checkOffset(offset, 1, this.length)
  3917. return this[offset]
  3918. }
  3919. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  3920. offset = offset >>> 0
  3921. if (!noAssert) checkOffset(offset, 2, this.length)
  3922. return this[offset] | (this[offset + 1] << 8)
  3923. }
  3924. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  3925. offset = offset >>> 0
  3926. if (!noAssert) checkOffset(offset, 2, this.length)
  3927. return (this[offset] << 8) | this[offset + 1]
  3928. }
  3929. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  3930. offset = offset >>> 0
  3931. if (!noAssert) checkOffset(offset, 4, this.length)
  3932. return ((this[offset]) |
  3933. (this[offset + 1] << 8) |
  3934. (this[offset + 2] << 16)) +
  3935. (this[offset + 3] * 0x1000000)
  3936. }
  3937. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  3938. offset = offset >>> 0
  3939. if (!noAssert) checkOffset(offset, 4, this.length)
  3940. return (this[offset] * 0x1000000) +
  3941. ((this[offset + 1] << 16) |
  3942. (this[offset + 2] << 8) |
  3943. this[offset + 3])
  3944. }
  3945. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  3946. offset = offset >>> 0
  3947. byteLength = byteLength >>> 0
  3948. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3949. var val = this[offset]
  3950. var mul = 1
  3951. var i = 0
  3952. while (++i < byteLength && (mul *= 0x100)) {
  3953. val += this[offset + i] * mul
  3954. }
  3955. mul *= 0x80
  3956. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3957. return val
  3958. }
  3959. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  3960. offset = offset >>> 0
  3961. byteLength = byteLength >>> 0
  3962. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3963. var i = byteLength
  3964. var mul = 1
  3965. var val = this[offset + --i]
  3966. while (i > 0 && (mul *= 0x100)) {
  3967. val += this[offset + --i] * mul
  3968. }
  3969. mul *= 0x80
  3970. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3971. return val
  3972. }
  3973. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  3974. offset = offset >>> 0
  3975. if (!noAssert) checkOffset(offset, 1, this.length)
  3976. if (!(this[offset] & 0x80)) return (this[offset])
  3977. return ((0xff - this[offset] + 1) * -1)
  3978. }
  3979. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  3980. offset = offset >>> 0
  3981. if (!noAssert) checkOffset(offset, 2, this.length)
  3982. var val = this[offset] | (this[offset + 1] << 8)
  3983. return (val & 0x8000) ? val | 0xFFFF0000 : val
  3984. }
  3985. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  3986. offset = offset >>> 0
  3987. if (!noAssert) checkOffset(offset, 2, this.length)
  3988. var val = this[offset + 1] | (this[offset] << 8)
  3989. return (val & 0x8000) ? val | 0xFFFF0000 : val
  3990. }
  3991. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  3992. offset = offset >>> 0
  3993. if (!noAssert) checkOffset(offset, 4, this.length)
  3994. return (this[offset]) |
  3995. (this[offset + 1] << 8) |
  3996. (this[offset + 2] << 16) |
  3997. (this[offset + 3] << 24)
  3998. }
  3999. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  4000. offset = offset >>> 0
  4001. if (!noAssert) checkOffset(offset, 4, this.length)
  4002. return (this[offset] << 24) |
  4003. (this[offset + 1] << 16) |
  4004. (this[offset + 2] << 8) |
  4005. (this[offset + 3])
  4006. }
  4007. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  4008. offset = offset >>> 0
  4009. if (!noAssert) checkOffset(offset, 4, this.length)
  4010. return ieee754.read(this, offset, true, 23, 4)
  4011. }
  4012. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  4013. offset = offset >>> 0
  4014. if (!noAssert) checkOffset(offset, 4, this.length)
  4015. return ieee754.read(this, offset, false, 23, 4)
  4016. }
  4017. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  4018. offset = offset >>> 0
  4019. if (!noAssert) checkOffset(offset, 8, this.length)
  4020. return ieee754.read(this, offset, true, 52, 8)
  4021. }
  4022. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  4023. offset = offset >>> 0
  4024. if (!noAssert) checkOffset(offset, 8, this.length)
  4025. return ieee754.read(this, offset, false, 52, 8)
  4026. }
  4027. function checkInt (buf, value, offset, ext, max, min) {
  4028. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  4029. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  4030. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  4031. }
  4032. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  4033. value = +value
  4034. offset = offset >>> 0
  4035. byteLength = byteLength >>> 0
  4036. if (!noAssert) {
  4037. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  4038. checkInt(this, value, offset, byteLength, maxBytes, 0)
  4039. }
  4040. var mul = 1
  4041. var i = 0
  4042. this[offset] = value & 0xFF
  4043. while (++i < byteLength && (mul *= 0x100)) {
  4044. this[offset + i] = (value / mul) & 0xFF
  4045. }
  4046. return offset + byteLength
  4047. }
  4048. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  4049. value = +value
  4050. offset = offset >>> 0
  4051. byteLength = byteLength >>> 0
  4052. if (!noAssert) {
  4053. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  4054. checkInt(this, value, offset, byteLength, maxBytes, 0)
  4055. }
  4056. var i = byteLength - 1
  4057. var mul = 1
  4058. this[offset + i] = value & 0xFF
  4059. while (--i >= 0 && (mul *= 0x100)) {
  4060. this[offset + i] = (value / mul) & 0xFF
  4061. }
  4062. return offset + byteLength
  4063. }
  4064. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  4065. value = +value
  4066. offset = offset >>> 0
  4067. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  4068. this[offset] = (value & 0xff)
  4069. return offset + 1
  4070. }
  4071. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  4072. value = +value
  4073. offset = offset >>> 0
  4074. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  4075. this[offset] = (value & 0xff)
  4076. this[offset + 1] = (value >>> 8)
  4077. return offset + 2
  4078. }
  4079. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  4080. value = +value
  4081. offset = offset >>> 0
  4082. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  4083. this[offset] = (value >>> 8)
  4084. this[offset + 1] = (value & 0xff)
  4085. return offset + 2
  4086. }
  4087. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  4088. value = +value
  4089. offset = offset >>> 0
  4090. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  4091. this[offset + 3] = (value >>> 24)
  4092. this[offset + 2] = (value >>> 16)
  4093. this[offset + 1] = (value >>> 8)
  4094. this[offset] = (value & 0xff)
  4095. return offset + 4
  4096. }
  4097. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  4098. value = +value
  4099. offset = offset >>> 0
  4100. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  4101. this[offset] = (value >>> 24)
  4102. this[offset + 1] = (value >>> 16)
  4103. this[offset + 2] = (value >>> 8)
  4104. this[offset + 3] = (value & 0xff)
  4105. return offset + 4
  4106. }
  4107. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  4108. value = +value
  4109. offset = offset >>> 0
  4110. if (!noAssert) {
  4111. var limit = Math.pow(2, (8 * byteLength) - 1)
  4112. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  4113. }
  4114. var i = 0
  4115. var mul = 1
  4116. var sub = 0
  4117. this[offset] = value & 0xFF
  4118. while (++i < byteLength && (mul *= 0x100)) {
  4119. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  4120. sub = 1
  4121. }
  4122. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  4123. }
  4124. return offset + byteLength
  4125. }
  4126. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  4127. value = +value
  4128. offset = offset >>> 0
  4129. if (!noAssert) {
  4130. var limit = Math.pow(2, (8 * byteLength) - 1)
  4131. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  4132. }
  4133. var i = byteLength - 1
  4134. var mul = 1
  4135. var sub = 0
  4136. this[offset + i] = value & 0xFF
  4137. while (--i >= 0 && (mul *= 0x100)) {
  4138. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  4139. sub = 1
  4140. }
  4141. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  4142. }
  4143. return offset + byteLength
  4144. }
  4145. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  4146. value = +value
  4147. offset = offset >>> 0
  4148. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  4149. if (value < 0) value = 0xff + value + 1
  4150. this[offset] = (value & 0xff)
  4151. return offset + 1
  4152. }
  4153. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  4154. value = +value
  4155. offset = offset >>> 0
  4156. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  4157. this[offset] = (value & 0xff)
  4158. this[offset + 1] = (value >>> 8)
  4159. return offset + 2
  4160. }
  4161. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  4162. value = +value
  4163. offset = offset >>> 0
  4164. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  4165. this[offset] = (value >>> 8)
  4166. this[offset + 1] = (value & 0xff)
  4167. return offset + 2
  4168. }
  4169. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  4170. value = +value
  4171. offset = offset >>> 0
  4172. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  4173. this[offset] = (value & 0xff)
  4174. this[offset + 1] = (value >>> 8)
  4175. this[offset + 2] = (value >>> 16)
  4176. this[offset + 3] = (value >>> 24)
  4177. return offset + 4
  4178. }
  4179. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  4180. value = +value
  4181. offset = offset >>> 0
  4182. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  4183. if (value < 0) value = 0xffffffff + value + 1
  4184. this[offset] = (value >>> 24)
  4185. this[offset + 1] = (value >>> 16)
  4186. this[offset + 2] = (value >>> 8)
  4187. this[offset + 3] = (value & 0xff)
  4188. return offset + 4
  4189. }
  4190. function checkIEEE754 (buf, value, offset, ext, max, min) {
  4191. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  4192. if (offset < 0) throw new RangeError('Index out of range')
  4193. }
  4194. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  4195. value = +value
  4196. offset = offset >>> 0
  4197. if (!noAssert) {
  4198. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  4199. }
  4200. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  4201. return offset + 4
  4202. }
  4203. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  4204. return writeFloat(this, value, offset, true, noAssert)
  4205. }
  4206. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  4207. return writeFloat(this, value, offset, false, noAssert)
  4208. }
  4209. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  4210. value = +value
  4211. offset = offset >>> 0
  4212. if (!noAssert) {
  4213. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  4214. }
  4215. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  4216. return offset + 8
  4217. }
  4218. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  4219. return writeDouble(this, value, offset, true, noAssert)
  4220. }
  4221. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  4222. return writeDouble(this, value, offset, false, noAssert)
  4223. }
  4224. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  4225. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  4226. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  4227. if (!start) start = 0
  4228. if (!end && end !== 0) end = this.length
  4229. if (targetStart >= target.length) targetStart = target.length
  4230. if (!targetStart) targetStart = 0
  4231. if (end > 0 && end < start) end = start
  4232. // Copy 0 bytes; we're done
  4233. if (end === start) return 0
  4234. if (target.length === 0 || this.length === 0) return 0
  4235. // Fatal error conditions
  4236. if (targetStart < 0) {
  4237. throw new RangeError('targetStart out of bounds')
  4238. }
  4239. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  4240. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  4241. // Are we oob?
  4242. if (end > this.length) end = this.length
  4243. if (target.length - targetStart < end - start) {
  4244. end = target.length - targetStart + start
  4245. }
  4246. var len = end - start
  4247. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  4248. // Use built-in when available, missing from IE11
  4249. this.copyWithin(targetStart, start, end)
  4250. } else if (this === target && start < targetStart && targetStart < end) {
  4251. // descending copy from end
  4252. for (var i = len - 1; i >= 0; --i) {
  4253. target[i + targetStart] = this[i + start]
  4254. }
  4255. } else {
  4256. Uint8Array.prototype.set.call(
  4257. target,
  4258. this.subarray(start, end),
  4259. targetStart
  4260. )
  4261. }
  4262. return len
  4263. }
  4264. // Usage:
  4265. // buffer.fill(number[, offset[, end]])
  4266. // buffer.fill(buffer[, offset[, end]])
  4267. // buffer.fill(string[, offset[, end]][, encoding])
  4268. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  4269. // Handle string cases:
  4270. if (typeof val === 'string') {
  4271. if (typeof start === 'string') {
  4272. encoding = start
  4273. start = 0
  4274. end = this.length
  4275. } else if (typeof end === 'string') {
  4276. encoding = end
  4277. end = this.length
  4278. }
  4279. if (encoding !== undefined && typeof encoding !== 'string') {
  4280. throw new TypeError('encoding must be a string')
  4281. }
  4282. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  4283. throw new TypeError('Unknown encoding: ' + encoding)
  4284. }
  4285. if (val.length === 1) {
  4286. var code = val.charCodeAt(0)
  4287. if ((encoding === 'utf8' && code < 128) ||
  4288. encoding === 'latin1') {
  4289. // Fast path: If `val` fits into a single byte, use that numeric value.
  4290. val = code
  4291. }
  4292. }
  4293. } else if (typeof val === 'number') {
  4294. val = val & 255
  4295. }
  4296. // Invalid ranges are not set to a default, so can range check early.
  4297. if (start < 0 || this.length < start || this.length < end) {
  4298. throw new RangeError('Out of range index')
  4299. }
  4300. if (end <= start) {
  4301. return this
  4302. }
  4303. start = start >>> 0
  4304. end = end === undefined ? this.length : end >>> 0
  4305. if (!val) val = 0
  4306. var i
  4307. if (typeof val === 'number') {
  4308. for (i = start; i < end; ++i) {
  4309. this[i] = val
  4310. }
  4311. } else {
  4312. var bytes = Buffer.isBuffer(val)
  4313. ? val
  4314. : Buffer.from(val, encoding)
  4315. var len = bytes.length
  4316. if (len === 0) {
  4317. throw new TypeError('The value "' + val +
  4318. '" is invalid for argument "value"')
  4319. }
  4320. for (i = 0; i < end - start; ++i) {
  4321. this[i + start] = bytes[i % len]
  4322. }
  4323. }
  4324. return this
  4325. }
  4326. // HELPER FUNCTIONS
  4327. // ================
  4328. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  4329. function base64clean (str) {
  4330. // Node takes equal signs as end of the Base64 encoding
  4331. str = str.split('=')[0]
  4332. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  4333. str = str.trim().replace(INVALID_BASE64_RE, '')
  4334. // Node converts strings with length < 2 to ''
  4335. if (str.length < 2) return ''
  4336. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  4337. while (str.length % 4 !== 0) {
  4338. str = str + '='
  4339. }
  4340. return str
  4341. }
  4342. function toHex (n) {
  4343. if (n < 16) return '0' + n.toString(16)
  4344. return n.toString(16)
  4345. }
  4346. function utf8ToBytes (string, units) {
  4347. units = units || Infinity
  4348. var codePoint
  4349. var length = string.length
  4350. var leadSurrogate = null
  4351. var bytes = []
  4352. for (var i = 0; i < length; ++i) {
  4353. codePoint = string.charCodeAt(i)
  4354. // is surrogate component
  4355. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  4356. // last char was a lead
  4357. if (!leadSurrogate) {
  4358. // no lead yet
  4359. if (codePoint > 0xDBFF) {
  4360. // unexpected trail
  4361. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4362. continue
  4363. } else if (i + 1 === length) {
  4364. // unpaired lead
  4365. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4366. continue
  4367. }
  4368. // valid lead
  4369. leadSurrogate = codePoint
  4370. continue
  4371. }
  4372. // 2 leads in a row
  4373. if (codePoint < 0xDC00) {
  4374. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4375. leadSurrogate = codePoint
  4376. continue
  4377. }
  4378. // valid surrogate pair
  4379. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  4380. } else if (leadSurrogate) {
  4381. // valid bmp char, but last char was a lead
  4382. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4383. }
  4384. leadSurrogate = null
  4385. // encode utf8
  4386. if (codePoint < 0x80) {
  4387. if ((units -= 1) < 0) break
  4388. bytes.push(codePoint)
  4389. } else if (codePoint < 0x800) {
  4390. if ((units -= 2) < 0) break
  4391. bytes.push(
  4392. codePoint >> 0x6 | 0xC0,
  4393. codePoint & 0x3F | 0x80
  4394. )
  4395. } else if (codePoint < 0x10000) {
  4396. if ((units -= 3) < 0) break
  4397. bytes.push(
  4398. codePoint >> 0xC | 0xE0,
  4399. codePoint >> 0x6 & 0x3F | 0x80,
  4400. codePoint & 0x3F | 0x80
  4401. )
  4402. } else if (codePoint < 0x110000) {
  4403. if ((units -= 4) < 0) break
  4404. bytes.push(
  4405. codePoint >> 0x12 | 0xF0,
  4406. codePoint >> 0xC & 0x3F | 0x80,
  4407. codePoint >> 0x6 & 0x3F | 0x80,
  4408. codePoint & 0x3F | 0x80
  4409. )
  4410. } else {
  4411. throw new Error('Invalid code point')
  4412. }
  4413. }
  4414. return bytes
  4415. }
  4416. function asciiToBytes (str) {
  4417. var byteArray = []
  4418. for (var i = 0; i < str.length; ++i) {
  4419. // Node's code seems to be doing this and not & 0x7F..
  4420. byteArray.push(str.charCodeAt(i) & 0xFF)
  4421. }
  4422. return byteArray
  4423. }
  4424. function utf16leToBytes (str, units) {
  4425. var c, hi, lo
  4426. var byteArray = []
  4427. for (var i = 0; i < str.length; ++i) {
  4428. if ((units -= 2) < 0) break
  4429. c = str.charCodeAt(i)
  4430. hi = c >> 8
  4431. lo = c % 256
  4432. byteArray.push(lo)
  4433. byteArray.push(hi)
  4434. }
  4435. return byteArray
  4436. }
  4437. function base64ToBytes (str) {
  4438. return base64.toByteArray(base64clean(str))
  4439. }
  4440. function blitBuffer (src, dst, offset, length) {
  4441. for (var i = 0; i < length; ++i) {
  4442. if ((i + offset >= dst.length) || (i >= src.length)) break
  4443. dst[i + offset] = src[i]
  4444. }
  4445. return i
  4446. }
  4447. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  4448. // the `instanceof` check but they should be treated as of that type.
  4449. // See: https://github.com/feross/buffer/issues/166
  4450. function isInstance (obj, type) {
  4451. return obj instanceof type ||
  4452. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  4453. obj.constructor.name === type.name)
  4454. }
  4455. function numberIsNaN (obj) {
  4456. // For IE11 support
  4457. return obj !== obj // eslint-disable-line no-self-compare
  4458. }
  4459. }).call(this,require("buffer").Buffer)
  4460. },{"base64-js":9,"buffer":10,"ieee754":11}],11:[function(require,module,exports){
  4461. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  4462. var e, m
  4463. var eLen = (nBytes * 8) - mLen - 1
  4464. var eMax = (1 << eLen) - 1
  4465. var eBias = eMax >> 1
  4466. var nBits = -7
  4467. var i = isLE ? (nBytes - 1) : 0
  4468. var d = isLE ? -1 : 1
  4469. var s = buffer[offset + i]
  4470. i += d
  4471. e = s & ((1 << (-nBits)) - 1)
  4472. s >>= (-nBits)
  4473. nBits += eLen
  4474. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  4475. m = e & ((1 << (-nBits)) - 1)
  4476. e >>= (-nBits)
  4477. nBits += mLen
  4478. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  4479. if (e === 0) {
  4480. e = 1 - eBias
  4481. } else if (e === eMax) {
  4482. return m ? NaN : ((s ? -1 : 1) * Infinity)
  4483. } else {
  4484. m = m + Math.pow(2, mLen)
  4485. e = e - eBias
  4486. }
  4487. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  4488. }
  4489. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  4490. var e, m, c
  4491. var eLen = (nBytes * 8) - mLen - 1
  4492. var eMax = (1 << eLen) - 1
  4493. var eBias = eMax >> 1
  4494. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  4495. var i = isLE ? 0 : (nBytes - 1)
  4496. var d = isLE ? 1 : -1
  4497. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  4498. value = Math.abs(value)
  4499. if (isNaN(value) || value === Infinity) {
  4500. m = isNaN(value) ? 1 : 0
  4501. e = eMax
  4502. } else {
  4503. e = Math.floor(Math.log(value) / Math.LN2)
  4504. if (value * (c = Math.pow(2, -e)) < 1) {
  4505. e--
  4506. c *= 2
  4507. }
  4508. if (e + eBias >= 1) {
  4509. value += rt / c
  4510. } else {
  4511. value += rt * Math.pow(2, 1 - eBias)
  4512. }
  4513. if (value * c >= 2) {
  4514. e++
  4515. c /= 2
  4516. }
  4517. if (e + eBias >= eMax) {
  4518. m = 0
  4519. e = eMax
  4520. } else if (e + eBias >= 1) {
  4521. m = ((value * c) - 1) * Math.pow(2, mLen)
  4522. e = e + eBias
  4523. } else {
  4524. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  4525. e = 0
  4526. }
  4527. }
  4528. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  4529. e = (e << mLen) | m
  4530. eLen += mLen
  4531. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  4532. buffer[offset + i - d] |= s * 128
  4533. }
  4534. },{}],12:[function(require,module,exports){
  4535. // shim for using process in browser
  4536. var process = module.exports = {};
  4537. // cached from whatever global is present so that test runners that stub it
  4538. // don't break things. But we need to wrap it in a try catch in case it is
  4539. // wrapped in strict mode code which doesn't define any globals. It's inside a
  4540. // function because try/catches deoptimize in certain engines.
  4541. var cachedSetTimeout;
  4542. var cachedClearTimeout;
  4543. function defaultSetTimout() {
  4544. throw new Error('setTimeout has not been defined');
  4545. }
  4546. function defaultClearTimeout () {
  4547. throw new Error('clearTimeout has not been defined');
  4548. }
  4549. (function () {
  4550. try {
  4551. if (typeof setTimeout === 'function') {
  4552. cachedSetTimeout = setTimeout;
  4553. } else {
  4554. cachedSetTimeout = defaultSetTimout;
  4555. }
  4556. } catch (e) {
  4557. cachedSetTimeout = defaultSetTimout;
  4558. }
  4559. try {
  4560. if (typeof clearTimeout === 'function') {
  4561. cachedClearTimeout = clearTimeout;
  4562. } else {
  4563. cachedClearTimeout = defaultClearTimeout;
  4564. }
  4565. } catch (e) {
  4566. cachedClearTimeout = defaultClearTimeout;
  4567. }
  4568. } ())
  4569. function runTimeout(fun) {
  4570. if (cachedSetTimeout === setTimeout) {
  4571. //normal enviroments in sane situations
  4572. return setTimeout(fun, 0);
  4573. }
  4574. // if setTimeout wasn't available but was latter defined
  4575. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  4576. cachedSetTimeout = setTimeout;
  4577. return setTimeout(fun, 0);
  4578. }
  4579. try {
  4580. // when when somebody has screwed with setTimeout but no I.E. maddness
  4581. return cachedSetTimeout(fun, 0);
  4582. } catch(e){
  4583. try {
  4584. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4585. return cachedSetTimeout.call(null, fun, 0);
  4586. } catch(e){
  4587. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  4588. return cachedSetTimeout.call(this, fun, 0);
  4589. }
  4590. }
  4591. }
  4592. function runClearTimeout(marker) {
  4593. if (cachedClearTimeout === clearTimeout) {
  4594. //normal enviroments in sane situations
  4595. return clearTimeout(marker);
  4596. }
  4597. // if clearTimeout wasn't available but was latter defined
  4598. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  4599. cachedClearTimeout = clearTimeout;
  4600. return clearTimeout(marker);
  4601. }
  4602. try {
  4603. // when when somebody has screwed with setTimeout but no I.E. maddness
  4604. return cachedClearTimeout(marker);
  4605. } catch (e){
  4606. try {
  4607. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4608. return cachedClearTimeout.call(null, marker);
  4609. } catch (e){
  4610. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  4611. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  4612. return cachedClearTimeout.call(this, marker);
  4613. }
  4614. }
  4615. }
  4616. var queue = [];
  4617. var draining = false;
  4618. var currentQueue;
  4619. var queueIndex = -1;
  4620. function cleanUpNextTick() {
  4621. if (!draining || !currentQueue) {
  4622. return;
  4623. }
  4624. draining = false;
  4625. if (currentQueue.length) {
  4626. queue = currentQueue.concat(queue);
  4627. } else {
  4628. queueIndex = -1;
  4629. }
  4630. if (queue.length) {
  4631. drainQueue();
  4632. }
  4633. }
  4634. function drainQueue() {
  4635. if (draining) {
  4636. return;
  4637. }
  4638. var timeout = runTimeout(cleanUpNextTick);
  4639. draining = true;
  4640. var len = queue.length;
  4641. while(len) {
  4642. currentQueue = queue;
  4643. queue = [];
  4644. while (++queueIndex < len) {
  4645. if (currentQueue) {
  4646. currentQueue[queueIndex].run();
  4647. }
  4648. }
  4649. queueIndex = -1;
  4650. len = queue.length;
  4651. }
  4652. currentQueue = null;
  4653. draining = false;
  4654. runClearTimeout(timeout);
  4655. }
  4656. process.nextTick = function (fun) {
  4657. var args = new Array(arguments.length - 1);
  4658. if (arguments.length > 1) {
  4659. for (var i = 1; i < arguments.length; i++) {
  4660. args[i - 1] = arguments[i];
  4661. }
  4662. }
  4663. queue.push(new Item(fun, args));
  4664. if (queue.length === 1 && !draining) {
  4665. runTimeout(drainQueue);
  4666. }
  4667. };
  4668. // v8 likes predictible objects
  4669. function Item(fun, array) {
  4670. this.fun = fun;
  4671. this.array = array;
  4672. }
  4673. Item.prototype.run = function () {
  4674. this.fun.apply(null, this.array);
  4675. };
  4676. process.title = 'browser';
  4677. process.browser = true;
  4678. process.env = {};
  4679. process.argv = [];
  4680. process.version = ''; // empty string to avoid regexp issues
  4681. process.versions = {};
  4682. function noop() {}
  4683. process.on = noop;
  4684. process.addListener = noop;
  4685. process.once = noop;
  4686. process.off = noop;
  4687. process.removeListener = noop;
  4688. process.removeAllListeners = noop;
  4689. process.emit = noop;
  4690. process.prependListener = noop;
  4691. process.prependOnceListener = noop;
  4692. process.listeners = function (name) { return [] }
  4693. process.binding = function (name) {
  4694. throw new Error('process.binding is not supported');
  4695. };
  4696. process.cwd = function () { return '/' };
  4697. process.chdir = function (dir) {
  4698. throw new Error('process.chdir is not supported');
  4699. };
  4700. process.umask = function() { return 0; };
  4701. },{}]},{},[2]);