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.

5432 lines
187 KiB

5 years ago
5 years ago
5 years ago
5 years ago
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+4IXAhpbnRfY29weQAACGludF96ZXJvAAEHaW50X29uZQADCmludF9pc1plcm8AAgZpbnRfZXEABAdpbnRfZ3RlAAUHaW50X2FkZAAGB2ludF9zdWIABwdpbnRfbXVsAAgHaW50X2RpdgALDmludF9pbnZlcnNlTW9kAAwHZjFtX2FkZAANB2YxbV9zdWIADgdmMW1fbmVnAA8LZjFtX21SZWR1Y3QAEAdmMW1fbXVsABESZjFtX2Zyb21Nb250Z29tZXJ5ABMQZjFtX3RvTW9udGdvbWVyeQASC2YxbV9pbnZlcnNlABQIZjFtX2NvcHkAAAhmMW1femVybwABCmYxbV9pc1plcm8AAgZmMW1fZXEABAdmMW1fb25lABUHZnJtX2FkZAAWB2ZybV9zdWIAFwdmcm1fbmVnABgLZnJtX21SZWR1Y3QAGQdmcm1fbXVsABoSZnJtX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AApAwg3AwggASAAKQMQNwMQIAEgACkDGDcDGAseACAAQgA3AwAgAEIANwMIIABCADcDECAAQgA3AxgLMwAgACkDGFAEQCAAKQMQUARAIAApAwhQBEAgACkDAFAPBUEADwsFQQAPCwVBAA8LQQAPCx4AIABCATcDACAAQgA3AwggAEIANwMQIABCADcDGAtHACAAKQMYIAEpAxhRBEAgACkDECABKQMQUQRAIAApAwggASkDCFEEQCAAKQMAIAEpAwBRDwVBAA8LBUEADwsFQQAPC0EADwt9ACAAKQMYIAEpAxhUBEBBAA8FIAApAxggASkDGFYEQEEBDwUgACkDECABKQMQVARAQQAPBSAAKQMQIAEpAxBWBEBBAQ8FIAApAwggASkDCFQEQEEADwUgACkDCCABKQMIVgRAQQEPBSAAKQMAIAEpAwBaDwsLCwsLC0EADwvUAQEBfiAANQIAIAE1AgB8IQMgAiADPgIAIAA1AgQgATUCBHwgA0IgiHwhAyACIAM+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+NwOQA0EoIAA1AhggATUCDH43A5gDQSggADUCGC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AiAgA0IgiHxB6A01AgQgBH58IQMgACADPgIgIAA1AiQgA0IgiHxB6A01AgggBH58IQMgACADPgIkIAA1AiggA0IgiHxB6A01AgwgBH58IQMgACADPgIoIAA1AiwgA0IgiHxB6A01AhAgBH58IQMgACADPgIsIAA1AjAgA0IgiHxB6A01AhQgBH58IQMgACADPgIwIAA1AjQgA0IgiHxB6A01AhggBH58IQMgACADPgI0IAA1AjggA0IgiHxB6A01AhwgBH58IQMgACADPgI4QegOIANCIIg+AhxB6A4gAEEgaiABEBYLEgAgACABQegSEAhB6BIgAhAZCwsAIABBiA4gARAaCxUAIABBqBMQAEHIExABQagTIAEQGQsXACAAIAEQHCABQegNIAEQDCABIAEQGwsJAEGoDiAAEAALFQAgACABQegTEBpB6BNBiA4gAhAaCwsAIABB6A0gARAMCwoAIABBwABqEAILFQAgABABIABBIGoQFSAAQcAAahABCyIAIAAgARAAIABBIGogAUEgahAAIABBwABqIAFBwABqEAALhgIAIAAQIQRAIAAgARAjDwsgACAAQYgUEBEgAEEgaiAAQSBqQagUEBFBqBRBqBRByBQQESAAQagUQegUEA1B6BRB6BRB6BQQEUHoFEGIFEHoFBAOQegUQcgUQegUEA5B6BRB6BRB6BQQDUGIFEGIFEGIFRANQYgVQYgUQYgVEA1BiBVBiBVBqBUQESAAQSBqIABBwABqQcgVEBFB6BRB6BQgARANQagVIAEgARAOQcgUQcgUQegVEA1B6BVB6BVB6BUQDUHoFUHoFUHoFRANQegUIAEgAUEgahAOIAFBIGpBiBUgAUEgahARIAFBIGpB6BUgAUEgahAOQcgVQcgVIAFBwABqEA0LrAMCAX8BfyAAQcAAaiEDIAFBwABqIQQgABAhBEAgASACECMPCyABECEEQCAAIAIQIw8LIAMgA0GIFhARIAQgBEGoFhARIABBqBZByBYQESABQYgWQegWEBEgA0GIFkGIFxARIARBqBZBqBcQESAAQSBqQagXQcgXEBEgAUEgakGIF0HoFxARQcgWQegWEAQEQEHIF0HoFxAEBEAgACACECQPCwtB6BZByBZBiBgQDkHoF0HIF0GoGBAOQYgYQYgYQcgYEA1ByBhByBhByBgQEUGIGEHIGEHoGBARQagYQagYQYgZEA1ByBZByBhByBkQEUGIGUGIGUGoGRARQcgZQcgZQegZEA1BqBlB6BggAhAOIAJB6BkgAhAOQcgXQegYQYgaEBFBiBpBiBpBiBoQDUHIGSACIAJBIGoQDiACQSBqQYgZIAJBIGoQESACQSBqQYgaIAJBIGoQDiADIAQgAkHAAGoQDSACQcAAaiACQcAAaiACQcAAahARIAJBwABqQYgWIAJBwABqEA4gAkHAAGpBqBYgAkHAAGoQDiACQcAAakGIGCACQcAAahARCyIAIAAgARAAIABBIGogAUEgahAPIABBwABqIAFBwABqEAALEAAgASACECYgACACIAIQJQsiACAAIAEQEyAAQSBqIAFBIGoQEyAAQcAAaiABQcAAahATCyIAIAAgARASIABBIGogAUEgahASIABBwABqIAFBwABqEBILTwAgABAhBEAgARAiBSAAQcAAakGoGhAUQagaQagaQcgaEBFBqBpByBpB6BoQESAAQcgaIAEQESAAQSBqQegaIAFBIGoQESABQcAAahAVCwunAgIBfwF/IABBiBsQIyADECIgAiEEAkADQCAEQQFrIQQgASAEai0AACEFIAMgAxAkIAVBgAFPBEAgBUGAAWshBUGIGyADIAMQJQsgAyADECQgBUHAAE8EQCAFQcAAayEFQYgbIAMgAxAlCyADIAMQJCAFQSBPBEAgBUEgayEFQYgbIAMgAxAlCyADIAMQJCAFQRBPBEAgBUEQayEFQYgbIAMgAxAlCyADIAMQJCAFQQhPBEAgBUEIayEFQYgbIAMgAxAlCyADIAMQJCAFQQRPBEAgBUEEayEFQYgbIAMgAxAlCyADIAMQJCAFQQJPBEAgBUECayEFQYgbIAMgAxAlCyADIAMQJCAFQQFPBEAgBUEBayEFQYgbIAMgAxAlCyAERQ0BDAALCwsrAgF/AX8gAEEFdkECdCEBQQEgAEEfcXQhAiABIAEoAujbASACcjYC6NsBCyQCAX8BfyAAQQV2QQJ0IQFBASAAQR9xdCECIAEoAujbASACcQugAQQBfwF/AX8B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wClHsdZZIgBB6IYFC4ACAAAAAgAEBAYACAgKCAwMDAAQEBIQFBQUEBgYGBgYGBwAICAiICQkJCAoKCgoKCgsIDAwMDAwMDQwMDA4MDg4OABAQEJAREREQEhISEhISExAUFBQUFBQVFBQUFhQWFhYQGBgYGBgYGRgYGBoYGhoaGBgYHBgcHBwYHBwcHBwcHgAgICCgISEhICIiIiIiIiMgJCQkJCQkJSQkJCYkJiYmICgoKCgoKCkoKCgqKCoqKigoKCwoLCwsKCwsLCwsLC4gMDAwMDAwMTAwMDIwMjIyMDAwNDA0NDQwNDQ0NDQ0NjAwMDgwODg4MDg4ODg4ODowODg4ODg4PDg4ODw4PDw8ABB6IgFC4ACAAAAAQABAgEAAQIBBAECAwABAgEEAQIDCAECAwQFBgMAAQIBBAECAwgBAgMEBQYDEAECAwQFBgMICQoDDAUGBwABAgEEAQIDCAECAwQFBgMQAQIDBAUGAwgJCgMMBQYHIAECAwQFBgMICQoDDAUGBxAREgMUBQYHGAkKCwwNDgcAAQIBBAECAwgBAgMEBQYDEAECAwQFBgMICQoDDAUGByABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HQAECAwQFBgMICQoDDAUGBxAREgMUBQYHGAkKCwwNDgcgISIDJAUGBygJCgsMDQ4HMBESExQVFgcYGRoLHA0ODw==", "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, domainSize);
  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. /* Debug code to print the result of h
  1768. for (let i=0; i<domainSize; i++) {
  1769. const a = this.bin2int(h.slice(i*32, i*32+32));
  1770. console.log(i + " -> " + a.toString());
  1771. }
  1772. */
  1773. return this.g1_multiexp(h, pointsHExps);
  1774. });
  1775. const pA = this.g1_multiexp(signals.slice(0), pointsA);
  1776. const pB1 = this.g1_multiexp(signals.slice(0), pointsB1);
  1777. const pB2 = this.g2_multiexp(signals.slice(0), pointsB2);
  1778. const pC = this.g1_multiexp(signals.slice((nPublic+1)*32), pointsC);
  1779. const res = await Promise.all([pA, pB1, pB2, pC, pH]);
  1780. const pi_a = this.alloc(96);
  1781. const pi_b = this.alloc(192);
  1782. const pi_c = this.alloc(96);
  1783. const pib1 = this.alloc(96);
  1784. this.putBin(pi_a, res[0]);
  1785. this.putBin(pib1, res[1]);
  1786. this.putBin(pi_b, res[2]);
  1787. this.putBin(pi_c, res[3]);
  1788. const pAlfa1 = this.loadPoint1(alfa1);
  1789. const pBeta1 = this.loadPoint1(beta1);
  1790. const pDelta1 = this.loadPoint1(delta1);
  1791. const pBeta2 = this.loadPoint2(beta2);
  1792. const pDelta2 = this.loadPoint2(delta2);
  1793. let rnd = new Uint32Array(8);
  1794. const aux1 = this.alloc(96);
  1795. const aux2 = this.alloc(192);
  1796. const pr = this.alloc(32);
  1797. const ps = this.alloc(32);
  1798. if (inBrowser) {
  1799. window.crypto.getRandomValues(rnd);
  1800. this.putBin(pr, rnd);
  1801. window.crypto.getRandomValues(rnd);
  1802. this.putBin(ps, rnd);
  1803. } else {
  1804. const br = NodeCrypto.randomBytes(32);
  1805. this.putBin(pr, br);
  1806. const bs = NodeCrypto.randomBytes(32);
  1807. this.putBin(ps, bs);
  1808. }
  1809. /// Uncoment it to debug and check it works
  1810. // this.instance.exports.f1m_zero(pr);
  1811. // this.instance.exports.f1m_zero(ps);
  1812. // pi_a = pi_a + Alfa1 + r*Delta1
  1813. this.instance.exports.g1_add(pAlfa1, pi_a, pi_a);
  1814. this.instance.exports.g1_timesScalar(pDelta1, pr, 32, aux1);
  1815. this.instance.exports.g1_add(aux1, pi_a, pi_a);
  1816. // pi_b = pi_b + Beta2 + s*Delta2
  1817. this.instance.exports.g2_add(pBeta2, pi_b, pi_b);
  1818. this.instance.exports.g2_timesScalar(pDelta2, ps, 32, aux2);
  1819. this.instance.exports.g2_add(aux2, pi_b, pi_b);
  1820. // pib1 = pib1 + Beta1 + s*Delta1
  1821. this.instance.exports.g1_add(pBeta1, pib1, pib1);
  1822. this.instance.exports.g1_timesScalar(pDelta1, ps, 32, aux1);
  1823. this.instance.exports.g1_add(aux1, pib1, pib1);
  1824. // pi_c = pi_c + pH
  1825. this.putBin(aux1, res[4]);
  1826. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1827. // pi_c = pi_c + s*pi_a
  1828. this.instance.exports.g1_timesScalar(pi_a, ps, 32, aux1);
  1829. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1830. // pi_c = pi_c + r*pib1
  1831. this.instance.exports.g1_timesScalar(pib1, pr, 32, aux1);
  1832. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1833. // pi_c = pi_c - r*s*delta1
  1834. const prs = this.alloc(64);
  1835. this.instance.exports.int_mul(pr, ps, prs);
  1836. this.instance.exports.g1_timesScalar(pDelta1, prs, 64, aux1);
  1837. this.instance.exports.g1_neg(aux1, aux1);
  1838. this.instance.exports.g1_add(aux1, pi_c, pi_c);
  1839. this.instance.exports.g1_affine(pi_a, pi_a);
  1840. this.instance.exports.g2_affine(pi_b, pi_b);
  1841. this.instance.exports.g1_affine(pi_c, pi_c);
  1842. this.instance.exports.g1_fromMontgomery(pi_a, pi_a);
  1843. this.instance.exports.g2_fromMontgomery(pi_b, pi_b);
  1844. this.instance.exports.g1_fromMontgomery(pi_c, pi_c);
  1845. return {
  1846. pi_a: this.bin2g1(this.getBin(pi_a, 96)),
  1847. pi_b: this.bin2g2(this.getBin(pi_b, 192)),
  1848. pi_c: this.bin2g1(this.getBin(pi_c, 96)),
  1849. };
  1850. }
  1851. }
  1852. module.exports = build;
  1853. }).call(this,require('_process'))
  1854. },{"../build/groth16_wasm.js":1,"_process":12,"assert":5,"big-integer":3,"crypto":undefined,"worker_threads":undefined}],5:[function(require,module,exports){
  1855. (function (global){
  1856. 'use strict';
  1857. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  1858. // original notice:
  1859. /*!
  1860. * The buffer module from node.js, for the browser.
  1861. *
  1862. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  1863. * @license MIT
  1864. */
  1865. function compare(a, b) {
  1866. if (a === b) {
  1867. return 0;
  1868. }
  1869. var x = a.length;
  1870. var y = b.length;
  1871. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  1872. if (a[i] !== b[i]) {
  1873. x = a[i];
  1874. y = b[i];
  1875. break;
  1876. }
  1877. }
  1878. if (x < y) {
  1879. return -1;
  1880. }
  1881. if (y < x) {
  1882. return 1;
  1883. }
  1884. return 0;
  1885. }
  1886. function isBuffer(b) {
  1887. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  1888. return global.Buffer.isBuffer(b);
  1889. }
  1890. return !!(b != null && b._isBuffer);
  1891. }
  1892. // based on node assert, original notice:
  1893. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  1894. //
  1895. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  1896. //
  1897. // Originally from narwhal.js (http://narwhaljs.org)
  1898. // Copyright (c) 2009 Thomas Robinson <280north.com>
  1899. //
  1900. // Permission is hereby granted, free of charge, to any person obtaining a copy
  1901. // of this software and associated documentation files (the 'Software'), to
  1902. // deal in the Software without restriction, including without limitation the
  1903. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  1904. // sell copies of the Software, and to permit persons to whom the Software is
  1905. // furnished to do so, subject to the following conditions:
  1906. //
  1907. // The above copyright notice and this permission notice shall be included in
  1908. // all copies or substantial portions of the Software.
  1909. //
  1910. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1911. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1912. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1913. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  1914. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  1915. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  1916. var util = require('util/');
  1917. var hasOwn = Object.prototype.hasOwnProperty;
  1918. var pSlice = Array.prototype.slice;
  1919. var functionsHaveNames = (function () {
  1920. return function foo() {}.name === 'foo';
  1921. }());
  1922. function pToString (obj) {
  1923. return Object.prototype.toString.call(obj);
  1924. }
  1925. function isView(arrbuf) {
  1926. if (isBuffer(arrbuf)) {
  1927. return false;
  1928. }
  1929. if (typeof global.ArrayBuffer !== 'function') {
  1930. return false;
  1931. }
  1932. if (typeof ArrayBuffer.isView === 'function') {
  1933. return ArrayBuffer.isView(arrbuf);
  1934. }
  1935. if (!arrbuf) {
  1936. return false;
  1937. }
  1938. if (arrbuf instanceof DataView) {
  1939. return true;
  1940. }
  1941. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  1942. return true;
  1943. }
  1944. return false;
  1945. }
  1946. // 1. The assert module provides functions that throw
  1947. // AssertionError's when particular conditions are not met. The
  1948. // assert module must conform to the following interface.
  1949. var assert = module.exports = ok;
  1950. // 2. The AssertionError is defined in assert.
  1951. // new assert.AssertionError({ message: message,
  1952. // actual: actual,
  1953. // expected: expected })
  1954. var regex = /\s*function\s+([^\(\s]*)\s*/;
  1955. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  1956. function getName(func) {
  1957. if (!util.isFunction(func)) {
  1958. return;
  1959. }
  1960. if (functionsHaveNames) {
  1961. return func.name;
  1962. }
  1963. var str = func.toString();
  1964. var match = str.match(regex);
  1965. return match && match[1];
  1966. }
  1967. assert.AssertionError = function AssertionError(options) {
  1968. this.name = 'AssertionError';
  1969. this.actual = options.actual;
  1970. this.expected = options.expected;
  1971. this.operator = options.operator;
  1972. if (options.message) {
  1973. this.message = options.message;
  1974. this.generatedMessage = false;
  1975. } else {
  1976. this.message = getMessage(this);
  1977. this.generatedMessage = true;
  1978. }
  1979. var stackStartFunction = options.stackStartFunction || fail;
  1980. if (Error.captureStackTrace) {
  1981. Error.captureStackTrace(this, stackStartFunction);
  1982. } else {
  1983. // non v8 browsers so we can have a stacktrace
  1984. var err = new Error();
  1985. if (err.stack) {
  1986. var out = err.stack;
  1987. // try to strip useless frames
  1988. var fn_name = getName(stackStartFunction);
  1989. var idx = out.indexOf('\n' + fn_name);
  1990. if (idx >= 0) {
  1991. // once we have located the function frame
  1992. // we need to strip out everything before it (and its line)
  1993. var next_line = out.indexOf('\n', idx + 1);
  1994. out = out.substring(next_line + 1);
  1995. }
  1996. this.stack = out;
  1997. }
  1998. }
  1999. };
  2000. // assert.AssertionError instanceof Error
  2001. util.inherits(assert.AssertionError, Error);
  2002. function truncate(s, n) {
  2003. if (typeof s === 'string') {
  2004. return s.length < n ? s : s.slice(0, n);
  2005. } else {
  2006. return s;
  2007. }
  2008. }
  2009. function inspect(something) {
  2010. if (functionsHaveNames || !util.isFunction(something)) {
  2011. return util.inspect(something);
  2012. }
  2013. var rawname = getName(something);
  2014. var name = rawname ? ': ' + rawname : '';
  2015. return '[Function' + name + ']';
  2016. }
  2017. function getMessage(self) {
  2018. return truncate(inspect(self.actual), 128) + ' ' +
  2019. self.operator + ' ' +
  2020. truncate(inspect(self.expected), 128);
  2021. }
  2022. // At present only the three keys mentioned above are used and
  2023. // understood by the spec. Implementations or sub modules can pass
  2024. // other keys to the AssertionError's constructor - they will be
  2025. // ignored.
  2026. // 3. All of the following functions must throw an AssertionError
  2027. // when a corresponding condition is not met, with a message that
  2028. // may be undefined if not provided. All assertion methods provide
  2029. // both the actual and expected values to the assertion error for
  2030. // display purposes.
  2031. function fail(actual, expected, message, operator, stackStartFunction) {
  2032. throw new assert.AssertionError({
  2033. message: message,
  2034. actual: actual,
  2035. expected: expected,
  2036. operator: operator,
  2037. stackStartFunction: stackStartFunction
  2038. });
  2039. }
  2040. // EXTENSION! allows for well behaved errors defined elsewhere.
  2041. assert.fail = fail;
  2042. // 4. Pure assertion tests whether a value is truthy, as determined
  2043. // by !!guard.
  2044. // assert.ok(guard, message_opt);
  2045. // This statement is equivalent to assert.equal(true, !!guard,
  2046. // message_opt);. To test strictly for the value true, use
  2047. // assert.strictEqual(true, guard, message_opt);.
  2048. function ok(value, message) {
  2049. if (!value) fail(value, true, message, '==', assert.ok);
  2050. }
  2051. assert.ok = ok;
  2052. // 5. The equality assertion tests shallow, coercive equality with
  2053. // ==.
  2054. // assert.equal(actual, expected, message_opt);
  2055. assert.equal = function equal(actual, expected, message) {
  2056. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  2057. };
  2058. // 6. The non-equality assertion tests for whether two objects are not equal
  2059. // with != assert.notEqual(actual, expected, message_opt);
  2060. assert.notEqual = function notEqual(actual, expected, message) {
  2061. if (actual == expected) {
  2062. fail(actual, expected, message, '!=', assert.notEqual);
  2063. }
  2064. };
  2065. // 7. The equivalence assertion tests a deep equality relation.
  2066. // assert.deepEqual(actual, expected, message_opt);
  2067. assert.deepEqual = function deepEqual(actual, expected, message) {
  2068. if (!_deepEqual(actual, expected, false)) {
  2069. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  2070. }
  2071. };
  2072. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  2073. if (!_deepEqual(actual, expected, true)) {
  2074. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  2075. }
  2076. };
  2077. function _deepEqual(actual, expected, strict, memos) {
  2078. // 7.1. All identical values are equivalent, as determined by ===.
  2079. if (actual === expected) {
  2080. return true;
  2081. } else if (isBuffer(actual) && isBuffer(expected)) {
  2082. return compare(actual, expected) === 0;
  2083. // 7.2. If the expected value is a Date object, the actual value is
  2084. // equivalent if it is also a Date object that refers to the same time.
  2085. } else if (util.isDate(actual) && util.isDate(expected)) {
  2086. return actual.getTime() === expected.getTime();
  2087. // 7.3 If the expected value is a RegExp object, the actual value is
  2088. // equivalent if it is also a RegExp object with the same source and
  2089. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  2090. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  2091. return actual.source === expected.source &&
  2092. actual.global === expected.global &&
  2093. actual.multiline === expected.multiline &&
  2094. actual.lastIndex === expected.lastIndex &&
  2095. actual.ignoreCase === expected.ignoreCase;
  2096. // 7.4. Other pairs that do not both pass typeof value == 'object',
  2097. // equivalence is determined by ==.
  2098. } else if ((actual === null || typeof actual !== 'object') &&
  2099. (expected === null || typeof expected !== 'object')) {
  2100. return strict ? actual === expected : actual == expected;
  2101. // If both values are instances of typed arrays, wrap their underlying
  2102. // ArrayBuffers in a Buffer each to increase performance
  2103. // This optimization requires the arrays to have the same type as checked by
  2104. // Object.prototype.toString (aka pToString). Never perform binary
  2105. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  2106. // bit patterns are not identical.
  2107. } else if (isView(actual) && isView(expected) &&
  2108. pToString(actual) === pToString(expected) &&
  2109. !(actual instanceof Float32Array ||
  2110. actual instanceof Float64Array)) {
  2111. return compare(new Uint8Array(actual.buffer),
  2112. new Uint8Array(expected.buffer)) === 0;
  2113. // 7.5 For all other Object pairs, including Array objects, equivalence is
  2114. // determined by having the same number of owned properties (as verified
  2115. // with Object.prototype.hasOwnProperty.call), the same set of keys
  2116. // (although not necessarily the same order), equivalent values for every
  2117. // corresponding key, and an identical 'prototype' property. Note: this
  2118. // accounts for both named and indexed properties on Arrays.
  2119. } else if (isBuffer(actual) !== isBuffer(expected)) {
  2120. return false;
  2121. } else {
  2122. memos = memos || {actual: [], expected: []};
  2123. var actualIndex = memos.actual.indexOf(actual);
  2124. if (actualIndex !== -1) {
  2125. if (actualIndex === memos.expected.indexOf(expected)) {
  2126. return true;
  2127. }
  2128. }
  2129. memos.actual.push(actual);
  2130. memos.expected.push(expected);
  2131. return objEquiv(actual, expected, strict, memos);
  2132. }
  2133. }
  2134. function isArguments(object) {
  2135. return Object.prototype.toString.call(object) == '[object Arguments]';
  2136. }
  2137. function objEquiv(a, b, strict, actualVisitedObjects) {
  2138. if (a === null || a === undefined || b === null || b === undefined)
  2139. return false;
  2140. // if one is a primitive, the other must be same
  2141. if (util.isPrimitive(a) || util.isPrimitive(b))
  2142. return a === b;
  2143. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  2144. return false;
  2145. var aIsArgs = isArguments(a);
  2146. var bIsArgs = isArguments(b);
  2147. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  2148. return false;
  2149. if (aIsArgs) {
  2150. a = pSlice.call(a);
  2151. b = pSlice.call(b);
  2152. return _deepEqual(a, b, strict);
  2153. }
  2154. var ka = objectKeys(a);
  2155. var kb = objectKeys(b);
  2156. var key, i;
  2157. // having the same number of owned properties (keys incorporates
  2158. // hasOwnProperty)
  2159. if (ka.length !== kb.length)
  2160. return false;
  2161. //the same set of keys (although not necessarily the same order),
  2162. ka.sort();
  2163. kb.sort();
  2164. //~~~cheap key test
  2165. for (i = ka.length - 1; i >= 0; i--) {
  2166. if (ka[i] !== kb[i])
  2167. return false;
  2168. }
  2169. //equivalent values for every corresponding key, and
  2170. //~~~possibly expensive deep test
  2171. for (i = ka.length - 1; i >= 0; i--) {
  2172. key = ka[i];
  2173. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  2174. return false;
  2175. }
  2176. return true;
  2177. }
  2178. // 8. The non-equivalence assertion tests for any deep inequality.
  2179. // assert.notDeepEqual(actual, expected, message_opt);
  2180. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  2181. if (_deepEqual(actual, expected, false)) {
  2182. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  2183. }
  2184. };
  2185. assert.notDeepStrictEqual = notDeepStrictEqual;
  2186. function notDeepStrictEqual(actual, expected, message) {
  2187. if (_deepEqual(actual, expected, true)) {
  2188. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  2189. }
  2190. }
  2191. // 9. The strict equality assertion tests strict equality, as determined by ===.
  2192. // assert.strictEqual(actual, expected, message_opt);
  2193. assert.strictEqual = function strictEqual(actual, expected, message) {
  2194. if (actual !== expected) {
  2195. fail(actual, expected, message, '===', assert.strictEqual);
  2196. }
  2197. };
  2198. // 10. The strict non-equality assertion tests for strict inequality, as
  2199. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  2200. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  2201. if (actual === expected) {
  2202. fail(actual, expected, message, '!==', assert.notStrictEqual);
  2203. }
  2204. };
  2205. function expectedException(actual, expected) {
  2206. if (!actual || !expected) {
  2207. return false;
  2208. }
  2209. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  2210. return expected.test(actual);
  2211. }
  2212. try {
  2213. if (actual instanceof expected) {
  2214. return true;
  2215. }
  2216. } catch (e) {
  2217. // Ignore. The instanceof check doesn't work for arrow functions.
  2218. }
  2219. if (Error.isPrototypeOf(expected)) {
  2220. return false;
  2221. }
  2222. return expected.call({}, actual) === true;
  2223. }
  2224. function _tryBlock(block) {
  2225. var error;
  2226. try {
  2227. block();
  2228. } catch (e) {
  2229. error = e;
  2230. }
  2231. return error;
  2232. }
  2233. function _throws(shouldThrow, block, expected, message) {
  2234. var actual;
  2235. if (typeof block !== 'function') {
  2236. throw new TypeError('"block" argument must be a function');
  2237. }
  2238. if (typeof expected === 'string') {
  2239. message = expected;
  2240. expected = null;
  2241. }
  2242. actual = _tryBlock(block);
  2243. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  2244. (message ? ' ' + message : '.');
  2245. if (shouldThrow && !actual) {
  2246. fail(actual, expected, 'Missing expected exception' + message);
  2247. }
  2248. var userProvidedMessage = typeof message === 'string';
  2249. var isUnwantedException = !shouldThrow && util.isError(actual);
  2250. var isUnexpectedException = !shouldThrow && actual && !expected;
  2251. if ((isUnwantedException &&
  2252. userProvidedMessage &&
  2253. expectedException(actual, expected)) ||
  2254. isUnexpectedException) {
  2255. fail(actual, expected, 'Got unwanted exception' + message);
  2256. }
  2257. if ((shouldThrow && actual && expected &&
  2258. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  2259. throw actual;
  2260. }
  2261. }
  2262. // 11. Expected to throw an error:
  2263. // assert.throws(block, Error_opt, message_opt);
  2264. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  2265. _throws(true, block, error, message);
  2266. };
  2267. // EXTENSION! This is annoying to write outside this module.
  2268. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  2269. _throws(false, block, error, message);
  2270. };
  2271. assert.ifError = function(err) { if (err) throw err; };
  2272. var objectKeys = Object.keys || function (obj) {
  2273. var keys = [];
  2274. for (var key in obj) {
  2275. if (hasOwn.call(obj, key)) keys.push(key);
  2276. }
  2277. return keys;
  2278. };
  2279. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2280. },{"util/":8}],6:[function(require,module,exports){
  2281. if (typeof Object.create === 'function') {
  2282. // implementation from standard node.js 'util' module
  2283. module.exports = function inherits(ctor, superCtor) {
  2284. ctor.super_ = superCtor
  2285. ctor.prototype = Object.create(superCtor.prototype, {
  2286. constructor: {
  2287. value: ctor,
  2288. enumerable: false,
  2289. writable: true,
  2290. configurable: true
  2291. }
  2292. });
  2293. };
  2294. } else {
  2295. // old school shim for old browsers
  2296. module.exports = function inherits(ctor, superCtor) {
  2297. ctor.super_ = superCtor
  2298. var TempCtor = function () {}
  2299. TempCtor.prototype = superCtor.prototype
  2300. ctor.prototype = new TempCtor()
  2301. ctor.prototype.constructor = ctor
  2302. }
  2303. }
  2304. },{}],7:[function(require,module,exports){
  2305. module.exports = function isBuffer(arg) {
  2306. return arg && typeof arg === 'object'
  2307. && typeof arg.copy === 'function'
  2308. && typeof arg.fill === 'function'
  2309. && typeof arg.readUInt8 === 'function';
  2310. }
  2311. },{}],8:[function(require,module,exports){
  2312. (function (process,global){
  2313. // Copyright Joyent, Inc. and other Node contributors.
  2314. //
  2315. // Permission is hereby granted, free of charge, to any person obtaining a
  2316. // copy of this software and associated documentation files (the
  2317. // "Software"), to deal in the Software without restriction, including
  2318. // without limitation the rights to use, copy, modify, merge, publish,
  2319. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2320. // persons to whom the Software is furnished to do so, subject to the
  2321. // following conditions:
  2322. //
  2323. // The above copyright notice and this permission notice shall be included
  2324. // in all copies or substantial portions of the Software.
  2325. //
  2326. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2327. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2328. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2329. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2330. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2331. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2332. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2333. var formatRegExp = /%[sdj%]/g;
  2334. exports.format = function(f) {
  2335. if (!isString(f)) {
  2336. var objects = [];
  2337. for (var i = 0; i < arguments.length; i++) {
  2338. objects.push(inspect(arguments[i]));
  2339. }
  2340. return objects.join(' ');
  2341. }
  2342. var i = 1;
  2343. var args = arguments;
  2344. var len = args.length;
  2345. var str = String(f).replace(formatRegExp, function(x) {
  2346. if (x === '%%') return '%';
  2347. if (i >= len) return x;
  2348. switch (x) {
  2349. case '%s': return String(args[i++]);
  2350. case '%d': return Number(args[i++]);
  2351. case '%j':
  2352. try {
  2353. return JSON.stringify(args[i++]);
  2354. } catch (_) {
  2355. return '[Circular]';
  2356. }
  2357. default:
  2358. return x;
  2359. }
  2360. });
  2361. for (var x = args[i]; i < len; x = args[++i]) {
  2362. if (isNull(x) || !isObject(x)) {
  2363. str += ' ' + x;
  2364. } else {
  2365. str += ' ' + inspect(x);
  2366. }
  2367. }
  2368. return str;
  2369. };
  2370. // Mark that a method should not be used.
  2371. // Returns a modified function which warns once by default.
  2372. // If --no-deprecation is set, then it is a no-op.
  2373. exports.deprecate = function(fn, msg) {
  2374. // Allow for deprecating things in the process of starting up.
  2375. if (isUndefined(global.process)) {
  2376. return function() {
  2377. return exports.deprecate(fn, msg).apply(this, arguments);
  2378. };
  2379. }
  2380. if (process.noDeprecation === true) {
  2381. return fn;
  2382. }
  2383. var warned = false;
  2384. function deprecated() {
  2385. if (!warned) {
  2386. if (process.throwDeprecation) {
  2387. throw new Error(msg);
  2388. } else if (process.traceDeprecation) {
  2389. console.trace(msg);
  2390. } else {
  2391. console.error(msg);
  2392. }
  2393. warned = true;
  2394. }
  2395. return fn.apply(this, arguments);
  2396. }
  2397. return deprecated;
  2398. };
  2399. var debugs = {};
  2400. var debugEnviron;
  2401. exports.debuglog = function(set) {
  2402. if (isUndefined(debugEnviron))
  2403. debugEnviron = process.env.NODE_DEBUG || '';
  2404. set = set.toUpperCase();
  2405. if (!debugs[set]) {
  2406. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  2407. var pid = process.pid;
  2408. debugs[set] = function() {
  2409. var msg = exports.format.apply(exports, arguments);
  2410. console.error('%s %d: %s', set, pid, msg);
  2411. };
  2412. } else {
  2413. debugs[set] = function() {};
  2414. }
  2415. }
  2416. return debugs[set];
  2417. };
  2418. /**
  2419. * Echos the value of a value. Trys to print the value out
  2420. * in the best way possible given the different types.
  2421. *
  2422. * @param {Object} obj The object to print out.
  2423. * @param {Object} opts Optional options object that alters the output.
  2424. */
  2425. /* legacy: obj, showHidden, depth, colors*/
  2426. function inspect(obj, opts) {
  2427. // default options
  2428. var ctx = {
  2429. seen: [],
  2430. stylize: stylizeNoColor
  2431. };
  2432. // legacy...
  2433. if (arguments.length >= 3) ctx.depth = arguments[2];
  2434. if (arguments.length >= 4) ctx.colors = arguments[3];
  2435. if (isBoolean(opts)) {
  2436. // legacy...
  2437. ctx.showHidden = opts;
  2438. } else if (opts) {
  2439. // got an "options" object
  2440. exports._extend(ctx, opts);
  2441. }
  2442. // set default options
  2443. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  2444. if (isUndefined(ctx.depth)) ctx.depth = 2;
  2445. if (isUndefined(ctx.colors)) ctx.colors = false;
  2446. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  2447. if (ctx.colors) ctx.stylize = stylizeWithColor;
  2448. return formatValue(ctx, obj, ctx.depth);
  2449. }
  2450. exports.inspect = inspect;
  2451. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  2452. inspect.colors = {
  2453. 'bold' : [1, 22],
  2454. 'italic' : [3, 23],
  2455. 'underline' : [4, 24],
  2456. 'inverse' : [7, 27],
  2457. 'white' : [37, 39],
  2458. 'grey' : [90, 39],
  2459. 'black' : [30, 39],
  2460. 'blue' : [34, 39],
  2461. 'cyan' : [36, 39],
  2462. 'green' : [32, 39],
  2463. 'magenta' : [35, 39],
  2464. 'red' : [31, 39],
  2465. 'yellow' : [33, 39]
  2466. };
  2467. // Don't use 'blue' not visible on cmd.exe
  2468. inspect.styles = {
  2469. 'special': 'cyan',
  2470. 'number': 'yellow',
  2471. 'boolean': 'yellow',
  2472. 'undefined': 'grey',
  2473. 'null': 'bold',
  2474. 'string': 'green',
  2475. 'date': 'magenta',
  2476. // "name": intentionally not styling
  2477. 'regexp': 'red'
  2478. };
  2479. function stylizeWithColor(str, styleType) {
  2480. var style = inspect.styles[styleType];
  2481. if (style) {
  2482. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  2483. '\u001b[' + inspect.colors[style][1] + 'm';
  2484. } else {
  2485. return str;
  2486. }
  2487. }
  2488. function stylizeNoColor(str, styleType) {
  2489. return str;
  2490. }
  2491. function arrayToHash(array) {
  2492. var hash = {};
  2493. array.forEach(function(val, idx) {
  2494. hash[val] = true;
  2495. });
  2496. return hash;
  2497. }
  2498. function formatValue(ctx, value, recurseTimes) {
  2499. // Provide a hook for user-specified inspect functions.
  2500. // Check that value is an object with an inspect function on it
  2501. if (ctx.customInspect &&
  2502. value &&
  2503. isFunction(value.inspect) &&
  2504. // Filter out the util module, it's inspect function is special
  2505. value.inspect !== exports.inspect &&
  2506. // Also filter out any prototype objects using the circular check.
  2507. !(value.constructor && value.constructor.prototype === value)) {
  2508. var ret = value.inspect(recurseTimes, ctx);
  2509. if (!isString(ret)) {
  2510. ret = formatValue(ctx, ret, recurseTimes);
  2511. }
  2512. return ret;
  2513. }
  2514. // Primitive types cannot have properties
  2515. var primitive = formatPrimitive(ctx, value);
  2516. if (primitive) {
  2517. return primitive;
  2518. }
  2519. // Look up the keys of the object.
  2520. var keys = Object.keys(value);
  2521. var visibleKeys = arrayToHash(keys);
  2522. if (ctx.showHidden) {
  2523. keys = Object.getOwnPropertyNames(value);
  2524. }
  2525. // IE doesn't make error fields non-enumerable
  2526. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  2527. if (isError(value)
  2528. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  2529. return formatError(value);
  2530. }
  2531. // Some type of object without properties can be shortcutted.
  2532. if (keys.length === 0) {
  2533. if (isFunction(value)) {
  2534. var name = value.name ? ': ' + value.name : '';
  2535. return ctx.stylize('[Function' + name + ']', 'special');
  2536. }
  2537. if (isRegExp(value)) {
  2538. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2539. }
  2540. if (isDate(value)) {
  2541. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  2542. }
  2543. if (isError(value)) {
  2544. return formatError(value);
  2545. }
  2546. }
  2547. var base = '', array = false, braces = ['{', '}'];
  2548. // Make Array say that they are Array
  2549. if (isArray(value)) {
  2550. array = true;
  2551. braces = ['[', ']'];
  2552. }
  2553. // Make functions say that they are functions
  2554. if (isFunction(value)) {
  2555. var n = value.name ? ': ' + value.name : '';
  2556. base = ' [Function' + n + ']';
  2557. }
  2558. // Make RegExps say that they are RegExps
  2559. if (isRegExp(value)) {
  2560. base = ' ' + RegExp.prototype.toString.call(value);
  2561. }
  2562. // Make dates with properties first say the date
  2563. if (isDate(value)) {
  2564. base = ' ' + Date.prototype.toUTCString.call(value);
  2565. }
  2566. // Make error with message first say the error
  2567. if (isError(value)) {
  2568. base = ' ' + formatError(value);
  2569. }
  2570. if (keys.length === 0 && (!array || value.length == 0)) {
  2571. return braces[0] + base + braces[1];
  2572. }
  2573. if (recurseTimes < 0) {
  2574. if (isRegExp(value)) {
  2575. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2576. } else {
  2577. return ctx.stylize('[Object]', 'special');
  2578. }
  2579. }
  2580. ctx.seen.push(value);
  2581. var output;
  2582. if (array) {
  2583. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  2584. } else {
  2585. output = keys.map(function(key) {
  2586. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  2587. });
  2588. }
  2589. ctx.seen.pop();
  2590. return reduceToSingleString(output, base, braces);
  2591. }
  2592. function formatPrimitive(ctx, value) {
  2593. if (isUndefined(value))
  2594. return ctx.stylize('undefined', 'undefined');
  2595. if (isString(value)) {
  2596. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  2597. .replace(/'/g, "\\'")
  2598. .replace(/\\"/g, '"') + '\'';
  2599. return ctx.stylize(simple, 'string');
  2600. }
  2601. if (isNumber(value))
  2602. return ctx.stylize('' + value, 'number');
  2603. if (isBoolean(value))
  2604. return ctx.stylize('' + value, 'boolean');
  2605. // For some reason typeof null is "object", so special case here.
  2606. if (isNull(value))
  2607. return ctx.stylize('null', 'null');
  2608. }
  2609. function formatError(value) {
  2610. return '[' + Error.prototype.toString.call(value) + ']';
  2611. }
  2612. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  2613. var output = [];
  2614. for (var i = 0, l = value.length; i < l; ++i) {
  2615. if (hasOwnProperty(value, String(i))) {
  2616. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2617. String(i), true));
  2618. } else {
  2619. output.push('');
  2620. }
  2621. }
  2622. keys.forEach(function(key) {
  2623. if (!key.match(/^\d+$/)) {
  2624. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2625. key, true));
  2626. }
  2627. });
  2628. return output;
  2629. }
  2630. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  2631. var name, str, desc;
  2632. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  2633. if (desc.get) {
  2634. if (desc.set) {
  2635. str = ctx.stylize('[Getter/Setter]', 'special');
  2636. } else {
  2637. str = ctx.stylize('[Getter]', 'special');
  2638. }
  2639. } else {
  2640. if (desc.set) {
  2641. str = ctx.stylize('[Setter]', 'special');
  2642. }
  2643. }
  2644. if (!hasOwnProperty(visibleKeys, key)) {
  2645. name = '[' + key + ']';
  2646. }
  2647. if (!str) {
  2648. if (ctx.seen.indexOf(desc.value) < 0) {
  2649. if (isNull(recurseTimes)) {
  2650. str = formatValue(ctx, desc.value, null);
  2651. } else {
  2652. str = formatValue(ctx, desc.value, recurseTimes - 1);
  2653. }
  2654. if (str.indexOf('\n') > -1) {
  2655. if (array) {
  2656. str = str.split('\n').map(function(line) {
  2657. return ' ' + line;
  2658. }).join('\n').substr(2);
  2659. } else {
  2660. str = '\n' + str.split('\n').map(function(line) {
  2661. return ' ' + line;
  2662. }).join('\n');
  2663. }
  2664. }
  2665. } else {
  2666. str = ctx.stylize('[Circular]', 'special');
  2667. }
  2668. }
  2669. if (isUndefined(name)) {
  2670. if (array && key.match(/^\d+$/)) {
  2671. return str;
  2672. }
  2673. name = JSON.stringify('' + key);
  2674. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  2675. name = name.substr(1, name.length - 2);
  2676. name = ctx.stylize(name, 'name');
  2677. } else {
  2678. name = name.replace(/'/g, "\\'")
  2679. .replace(/\\"/g, '"')
  2680. .replace(/(^"|"$)/g, "'");
  2681. name = ctx.stylize(name, 'string');
  2682. }
  2683. }
  2684. return name + ': ' + str;
  2685. }
  2686. function reduceToSingleString(output, base, braces) {
  2687. var numLinesEst = 0;
  2688. var length = output.reduce(function(prev, cur) {
  2689. numLinesEst++;
  2690. if (cur.indexOf('\n') >= 0) numLinesEst++;
  2691. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  2692. }, 0);
  2693. if (length > 60) {
  2694. return braces[0] +
  2695. (base === '' ? '' : base + '\n ') +
  2696. ' ' +
  2697. output.join(',\n ') +
  2698. ' ' +
  2699. braces[1];
  2700. }
  2701. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  2702. }
  2703. // NOTE: These type checking functions intentionally don't use `instanceof`
  2704. // because it is fragile and can be easily faked with `Object.create()`.
  2705. function isArray(ar) {
  2706. return Array.isArray(ar);
  2707. }
  2708. exports.isArray = isArray;
  2709. function isBoolean(arg) {
  2710. return typeof arg === 'boolean';
  2711. }
  2712. exports.isBoolean = isBoolean;
  2713. function isNull(arg) {
  2714. return arg === null;
  2715. }
  2716. exports.isNull = isNull;
  2717. function isNullOrUndefined(arg) {
  2718. return arg == null;
  2719. }
  2720. exports.isNullOrUndefined = isNullOrUndefined;
  2721. function isNumber(arg) {
  2722. return typeof arg === 'number';
  2723. }
  2724. exports.isNumber = isNumber;
  2725. function isString(arg) {
  2726. return typeof arg === 'string';
  2727. }
  2728. exports.isString = isString;
  2729. function isSymbol(arg) {
  2730. return typeof arg === 'symbol';
  2731. }
  2732. exports.isSymbol = isSymbol;
  2733. function isUndefined(arg) {
  2734. return arg === void 0;
  2735. }
  2736. exports.isUndefined = isUndefined;
  2737. function isRegExp(re) {
  2738. return isObject(re) && objectToString(re) === '[object RegExp]';
  2739. }
  2740. exports.isRegExp = isRegExp;
  2741. function isObject(arg) {
  2742. return typeof arg === 'object' && arg !== null;
  2743. }
  2744. exports.isObject = isObject;
  2745. function isDate(d) {
  2746. return isObject(d) && objectToString(d) === '[object Date]';
  2747. }
  2748. exports.isDate = isDate;
  2749. function isError(e) {
  2750. return isObject(e) &&
  2751. (objectToString(e) === '[object Error]' || e instanceof Error);
  2752. }
  2753. exports.isError = isError;
  2754. function isFunction(arg) {
  2755. return typeof arg === 'function';
  2756. }
  2757. exports.isFunction = isFunction;
  2758. function isPrimitive(arg) {
  2759. return arg === null ||
  2760. typeof arg === 'boolean' ||
  2761. typeof arg === 'number' ||
  2762. typeof arg === 'string' ||
  2763. typeof arg === 'symbol' || // ES6 symbol
  2764. typeof arg === 'undefined';
  2765. }
  2766. exports.isPrimitive = isPrimitive;
  2767. exports.isBuffer = require('./support/isBuffer');
  2768. function objectToString(o) {
  2769. return Object.prototype.toString.call(o);
  2770. }
  2771. function pad(n) {
  2772. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  2773. }
  2774. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  2775. 'Oct', 'Nov', 'Dec'];
  2776. // 26 Feb 16:19:34
  2777. function timestamp() {
  2778. var d = new Date();
  2779. var time = [pad(d.getHours()),
  2780. pad(d.getMinutes()),
  2781. pad(d.getSeconds())].join(':');
  2782. return [d.getDate(), months[d.getMonth()], time].join(' ');
  2783. }
  2784. // log is just a thin wrapper to console.log that prepends a timestamp
  2785. exports.log = function() {
  2786. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  2787. };
  2788. /**
  2789. * Inherit the prototype methods from one constructor into another.
  2790. *
  2791. * The Function.prototype.inherits from lang.js rewritten as a standalone
  2792. * function (not on Function.prototype). NOTE: If this file is to be loaded
  2793. * during bootstrapping this function needs to be rewritten using some native
  2794. * functions as prototype setup using normal JavaScript does not work as
  2795. * expected during bootstrapping (see mirror.js in r114903).
  2796. *
  2797. * @param {function} ctor Constructor function which needs to inherit the
  2798. * prototype.
  2799. * @param {function} superCtor Constructor function to inherit prototype from.
  2800. */
  2801. exports.inherits = require('inherits');
  2802. exports._extend = function(origin, add) {
  2803. // Don't do anything if add isn't an object
  2804. if (!add || !isObject(add)) return origin;
  2805. var keys = Object.keys(add);
  2806. var i = keys.length;
  2807. while (i--) {
  2808. origin[keys[i]] = add[keys[i]];
  2809. }
  2810. return origin;
  2811. };
  2812. function hasOwnProperty(obj, prop) {
  2813. return Object.prototype.hasOwnProperty.call(obj, prop);
  2814. }
  2815. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2816. },{"./support/isBuffer":7,"_process":12,"inherits":6}],9:[function(require,module,exports){
  2817. 'use strict'
  2818. exports.byteLength = byteLength
  2819. exports.toByteArray = toByteArray
  2820. exports.fromByteArray = fromByteArray
  2821. var lookup = []
  2822. var revLookup = []
  2823. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  2824. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  2825. for (var i = 0, len = code.length; i < len; ++i) {
  2826. lookup[i] = code[i]
  2827. revLookup[code.charCodeAt(i)] = i
  2828. }
  2829. // Support decoding URL-safe base64 strings, as Node.js does.
  2830. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  2831. revLookup['-'.charCodeAt(0)] = 62
  2832. revLookup['_'.charCodeAt(0)] = 63
  2833. function getLens (b64) {
  2834. var len = b64.length
  2835. if (len % 4 > 0) {
  2836. throw new Error('Invalid string. Length must be a multiple of 4')
  2837. }
  2838. // Trim off extra bytes after placeholder bytes are found
  2839. // See: https://github.com/beatgammit/base64-js/issues/42
  2840. var validLen = b64.indexOf('=')
  2841. if (validLen === -1) validLen = len
  2842. var placeHoldersLen = validLen === len
  2843. ? 0
  2844. : 4 - (validLen % 4)
  2845. return [validLen, placeHoldersLen]
  2846. }
  2847. // base64 is 4/3 + up to two characters of the original data
  2848. function byteLength (b64) {
  2849. var lens = getLens(b64)
  2850. var validLen = lens[0]
  2851. var placeHoldersLen = lens[1]
  2852. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  2853. }
  2854. function _byteLength (b64, validLen, placeHoldersLen) {
  2855. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  2856. }
  2857. function toByteArray (b64) {
  2858. var tmp
  2859. var lens = getLens(b64)
  2860. var validLen = lens[0]
  2861. var placeHoldersLen = lens[1]
  2862. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  2863. var curByte = 0
  2864. // if there are placeholders, only get up to the last complete 4 chars
  2865. var len = placeHoldersLen > 0
  2866. ? validLen - 4
  2867. : validLen
  2868. for (var i = 0; i < len; i += 4) {
  2869. tmp =
  2870. (revLookup[b64.charCodeAt(i)] << 18) |
  2871. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  2872. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  2873. revLookup[b64.charCodeAt(i + 3)]
  2874. arr[curByte++] = (tmp >> 16) & 0xFF
  2875. arr[curByte++] = (tmp >> 8) & 0xFF
  2876. arr[curByte++] = tmp & 0xFF
  2877. }
  2878. if (placeHoldersLen === 2) {
  2879. tmp =
  2880. (revLookup[b64.charCodeAt(i)] << 2) |
  2881. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  2882. arr[curByte++] = tmp & 0xFF
  2883. }
  2884. if (placeHoldersLen === 1) {
  2885. tmp =
  2886. (revLookup[b64.charCodeAt(i)] << 10) |
  2887. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  2888. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  2889. arr[curByte++] = (tmp >> 8) & 0xFF
  2890. arr[curByte++] = tmp & 0xFF
  2891. }
  2892. return arr
  2893. }
  2894. function tripletToBase64 (num) {
  2895. return lookup[num >> 18 & 0x3F] +
  2896. lookup[num >> 12 & 0x3F] +
  2897. lookup[num >> 6 & 0x3F] +
  2898. lookup[num & 0x3F]
  2899. }
  2900. function encodeChunk (uint8, start, end) {
  2901. var tmp
  2902. var output = []
  2903. for (var i = start; i < end; i += 3) {
  2904. tmp =
  2905. ((uint8[i] << 16) & 0xFF0000) +
  2906. ((uint8[i + 1] << 8) & 0xFF00) +
  2907. (uint8[i + 2] & 0xFF)
  2908. output.push(tripletToBase64(tmp))
  2909. }
  2910. return output.join('')
  2911. }
  2912. function fromByteArray (uint8) {
  2913. var tmp
  2914. var len = uint8.length
  2915. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  2916. var parts = []
  2917. var maxChunkLength = 16383 // must be multiple of 3
  2918. // go through the array every three bytes, we'll deal with trailing stuff later
  2919. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  2920. parts.push(encodeChunk(
  2921. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  2922. ))
  2923. }
  2924. // pad the end with zeros, but make sure to not forget the extra bytes
  2925. if (extraBytes === 1) {
  2926. tmp = uint8[len - 1]
  2927. parts.push(
  2928. lookup[tmp >> 2] +
  2929. lookup[(tmp << 4) & 0x3F] +
  2930. '=='
  2931. )
  2932. } else if (extraBytes === 2) {
  2933. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  2934. parts.push(
  2935. lookup[tmp >> 10] +
  2936. lookup[(tmp >> 4) & 0x3F] +
  2937. lookup[(tmp << 2) & 0x3F] +
  2938. '='
  2939. )
  2940. }
  2941. return parts.join('')
  2942. }
  2943. },{}],10:[function(require,module,exports){
  2944. (function (Buffer){
  2945. /*!
  2946. * The buffer module from node.js, for the browser.
  2947. *
  2948. * @author Feross Aboukhadijeh <https://feross.org>
  2949. * @license MIT
  2950. */
  2951. /* eslint-disable no-proto */
  2952. 'use strict'
  2953. var base64 = require('base64-js')
  2954. var ieee754 = require('ieee754')
  2955. exports.Buffer = Buffer
  2956. exports.SlowBuffer = SlowBuffer
  2957. exports.INSPECT_MAX_BYTES = 50
  2958. var K_MAX_LENGTH = 0x7fffffff
  2959. exports.kMaxLength = K_MAX_LENGTH
  2960. /**
  2961. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  2962. * === true Use Uint8Array implementation (fastest)
  2963. * === false Print warning and recommend using `buffer` v4.x which has an Object
  2964. * implementation (most compatible, even IE6)
  2965. *
  2966. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  2967. * Opera 11.6+, iOS 4.2+.
  2968. *
  2969. * We report that the browser does not support typed arrays if the are not subclassable
  2970. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  2971. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  2972. * for __proto__ and has a buggy typed array implementation.
  2973. */
  2974. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  2975. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  2976. typeof console.error === 'function') {
  2977. console.error(
  2978. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  2979. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  2980. )
  2981. }
  2982. function typedArraySupport () {
  2983. // Can typed array instances can be augmented?
  2984. try {
  2985. var arr = new Uint8Array(1)
  2986. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  2987. return arr.foo() === 42
  2988. } catch (e) {
  2989. return false
  2990. }
  2991. }
  2992. Object.defineProperty(Buffer.prototype, 'parent', {
  2993. enumerable: true,
  2994. get: function () {
  2995. if (!Buffer.isBuffer(this)) return undefined
  2996. return this.buffer
  2997. }
  2998. })
  2999. Object.defineProperty(Buffer.prototype, 'offset', {
  3000. enumerable: true,
  3001. get: function () {
  3002. if (!Buffer.isBuffer(this)) return undefined
  3003. return this.byteOffset
  3004. }
  3005. })
  3006. function createBuffer (length) {
  3007. if (length > K_MAX_LENGTH) {
  3008. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  3009. }
  3010. // Return an augmented `Uint8Array` instance
  3011. var buf = new Uint8Array(length)
  3012. buf.__proto__ = Buffer.prototype
  3013. return buf
  3014. }
  3015. /**
  3016. * The Buffer constructor returns instances of `Uint8Array` that have their
  3017. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  3018. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  3019. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  3020. * returns a single octet.
  3021. *
  3022. * The `Uint8Array` prototype remains unmodified.
  3023. */
  3024. function Buffer (arg, encodingOrOffset, length) {
  3025. // Common case.
  3026. if (typeof arg === 'number') {
  3027. if (typeof encodingOrOffset === 'string') {
  3028. throw new TypeError(
  3029. 'The "string" argument must be of type string. Received type number'
  3030. )
  3031. }
  3032. return allocUnsafe(arg)
  3033. }
  3034. return from(arg, encodingOrOffset, length)
  3035. }
  3036. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  3037. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  3038. Buffer[Symbol.species] === Buffer) {
  3039. Object.defineProperty(Buffer, Symbol.species, {
  3040. value: null,
  3041. configurable: true,
  3042. enumerable: false,
  3043. writable: false
  3044. })
  3045. }
  3046. Buffer.poolSize = 8192 // not used by this implementation
  3047. function from (value, encodingOrOffset, length) {
  3048. if (typeof value === 'string') {
  3049. return fromString(value, encodingOrOffset)
  3050. }
  3051. if (ArrayBuffer.isView(value)) {
  3052. return fromArrayLike(value)
  3053. }
  3054. if (value == null) {
  3055. throw TypeError(
  3056. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  3057. 'or Array-like Object. Received type ' + (typeof value)
  3058. )
  3059. }
  3060. if (isInstance(value, ArrayBuffer) ||
  3061. (value && isInstance(value.buffer, ArrayBuffer))) {
  3062. return fromArrayBuffer(value, encodingOrOffset, length)
  3063. }
  3064. if (typeof value === 'number') {
  3065. throw new TypeError(
  3066. 'The "value" argument must not be of type number. Received type number'
  3067. )
  3068. }
  3069. var valueOf = value.valueOf && value.valueOf()
  3070. if (valueOf != null && valueOf !== value) {
  3071. return Buffer.from(valueOf, encodingOrOffset, length)
  3072. }
  3073. var b = fromObject(value)
  3074. if (b) return b
  3075. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  3076. typeof value[Symbol.toPrimitive] === 'function') {
  3077. return Buffer.from(
  3078. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  3079. )
  3080. }
  3081. throw new TypeError(
  3082. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  3083. 'or Array-like Object. Received type ' + (typeof value)
  3084. )
  3085. }
  3086. /**
  3087. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  3088. * if value is a number.
  3089. * Buffer.from(str[, encoding])
  3090. * Buffer.from(array)
  3091. * Buffer.from(buffer)
  3092. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  3093. **/
  3094. Buffer.from = function (value, encodingOrOffset, length) {
  3095. return from(value, encodingOrOffset, length)
  3096. }
  3097. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  3098. // https://github.com/feross/buffer/pull/148
  3099. Buffer.prototype.__proto__ = Uint8Array.prototype
  3100. Buffer.__proto__ = Uint8Array
  3101. function assertSize (size) {
  3102. if (typeof size !== 'number') {
  3103. throw new TypeError('"size" argument must be of type number')
  3104. } else if (size < 0) {
  3105. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  3106. }
  3107. }
  3108. function alloc (size, fill, encoding) {
  3109. assertSize(size)
  3110. if (size <= 0) {
  3111. return createBuffer(size)
  3112. }
  3113. if (fill !== undefined) {
  3114. // Only pay attention to encoding if it's a string. This
  3115. // prevents accidentally sending in a number that would
  3116. // be interpretted as a start offset.
  3117. return typeof encoding === 'string'
  3118. ? createBuffer(size).fill(fill, encoding)
  3119. : createBuffer(size).fill(fill)
  3120. }
  3121. return createBuffer(size)
  3122. }
  3123. /**
  3124. * Creates a new filled Buffer instance.
  3125. * alloc(size[, fill[, encoding]])
  3126. **/
  3127. Buffer.alloc = function (size, fill, encoding) {
  3128. return alloc(size, fill, encoding)
  3129. }
  3130. function allocUnsafe (size) {
  3131. assertSize(size)
  3132. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  3133. }
  3134. /**
  3135. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  3136. * */
  3137. Buffer.allocUnsafe = function (size) {
  3138. return allocUnsafe(size)
  3139. }
  3140. /**
  3141. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  3142. */
  3143. Buffer.allocUnsafeSlow = function (size) {
  3144. return allocUnsafe(size)
  3145. }
  3146. function fromString (string, encoding) {
  3147. if (typeof encoding !== 'string' || encoding === '') {
  3148. encoding = 'utf8'
  3149. }
  3150. if (!Buffer.isEncoding(encoding)) {
  3151. throw new TypeError('Unknown encoding: ' + encoding)
  3152. }
  3153. var length = byteLength(string, encoding) | 0
  3154. var buf = createBuffer(length)
  3155. var actual = buf.write(string, encoding)
  3156. if (actual !== length) {
  3157. // Writing a hex string, for example, that contains invalid characters will
  3158. // cause everything after the first invalid character to be ignored. (e.g.
  3159. // 'abxxcd' will be treated as 'ab')
  3160. buf = buf.slice(0, actual)
  3161. }
  3162. return buf
  3163. }
  3164. function fromArrayLike (array) {
  3165. var length = array.length < 0 ? 0 : checked(array.length) | 0
  3166. var buf = createBuffer(length)
  3167. for (var i = 0; i < length; i += 1) {
  3168. buf[i] = array[i] & 255
  3169. }
  3170. return buf
  3171. }
  3172. function fromArrayBuffer (array, byteOffset, length) {
  3173. if (byteOffset < 0 || array.byteLength < byteOffset) {
  3174. throw new RangeError('"offset" is outside of buffer bounds')
  3175. }
  3176. if (array.byteLength < byteOffset + (length || 0)) {
  3177. throw new RangeError('"length" is outside of buffer bounds')
  3178. }
  3179. var buf
  3180. if (byteOffset === undefined && length === undefined) {
  3181. buf = new Uint8Array(array)
  3182. } else if (length === undefined) {
  3183. buf = new Uint8Array(array, byteOffset)
  3184. } else {
  3185. buf = new Uint8Array(array, byteOffset, length)
  3186. }
  3187. // Return an augmented `Uint8Array` instance
  3188. buf.__proto__ = Buffer.prototype
  3189. return buf
  3190. }
  3191. function fromObject (obj) {
  3192. if (Buffer.isBuffer(obj)) {
  3193. var len = checked(obj.length) | 0
  3194. var buf = createBuffer(len)
  3195. if (buf.length === 0) {
  3196. return buf
  3197. }
  3198. obj.copy(buf, 0, 0, len)
  3199. return buf
  3200. }
  3201. if (obj.length !== undefined) {
  3202. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  3203. return createBuffer(0)
  3204. }
  3205. return fromArrayLike(obj)
  3206. }
  3207. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  3208. return fromArrayLike(obj.data)
  3209. }
  3210. }
  3211. function checked (length) {
  3212. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  3213. // length is NaN (which is otherwise coerced to zero.)
  3214. if (length >= K_MAX_LENGTH) {
  3215. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  3216. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  3217. }
  3218. return length | 0
  3219. }
  3220. function SlowBuffer (length) {
  3221. if (+length != length) { // eslint-disable-line eqeqeq
  3222. length = 0
  3223. }
  3224. return Buffer.alloc(+length)
  3225. }
  3226. Buffer.isBuffer = function isBuffer (b) {
  3227. return b != null && b._isBuffer === true &&
  3228. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  3229. }
  3230. Buffer.compare = function compare (a, b) {
  3231. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  3232. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  3233. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  3234. throw new TypeError(
  3235. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  3236. )
  3237. }
  3238. if (a === b) return 0
  3239. var x = a.length
  3240. var y = b.length
  3241. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  3242. if (a[i] !== b[i]) {
  3243. x = a[i]
  3244. y = b[i]
  3245. break
  3246. }
  3247. }
  3248. if (x < y) return -1
  3249. if (y < x) return 1
  3250. return 0
  3251. }
  3252. Buffer.isEncoding = function isEncoding (encoding) {
  3253. switch (String(encoding).toLowerCase()) {
  3254. case 'hex':
  3255. case 'utf8':
  3256. case 'utf-8':
  3257. case 'ascii':
  3258. case 'latin1':
  3259. case 'binary':
  3260. case 'base64':
  3261. case 'ucs2':
  3262. case 'ucs-2':
  3263. case 'utf16le':
  3264. case 'utf-16le':
  3265. return true
  3266. default:
  3267. return false
  3268. }
  3269. }
  3270. Buffer.concat = function concat (list, length) {
  3271. if (!Array.isArray(list)) {
  3272. throw new TypeError('"list" argument must be an Array of Buffers')
  3273. }
  3274. if (list.length === 0) {
  3275. return Buffer.alloc(0)
  3276. }
  3277. var i
  3278. if (length === undefined) {
  3279. length = 0
  3280. for (i = 0; i < list.length; ++i) {
  3281. length += list[i].length
  3282. }
  3283. }
  3284. var buffer = Buffer.allocUnsafe(length)
  3285. var pos = 0
  3286. for (i = 0; i < list.length; ++i) {
  3287. var buf = list[i]
  3288. if (isInstance(buf, Uint8Array)) {
  3289. buf = Buffer.from(buf)
  3290. }
  3291. if (!Buffer.isBuffer(buf)) {
  3292. throw new TypeError('"list" argument must be an Array of Buffers')
  3293. }
  3294. buf.copy(buffer, pos)
  3295. pos += buf.length
  3296. }
  3297. return buffer
  3298. }
  3299. function byteLength (string, encoding) {
  3300. if (Buffer.isBuffer(string)) {
  3301. return string.length
  3302. }
  3303. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  3304. return string.byteLength
  3305. }
  3306. if (typeof string !== 'string') {
  3307. throw new TypeError(
  3308. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  3309. 'Received type ' + typeof string
  3310. )
  3311. }
  3312. var len = string.length
  3313. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  3314. if (!mustMatch && len === 0) return 0
  3315. // Use a for loop to avoid recursion
  3316. var loweredCase = false
  3317. for (;;) {
  3318. switch (encoding) {
  3319. case 'ascii':
  3320. case 'latin1':
  3321. case 'binary':
  3322. return len
  3323. case 'utf8':
  3324. case 'utf-8':
  3325. return utf8ToBytes(string).length
  3326. case 'ucs2':
  3327. case 'ucs-2':
  3328. case 'utf16le':
  3329. case 'utf-16le':
  3330. return len * 2
  3331. case 'hex':
  3332. return len >>> 1
  3333. case 'base64':
  3334. return base64ToBytes(string).length
  3335. default:
  3336. if (loweredCase) {
  3337. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  3338. }
  3339. encoding = ('' + encoding).toLowerCase()
  3340. loweredCase = true
  3341. }
  3342. }
  3343. }
  3344. Buffer.byteLength = byteLength
  3345. function slowToString (encoding, start, end) {
  3346. var loweredCase = false
  3347. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  3348. // property of a typed array.
  3349. // This behaves neither like String nor Uint8Array in that we set start/end
  3350. // to their upper/lower bounds if the value passed is out of range.
  3351. // undefined is handled specially as per ECMA-262 6th Edition,
  3352. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  3353. if (start === undefined || start < 0) {
  3354. start = 0
  3355. }
  3356. // Return early if start > this.length. Done here to prevent potential uint32
  3357. // coercion fail below.
  3358. if (start > this.length) {
  3359. return ''
  3360. }
  3361. if (end === undefined || end > this.length) {
  3362. end = this.length
  3363. }
  3364. if (end <= 0) {
  3365. return ''
  3366. }
  3367. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  3368. end >>>= 0
  3369. start >>>= 0
  3370. if (end <= start) {
  3371. return ''
  3372. }
  3373. if (!encoding) encoding = 'utf8'
  3374. while (true) {
  3375. switch (encoding) {
  3376. case 'hex':
  3377. return hexSlice(this, start, end)
  3378. case 'utf8':
  3379. case 'utf-8':
  3380. return utf8Slice(this, start, end)
  3381. case 'ascii':
  3382. return asciiSlice(this, start, end)
  3383. case 'latin1':
  3384. case 'binary':
  3385. return latin1Slice(this, start, end)
  3386. case 'base64':
  3387. return base64Slice(this, start, end)
  3388. case 'ucs2':
  3389. case 'ucs-2':
  3390. case 'utf16le':
  3391. case 'utf-16le':
  3392. return utf16leSlice(this, start, end)
  3393. default:
  3394. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3395. encoding = (encoding + '').toLowerCase()
  3396. loweredCase = true
  3397. }
  3398. }
  3399. }
  3400. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  3401. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  3402. // reliably in a browserify context because there could be multiple different
  3403. // copies of the 'buffer' package in use. This method works even for Buffer
  3404. // instances that were created from another copy of the `buffer` package.
  3405. // See: https://github.com/feross/buffer/issues/154
  3406. Buffer.prototype._isBuffer = true
  3407. function swap (b, n, m) {
  3408. var i = b[n]
  3409. b[n] = b[m]
  3410. b[m] = i
  3411. }
  3412. Buffer.prototype.swap16 = function swap16 () {
  3413. var len = this.length
  3414. if (len % 2 !== 0) {
  3415. throw new RangeError('Buffer size must be a multiple of 16-bits')
  3416. }
  3417. for (var i = 0; i < len; i += 2) {
  3418. swap(this, i, i + 1)
  3419. }
  3420. return this
  3421. }
  3422. Buffer.prototype.swap32 = function swap32 () {
  3423. var len = this.length
  3424. if (len % 4 !== 0) {
  3425. throw new RangeError('Buffer size must be a multiple of 32-bits')
  3426. }
  3427. for (var i = 0; i < len; i += 4) {
  3428. swap(this, i, i + 3)
  3429. swap(this, i + 1, i + 2)
  3430. }
  3431. return this
  3432. }
  3433. Buffer.prototype.swap64 = function swap64 () {
  3434. var len = this.length
  3435. if (len % 8 !== 0) {
  3436. throw new RangeError('Buffer size must be a multiple of 64-bits')
  3437. }
  3438. for (var i = 0; i < len; i += 8) {
  3439. swap(this, i, i + 7)
  3440. swap(this, i + 1, i + 6)
  3441. swap(this, i + 2, i + 5)
  3442. swap(this, i + 3, i + 4)
  3443. }
  3444. return this
  3445. }
  3446. Buffer.prototype.toString = function toString () {
  3447. var length = this.length
  3448. if (length === 0) return ''
  3449. if (arguments.length === 0) return utf8Slice(this, 0, length)
  3450. return slowToString.apply(this, arguments)
  3451. }
  3452. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  3453. Buffer.prototype.equals = function equals (b) {
  3454. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  3455. if (this === b) return true
  3456. return Buffer.compare(this, b) === 0
  3457. }
  3458. Buffer.prototype.inspect = function inspect () {
  3459. var str = ''
  3460. var max = exports.INSPECT_MAX_BYTES
  3461. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  3462. if (this.length > max) str += ' ... '
  3463. return '<Buffer ' + str + '>'
  3464. }
  3465. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  3466. if (isInstance(target, Uint8Array)) {
  3467. target = Buffer.from(target, target.offset, target.byteLength)
  3468. }
  3469. if (!Buffer.isBuffer(target)) {
  3470. throw new TypeError(
  3471. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  3472. 'Received type ' + (typeof target)
  3473. )
  3474. }
  3475. if (start === undefined) {
  3476. start = 0
  3477. }
  3478. if (end === undefined) {
  3479. end = target ? target.length : 0
  3480. }
  3481. if (thisStart === undefined) {
  3482. thisStart = 0
  3483. }
  3484. if (thisEnd === undefined) {
  3485. thisEnd = this.length
  3486. }
  3487. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  3488. throw new RangeError('out of range index')
  3489. }
  3490. if (thisStart >= thisEnd && start >= end) {
  3491. return 0
  3492. }
  3493. if (thisStart >= thisEnd) {
  3494. return -1
  3495. }
  3496. if (start >= end) {
  3497. return 1
  3498. }
  3499. start >>>= 0
  3500. end >>>= 0
  3501. thisStart >>>= 0
  3502. thisEnd >>>= 0
  3503. if (this === target) return 0
  3504. var x = thisEnd - thisStart
  3505. var y = end - start
  3506. var len = Math.min(x, y)
  3507. var thisCopy = this.slice(thisStart, thisEnd)
  3508. var targetCopy = target.slice(start, end)
  3509. for (var i = 0; i < len; ++i) {
  3510. if (thisCopy[i] !== targetCopy[i]) {
  3511. x = thisCopy[i]
  3512. y = targetCopy[i]
  3513. break
  3514. }
  3515. }
  3516. if (x < y) return -1
  3517. if (y < x) return 1
  3518. return 0
  3519. }
  3520. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  3521. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  3522. //
  3523. // Arguments:
  3524. // - buffer - a Buffer to search
  3525. // - val - a string, Buffer, or number
  3526. // - byteOffset - an index into `buffer`; will be clamped to an int32
  3527. // - encoding - an optional encoding, relevant is val is a string
  3528. // - dir - true for indexOf, false for lastIndexOf
  3529. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  3530. // Empty buffer means no match
  3531. if (buffer.length === 0) return -1
  3532. // Normalize byteOffset
  3533. if (typeof byteOffset === 'string') {
  3534. encoding = byteOffset
  3535. byteOffset = 0
  3536. } else if (byteOffset > 0x7fffffff) {
  3537. byteOffset = 0x7fffffff
  3538. } else if (byteOffset < -0x80000000) {
  3539. byteOffset = -0x80000000
  3540. }
  3541. byteOffset = +byteOffset // Coerce to Number.
  3542. if (numberIsNaN(byteOffset)) {
  3543. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  3544. byteOffset = dir ? 0 : (buffer.length - 1)
  3545. }
  3546. // Normalize byteOffset: negative offsets start from the end of the buffer
  3547. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  3548. if (byteOffset >= buffer.length) {
  3549. if (dir) return -1
  3550. else byteOffset = buffer.length - 1
  3551. } else if (byteOffset < 0) {
  3552. if (dir) byteOffset = 0
  3553. else return -1
  3554. }
  3555. // Normalize val
  3556. if (typeof val === 'string') {
  3557. val = Buffer.from(val, encoding)
  3558. }
  3559. // Finally, search either indexOf (if dir is true) or lastIndexOf
  3560. if (Buffer.isBuffer(val)) {
  3561. // Special case: looking for empty string/buffer always fails
  3562. if (val.length === 0) {
  3563. return -1
  3564. }
  3565. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  3566. } else if (typeof val === 'number') {
  3567. val = val & 0xFF // Search for a byte value [0-255]
  3568. if (typeof Uint8Array.prototype.indexOf === 'function') {
  3569. if (dir) {
  3570. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  3571. } else {
  3572. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  3573. }
  3574. }
  3575. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  3576. }
  3577. throw new TypeError('val must be string, number or Buffer')
  3578. }
  3579. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  3580. var indexSize = 1
  3581. var arrLength = arr.length
  3582. var valLength = val.length
  3583. if (encoding !== undefined) {
  3584. encoding = String(encoding).toLowerCase()
  3585. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  3586. encoding === 'utf16le' || encoding === 'utf-16le') {
  3587. if (arr.length < 2 || val.length < 2) {
  3588. return -1
  3589. }
  3590. indexSize = 2
  3591. arrLength /= 2
  3592. valLength /= 2
  3593. byteOffset /= 2
  3594. }
  3595. }
  3596. function read (buf, i) {
  3597. if (indexSize === 1) {
  3598. return buf[i]
  3599. } else {
  3600. return buf.readUInt16BE(i * indexSize)
  3601. }
  3602. }
  3603. var i
  3604. if (dir) {
  3605. var foundIndex = -1
  3606. for (i = byteOffset; i < arrLength; i++) {
  3607. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  3608. if (foundIndex === -1) foundIndex = i
  3609. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  3610. } else {
  3611. if (foundIndex !== -1) i -= i - foundIndex
  3612. foundIndex = -1
  3613. }
  3614. }
  3615. } else {
  3616. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  3617. for (i = byteOffset; i >= 0; i--) {
  3618. var found = true
  3619. for (var j = 0; j < valLength; j++) {
  3620. if (read(arr, i + j) !== read(val, j)) {
  3621. found = false
  3622. break
  3623. }
  3624. }
  3625. if (found) return i
  3626. }
  3627. }
  3628. return -1
  3629. }
  3630. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  3631. return this.indexOf(val, byteOffset, encoding) !== -1
  3632. }
  3633. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  3634. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  3635. }
  3636. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  3637. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  3638. }
  3639. function hexWrite (buf, string, offset, length) {
  3640. offset = Number(offset) || 0
  3641. var remaining = buf.length - offset
  3642. if (!length) {
  3643. length = remaining
  3644. } else {
  3645. length = Number(length)
  3646. if (length > remaining) {
  3647. length = remaining
  3648. }
  3649. }
  3650. var strLen = string.length
  3651. if (length > strLen / 2) {
  3652. length = strLen / 2
  3653. }
  3654. for (var i = 0; i < length; ++i) {
  3655. var parsed = parseInt(string.substr(i * 2, 2), 16)
  3656. if (numberIsNaN(parsed)) return i
  3657. buf[offset + i] = parsed
  3658. }
  3659. return i
  3660. }
  3661. function utf8Write (buf, string, offset, length) {
  3662. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  3663. }
  3664. function asciiWrite (buf, string, offset, length) {
  3665. return blitBuffer(asciiToBytes(string), buf, offset, length)
  3666. }
  3667. function latin1Write (buf, string, offset, length) {
  3668. return asciiWrite(buf, string, offset, length)
  3669. }
  3670. function base64Write (buf, string, offset, length) {
  3671. return blitBuffer(base64ToBytes(string), buf, offset, length)
  3672. }
  3673. function ucs2Write (buf, string, offset, length) {
  3674. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  3675. }
  3676. Buffer.prototype.write = function write (string, offset, length, encoding) {
  3677. // Buffer#write(string)
  3678. if (offset === undefined) {
  3679. encoding = 'utf8'
  3680. length = this.length
  3681. offset = 0
  3682. // Buffer#write(string, encoding)
  3683. } else if (length === undefined && typeof offset === 'string') {
  3684. encoding = offset
  3685. length = this.length
  3686. offset = 0
  3687. // Buffer#write(string, offset[, length][, encoding])
  3688. } else if (isFinite(offset)) {
  3689. offset = offset >>> 0
  3690. if (isFinite(length)) {
  3691. length = length >>> 0
  3692. if (encoding === undefined) encoding = 'utf8'
  3693. } else {
  3694. encoding = length
  3695. length = undefined
  3696. }
  3697. } else {
  3698. throw new Error(
  3699. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  3700. )
  3701. }
  3702. var remaining = this.length - offset
  3703. if (length === undefined || length > remaining) length = remaining
  3704. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  3705. throw new RangeError('Attempt to write outside buffer bounds')
  3706. }
  3707. if (!encoding) encoding = 'utf8'
  3708. var loweredCase = false
  3709. for (;;) {
  3710. switch (encoding) {
  3711. case 'hex':
  3712. return hexWrite(this, string, offset, length)
  3713. case 'utf8':
  3714. case 'utf-8':
  3715. return utf8Write(this, string, offset, length)
  3716. case 'ascii':
  3717. return asciiWrite(this, string, offset, length)
  3718. case 'latin1':
  3719. case 'binary':
  3720. return latin1Write(this, string, offset, length)
  3721. case 'base64':
  3722. // Warning: maxLength not taken into account in base64Write
  3723. return base64Write(this, string, offset, length)
  3724. case 'ucs2':
  3725. case 'ucs-2':
  3726. case 'utf16le':
  3727. case 'utf-16le':
  3728. return ucs2Write(this, string, offset, length)
  3729. default:
  3730. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  3731. encoding = ('' + encoding).toLowerCase()
  3732. loweredCase = true
  3733. }
  3734. }
  3735. }
  3736. Buffer.prototype.toJSON = function toJSON () {
  3737. return {
  3738. type: 'Buffer',
  3739. data: Array.prototype.slice.call(this._arr || this, 0)
  3740. }
  3741. }
  3742. function base64Slice (buf, start, end) {
  3743. if (start === 0 && end === buf.length) {
  3744. return base64.fromByteArray(buf)
  3745. } else {
  3746. return base64.fromByteArray(buf.slice(start, end))
  3747. }
  3748. }
  3749. function utf8Slice (buf, start, end) {
  3750. end = Math.min(buf.length, end)
  3751. var res = []
  3752. var i = start
  3753. while (i < end) {
  3754. var firstByte = buf[i]
  3755. var codePoint = null
  3756. var bytesPerSequence = (firstByte > 0xEF) ? 4
  3757. : (firstByte > 0xDF) ? 3
  3758. : (firstByte > 0xBF) ? 2
  3759. : 1
  3760. if (i + bytesPerSequence <= end) {
  3761. var secondByte, thirdByte, fourthByte, tempCodePoint
  3762. switch (bytesPerSequence) {
  3763. case 1:
  3764. if (firstByte < 0x80) {
  3765. codePoint = firstByte
  3766. }
  3767. break
  3768. case 2:
  3769. secondByte = buf[i + 1]
  3770. if ((secondByte & 0xC0) === 0x80) {
  3771. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  3772. if (tempCodePoint > 0x7F) {
  3773. codePoint = tempCodePoint
  3774. }
  3775. }
  3776. break
  3777. case 3:
  3778. secondByte = buf[i + 1]
  3779. thirdByte = buf[i + 2]
  3780. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  3781. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  3782. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  3783. codePoint = tempCodePoint
  3784. }
  3785. }
  3786. break
  3787. case 4:
  3788. secondByte = buf[i + 1]
  3789. thirdByte = buf[i + 2]
  3790. fourthByte = buf[i + 3]
  3791. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  3792. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  3793. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  3794. codePoint = tempCodePoint
  3795. }
  3796. }
  3797. }
  3798. }
  3799. if (codePoint === null) {
  3800. // we did not generate a valid codePoint so insert a
  3801. // replacement char (U+FFFD) and advance only 1 byte
  3802. codePoint = 0xFFFD
  3803. bytesPerSequence = 1
  3804. } else if (codePoint > 0xFFFF) {
  3805. // encode to utf16 (surrogate pair dance)
  3806. codePoint -= 0x10000
  3807. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  3808. codePoint = 0xDC00 | codePoint & 0x3FF
  3809. }
  3810. res.push(codePoint)
  3811. i += bytesPerSequence
  3812. }
  3813. return decodeCodePointsArray(res)
  3814. }
  3815. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  3816. // the lowest limit is Chrome, with 0x10000 args.
  3817. // We go 1 magnitude less, for safety
  3818. var MAX_ARGUMENTS_LENGTH = 0x1000
  3819. function decodeCodePointsArray (codePoints) {
  3820. var len = codePoints.length
  3821. if (len <= MAX_ARGUMENTS_LENGTH) {
  3822. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  3823. }
  3824. // Decode in chunks to avoid "call stack size exceeded".
  3825. var res = ''
  3826. var i = 0
  3827. while (i < len) {
  3828. res += String.fromCharCode.apply(
  3829. String,
  3830. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  3831. )
  3832. }
  3833. return res
  3834. }
  3835. function asciiSlice (buf, start, end) {
  3836. var ret = ''
  3837. end = Math.min(buf.length, end)
  3838. for (var i = start; i < end; ++i) {
  3839. ret += String.fromCharCode(buf[i] & 0x7F)
  3840. }
  3841. return ret
  3842. }
  3843. function latin1Slice (buf, start, end) {
  3844. var ret = ''
  3845. end = Math.min(buf.length, end)
  3846. for (var i = start; i < end; ++i) {
  3847. ret += String.fromCharCode(buf[i])
  3848. }
  3849. return ret
  3850. }
  3851. function hexSlice (buf, start, end) {
  3852. var len = buf.length
  3853. if (!start || start < 0) start = 0
  3854. if (!end || end < 0 || end > len) end = len
  3855. var out = ''
  3856. for (var i = start; i < end; ++i) {
  3857. out += toHex(buf[i])
  3858. }
  3859. return out
  3860. }
  3861. function utf16leSlice (buf, start, end) {
  3862. var bytes = buf.slice(start, end)
  3863. var res = ''
  3864. for (var i = 0; i < bytes.length; i += 2) {
  3865. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  3866. }
  3867. return res
  3868. }
  3869. Buffer.prototype.slice = function slice (start, end) {
  3870. var len = this.length
  3871. start = ~~start
  3872. end = end === undefined ? len : ~~end
  3873. if (start < 0) {
  3874. start += len
  3875. if (start < 0) start = 0
  3876. } else if (start > len) {
  3877. start = len
  3878. }
  3879. if (end < 0) {
  3880. end += len
  3881. if (end < 0) end = 0
  3882. } else if (end > len) {
  3883. end = len
  3884. }
  3885. if (end < start) end = start
  3886. var newBuf = this.subarray(start, end)
  3887. // Return an augmented `Uint8Array` instance
  3888. newBuf.__proto__ = Buffer.prototype
  3889. return newBuf
  3890. }
  3891. /*
  3892. * Need to make sure that buffer isn't trying to write out of bounds.
  3893. */
  3894. function checkOffset (offset, ext, length) {
  3895. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  3896. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  3897. }
  3898. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  3899. offset = offset >>> 0
  3900. byteLength = byteLength >>> 0
  3901. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3902. var val = this[offset]
  3903. var mul = 1
  3904. var i = 0
  3905. while (++i < byteLength && (mul *= 0x100)) {
  3906. val += this[offset + i] * mul
  3907. }
  3908. return val
  3909. }
  3910. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  3911. offset = offset >>> 0
  3912. byteLength = byteLength >>> 0
  3913. if (!noAssert) {
  3914. checkOffset(offset, byteLength, this.length)
  3915. }
  3916. var val = this[offset + --byteLength]
  3917. var mul = 1
  3918. while (byteLength > 0 && (mul *= 0x100)) {
  3919. val += this[offset + --byteLength] * mul
  3920. }
  3921. return val
  3922. }
  3923. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  3924. offset = offset >>> 0
  3925. if (!noAssert) checkOffset(offset, 1, this.length)
  3926. return this[offset]
  3927. }
  3928. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  3929. offset = offset >>> 0
  3930. if (!noAssert) checkOffset(offset, 2, this.length)
  3931. return this[offset] | (this[offset + 1] << 8)
  3932. }
  3933. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  3934. offset = offset >>> 0
  3935. if (!noAssert) checkOffset(offset, 2, this.length)
  3936. return (this[offset] << 8) | this[offset + 1]
  3937. }
  3938. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  3939. offset = offset >>> 0
  3940. if (!noAssert) checkOffset(offset, 4, this.length)
  3941. return ((this[offset]) |
  3942. (this[offset + 1] << 8) |
  3943. (this[offset + 2] << 16)) +
  3944. (this[offset + 3] * 0x1000000)
  3945. }
  3946. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  3947. offset = offset >>> 0
  3948. if (!noAssert) checkOffset(offset, 4, this.length)
  3949. return (this[offset] * 0x1000000) +
  3950. ((this[offset + 1] << 16) |
  3951. (this[offset + 2] << 8) |
  3952. this[offset + 3])
  3953. }
  3954. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  3955. offset = offset >>> 0
  3956. byteLength = byteLength >>> 0
  3957. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3958. var val = this[offset]
  3959. var mul = 1
  3960. var i = 0
  3961. while (++i < byteLength && (mul *= 0x100)) {
  3962. val += this[offset + i] * mul
  3963. }
  3964. mul *= 0x80
  3965. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3966. return val
  3967. }
  3968. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  3969. offset = offset >>> 0
  3970. byteLength = byteLength >>> 0
  3971. if (!noAssert) checkOffset(offset, byteLength, this.length)
  3972. var i = byteLength
  3973. var mul = 1
  3974. var val = this[offset + --i]
  3975. while (i > 0 && (mul *= 0x100)) {
  3976. val += this[offset + --i] * mul
  3977. }
  3978. mul *= 0x80
  3979. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  3980. return val
  3981. }
  3982. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  3983. offset = offset >>> 0
  3984. if (!noAssert) checkOffset(offset, 1, this.length)
  3985. if (!(this[offset] & 0x80)) return (this[offset])
  3986. return ((0xff - this[offset] + 1) * -1)
  3987. }
  3988. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  3989. offset = offset >>> 0
  3990. if (!noAssert) checkOffset(offset, 2, this.length)
  3991. var val = this[offset] | (this[offset + 1] << 8)
  3992. return (val & 0x8000) ? val | 0xFFFF0000 : val
  3993. }
  3994. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  3995. offset = offset >>> 0
  3996. if (!noAssert) checkOffset(offset, 2, this.length)
  3997. var val = this[offset + 1] | (this[offset] << 8)
  3998. return (val & 0x8000) ? val | 0xFFFF0000 : val
  3999. }
  4000. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  4001. offset = offset >>> 0
  4002. if (!noAssert) checkOffset(offset, 4, this.length)
  4003. return (this[offset]) |
  4004. (this[offset + 1] << 8) |
  4005. (this[offset + 2] << 16) |
  4006. (this[offset + 3] << 24)
  4007. }
  4008. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  4009. offset = offset >>> 0
  4010. if (!noAssert) checkOffset(offset, 4, this.length)
  4011. return (this[offset] << 24) |
  4012. (this[offset + 1] << 16) |
  4013. (this[offset + 2] << 8) |
  4014. (this[offset + 3])
  4015. }
  4016. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  4017. offset = offset >>> 0
  4018. if (!noAssert) checkOffset(offset, 4, this.length)
  4019. return ieee754.read(this, offset, true, 23, 4)
  4020. }
  4021. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  4022. offset = offset >>> 0
  4023. if (!noAssert) checkOffset(offset, 4, this.length)
  4024. return ieee754.read(this, offset, false, 23, 4)
  4025. }
  4026. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  4027. offset = offset >>> 0
  4028. if (!noAssert) checkOffset(offset, 8, this.length)
  4029. return ieee754.read(this, offset, true, 52, 8)
  4030. }
  4031. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  4032. offset = offset >>> 0
  4033. if (!noAssert) checkOffset(offset, 8, this.length)
  4034. return ieee754.read(this, offset, false, 52, 8)
  4035. }
  4036. function checkInt (buf, value, offset, ext, max, min) {
  4037. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  4038. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  4039. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  4040. }
  4041. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  4042. value = +value
  4043. offset = offset >>> 0
  4044. byteLength = byteLength >>> 0
  4045. if (!noAssert) {
  4046. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  4047. checkInt(this, value, offset, byteLength, maxBytes, 0)
  4048. }
  4049. var mul = 1
  4050. var i = 0
  4051. this[offset] = value & 0xFF
  4052. while (++i < byteLength && (mul *= 0x100)) {
  4053. this[offset + i] = (value / mul) & 0xFF
  4054. }
  4055. return offset + byteLength
  4056. }
  4057. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  4058. value = +value
  4059. offset = offset >>> 0
  4060. byteLength = byteLength >>> 0
  4061. if (!noAssert) {
  4062. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  4063. checkInt(this, value, offset, byteLength, maxBytes, 0)
  4064. }
  4065. var i = byteLength - 1
  4066. var mul = 1
  4067. this[offset + i] = value & 0xFF
  4068. while (--i >= 0 && (mul *= 0x100)) {
  4069. this[offset + i] = (value / mul) & 0xFF
  4070. }
  4071. return offset + byteLength
  4072. }
  4073. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  4074. value = +value
  4075. offset = offset >>> 0
  4076. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  4077. this[offset] = (value & 0xff)
  4078. return offset + 1
  4079. }
  4080. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  4081. value = +value
  4082. offset = offset >>> 0
  4083. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  4084. this[offset] = (value & 0xff)
  4085. this[offset + 1] = (value >>> 8)
  4086. return offset + 2
  4087. }
  4088. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  4089. value = +value
  4090. offset = offset >>> 0
  4091. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  4092. this[offset] = (value >>> 8)
  4093. this[offset + 1] = (value & 0xff)
  4094. return offset + 2
  4095. }
  4096. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  4097. value = +value
  4098. offset = offset >>> 0
  4099. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  4100. this[offset + 3] = (value >>> 24)
  4101. this[offset + 2] = (value >>> 16)
  4102. this[offset + 1] = (value >>> 8)
  4103. this[offset] = (value & 0xff)
  4104. return offset + 4
  4105. }
  4106. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  4107. value = +value
  4108. offset = offset >>> 0
  4109. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  4110. this[offset] = (value >>> 24)
  4111. this[offset + 1] = (value >>> 16)
  4112. this[offset + 2] = (value >>> 8)
  4113. this[offset + 3] = (value & 0xff)
  4114. return offset + 4
  4115. }
  4116. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  4117. value = +value
  4118. offset = offset >>> 0
  4119. if (!noAssert) {
  4120. var limit = Math.pow(2, (8 * byteLength) - 1)
  4121. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  4122. }
  4123. var i = 0
  4124. var mul = 1
  4125. var sub = 0
  4126. this[offset] = value & 0xFF
  4127. while (++i < byteLength && (mul *= 0x100)) {
  4128. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  4129. sub = 1
  4130. }
  4131. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  4132. }
  4133. return offset + byteLength
  4134. }
  4135. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  4136. value = +value
  4137. offset = offset >>> 0
  4138. if (!noAssert) {
  4139. var limit = Math.pow(2, (8 * byteLength) - 1)
  4140. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  4141. }
  4142. var i = byteLength - 1
  4143. var mul = 1
  4144. var sub = 0
  4145. this[offset + i] = value & 0xFF
  4146. while (--i >= 0 && (mul *= 0x100)) {
  4147. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  4148. sub = 1
  4149. }
  4150. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  4151. }
  4152. return offset + byteLength
  4153. }
  4154. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  4155. value = +value
  4156. offset = offset >>> 0
  4157. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  4158. if (value < 0) value = 0xff + value + 1
  4159. this[offset] = (value & 0xff)
  4160. return offset + 1
  4161. }
  4162. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  4163. value = +value
  4164. offset = offset >>> 0
  4165. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  4166. this[offset] = (value & 0xff)
  4167. this[offset + 1] = (value >>> 8)
  4168. return offset + 2
  4169. }
  4170. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  4171. value = +value
  4172. offset = offset >>> 0
  4173. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  4174. this[offset] = (value >>> 8)
  4175. this[offset + 1] = (value & 0xff)
  4176. return offset + 2
  4177. }
  4178. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  4179. value = +value
  4180. offset = offset >>> 0
  4181. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  4182. this[offset] = (value & 0xff)
  4183. this[offset + 1] = (value >>> 8)
  4184. this[offset + 2] = (value >>> 16)
  4185. this[offset + 3] = (value >>> 24)
  4186. return offset + 4
  4187. }
  4188. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  4189. value = +value
  4190. offset = offset >>> 0
  4191. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  4192. if (value < 0) value = 0xffffffff + value + 1
  4193. this[offset] = (value >>> 24)
  4194. this[offset + 1] = (value >>> 16)
  4195. this[offset + 2] = (value >>> 8)
  4196. this[offset + 3] = (value & 0xff)
  4197. return offset + 4
  4198. }
  4199. function checkIEEE754 (buf, value, offset, ext, max, min) {
  4200. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  4201. if (offset < 0) throw new RangeError('Index out of range')
  4202. }
  4203. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  4204. value = +value
  4205. offset = offset >>> 0
  4206. if (!noAssert) {
  4207. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  4208. }
  4209. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  4210. return offset + 4
  4211. }
  4212. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  4213. return writeFloat(this, value, offset, true, noAssert)
  4214. }
  4215. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  4216. return writeFloat(this, value, offset, false, noAssert)
  4217. }
  4218. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  4219. value = +value
  4220. offset = offset >>> 0
  4221. if (!noAssert) {
  4222. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  4223. }
  4224. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  4225. return offset + 8
  4226. }
  4227. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  4228. return writeDouble(this, value, offset, true, noAssert)
  4229. }
  4230. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  4231. return writeDouble(this, value, offset, false, noAssert)
  4232. }
  4233. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  4234. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  4235. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  4236. if (!start) start = 0
  4237. if (!end && end !== 0) end = this.length
  4238. if (targetStart >= target.length) targetStart = target.length
  4239. if (!targetStart) targetStart = 0
  4240. if (end > 0 && end < start) end = start
  4241. // Copy 0 bytes; we're done
  4242. if (end === start) return 0
  4243. if (target.length === 0 || this.length === 0) return 0
  4244. // Fatal error conditions
  4245. if (targetStart < 0) {
  4246. throw new RangeError('targetStart out of bounds')
  4247. }
  4248. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  4249. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  4250. // Are we oob?
  4251. if (end > this.length) end = this.length
  4252. if (target.length - targetStart < end - start) {
  4253. end = target.length - targetStart + start
  4254. }
  4255. var len = end - start
  4256. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  4257. // Use built-in when available, missing from IE11
  4258. this.copyWithin(targetStart, start, end)
  4259. } else if (this === target && start < targetStart && targetStart < end) {
  4260. // descending copy from end
  4261. for (var i = len - 1; i >= 0; --i) {
  4262. target[i + targetStart] = this[i + start]
  4263. }
  4264. } else {
  4265. Uint8Array.prototype.set.call(
  4266. target,
  4267. this.subarray(start, end),
  4268. targetStart
  4269. )
  4270. }
  4271. return len
  4272. }
  4273. // Usage:
  4274. // buffer.fill(number[, offset[, end]])
  4275. // buffer.fill(buffer[, offset[, end]])
  4276. // buffer.fill(string[, offset[, end]][, encoding])
  4277. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  4278. // Handle string cases:
  4279. if (typeof val === 'string') {
  4280. if (typeof start === 'string') {
  4281. encoding = start
  4282. start = 0
  4283. end = this.length
  4284. } else if (typeof end === 'string') {
  4285. encoding = end
  4286. end = this.length
  4287. }
  4288. if (encoding !== undefined && typeof encoding !== 'string') {
  4289. throw new TypeError('encoding must be a string')
  4290. }
  4291. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  4292. throw new TypeError('Unknown encoding: ' + encoding)
  4293. }
  4294. if (val.length === 1) {
  4295. var code = val.charCodeAt(0)
  4296. if ((encoding === 'utf8' && code < 128) ||
  4297. encoding === 'latin1') {
  4298. // Fast path: If `val` fits into a single byte, use that numeric value.
  4299. val = code
  4300. }
  4301. }
  4302. } else if (typeof val === 'number') {
  4303. val = val & 255
  4304. }
  4305. // Invalid ranges are not set to a default, so can range check early.
  4306. if (start < 0 || this.length < start || this.length < end) {
  4307. throw new RangeError('Out of range index')
  4308. }
  4309. if (end <= start) {
  4310. return this
  4311. }
  4312. start = start >>> 0
  4313. end = end === undefined ? this.length : end >>> 0
  4314. if (!val) val = 0
  4315. var i
  4316. if (typeof val === 'number') {
  4317. for (i = start; i < end; ++i) {
  4318. this[i] = val
  4319. }
  4320. } else {
  4321. var bytes = Buffer.isBuffer(val)
  4322. ? val
  4323. : Buffer.from(val, encoding)
  4324. var len = bytes.length
  4325. if (len === 0) {
  4326. throw new TypeError('The value "' + val +
  4327. '" is invalid for argument "value"')
  4328. }
  4329. for (i = 0; i < end - start; ++i) {
  4330. this[i + start] = bytes[i % len]
  4331. }
  4332. }
  4333. return this
  4334. }
  4335. // HELPER FUNCTIONS
  4336. // ================
  4337. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  4338. function base64clean (str) {
  4339. // Node takes equal signs as end of the Base64 encoding
  4340. str = str.split('=')[0]
  4341. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  4342. str = str.trim().replace(INVALID_BASE64_RE, '')
  4343. // Node converts strings with length < 2 to ''
  4344. if (str.length < 2) return ''
  4345. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  4346. while (str.length % 4 !== 0) {
  4347. str = str + '='
  4348. }
  4349. return str
  4350. }
  4351. function toHex (n) {
  4352. if (n < 16) return '0' + n.toString(16)
  4353. return n.toString(16)
  4354. }
  4355. function utf8ToBytes (string, units) {
  4356. units = units || Infinity
  4357. var codePoint
  4358. var length = string.length
  4359. var leadSurrogate = null
  4360. var bytes = []
  4361. for (var i = 0; i < length; ++i) {
  4362. codePoint = string.charCodeAt(i)
  4363. // is surrogate component
  4364. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  4365. // last char was a lead
  4366. if (!leadSurrogate) {
  4367. // no lead yet
  4368. if (codePoint > 0xDBFF) {
  4369. // unexpected trail
  4370. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4371. continue
  4372. } else if (i + 1 === length) {
  4373. // unpaired lead
  4374. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4375. continue
  4376. }
  4377. // valid lead
  4378. leadSurrogate = codePoint
  4379. continue
  4380. }
  4381. // 2 leads in a row
  4382. if (codePoint < 0xDC00) {
  4383. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4384. leadSurrogate = codePoint
  4385. continue
  4386. }
  4387. // valid surrogate pair
  4388. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  4389. } else if (leadSurrogate) {
  4390. // valid bmp char, but last char was a lead
  4391. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  4392. }
  4393. leadSurrogate = null
  4394. // encode utf8
  4395. if (codePoint < 0x80) {
  4396. if ((units -= 1) < 0) break
  4397. bytes.push(codePoint)
  4398. } else if (codePoint < 0x800) {
  4399. if ((units -= 2) < 0) break
  4400. bytes.push(
  4401. codePoint >> 0x6 | 0xC0,
  4402. codePoint & 0x3F | 0x80
  4403. )
  4404. } else if (codePoint < 0x10000) {
  4405. if ((units -= 3) < 0) break
  4406. bytes.push(
  4407. codePoint >> 0xC | 0xE0,
  4408. codePoint >> 0x6 & 0x3F | 0x80,
  4409. codePoint & 0x3F | 0x80
  4410. )
  4411. } else if (codePoint < 0x110000) {
  4412. if ((units -= 4) < 0) break
  4413. bytes.push(
  4414. codePoint >> 0x12 | 0xF0,
  4415. codePoint >> 0xC & 0x3F | 0x80,
  4416. codePoint >> 0x6 & 0x3F | 0x80,
  4417. codePoint & 0x3F | 0x80
  4418. )
  4419. } else {
  4420. throw new Error('Invalid code point')
  4421. }
  4422. }
  4423. return bytes
  4424. }
  4425. function asciiToBytes (str) {
  4426. var byteArray = []
  4427. for (var i = 0; i < str.length; ++i) {
  4428. // Node's code seems to be doing this and not & 0x7F..
  4429. byteArray.push(str.charCodeAt(i) & 0xFF)
  4430. }
  4431. return byteArray
  4432. }
  4433. function utf16leToBytes (str, units) {
  4434. var c, hi, lo
  4435. var byteArray = []
  4436. for (var i = 0; i < str.length; ++i) {
  4437. if ((units -= 2) < 0) break
  4438. c = str.charCodeAt(i)
  4439. hi = c >> 8
  4440. lo = c % 256
  4441. byteArray.push(lo)
  4442. byteArray.push(hi)
  4443. }
  4444. return byteArray
  4445. }
  4446. function base64ToBytes (str) {
  4447. return base64.toByteArray(base64clean(str))
  4448. }
  4449. function blitBuffer (src, dst, offset, length) {
  4450. for (var i = 0; i < length; ++i) {
  4451. if ((i + offset >= dst.length) || (i >= src.length)) break
  4452. dst[i + offset] = src[i]
  4453. }
  4454. return i
  4455. }
  4456. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  4457. // the `instanceof` check but they should be treated as of that type.
  4458. // See: https://github.com/feross/buffer/issues/166
  4459. function isInstance (obj, type) {
  4460. return obj instanceof type ||
  4461. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  4462. obj.constructor.name === type.name)
  4463. }
  4464. function numberIsNaN (obj) {
  4465. // For IE11 support
  4466. return obj !== obj // eslint-disable-line no-self-compare
  4467. }
  4468. }).call(this,require("buffer").Buffer)
  4469. },{"base64-js":9,"buffer":10,"ieee754":11}],11:[function(require,module,exports){
  4470. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  4471. var e, m
  4472. var eLen = (nBytes * 8) - mLen - 1
  4473. var eMax = (1 << eLen) - 1
  4474. var eBias = eMax >> 1
  4475. var nBits = -7
  4476. var i = isLE ? (nBytes - 1) : 0
  4477. var d = isLE ? -1 : 1
  4478. var s = buffer[offset + i]
  4479. i += d
  4480. e = s & ((1 << (-nBits)) - 1)
  4481. s >>= (-nBits)
  4482. nBits += eLen
  4483. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  4484. m = e & ((1 << (-nBits)) - 1)
  4485. e >>= (-nBits)
  4486. nBits += mLen
  4487. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  4488. if (e === 0) {
  4489. e = 1 - eBias
  4490. } else if (e === eMax) {
  4491. return m ? NaN : ((s ? -1 : 1) * Infinity)
  4492. } else {
  4493. m = m + Math.pow(2, mLen)
  4494. e = e - eBias
  4495. }
  4496. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  4497. }
  4498. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  4499. var e, m, c
  4500. var eLen = (nBytes * 8) - mLen - 1
  4501. var eMax = (1 << eLen) - 1
  4502. var eBias = eMax >> 1
  4503. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  4504. var i = isLE ? 0 : (nBytes - 1)
  4505. var d = isLE ? 1 : -1
  4506. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  4507. value = Math.abs(value)
  4508. if (isNaN(value) || value === Infinity) {
  4509. m = isNaN(value) ? 1 : 0
  4510. e = eMax
  4511. } else {
  4512. e = Math.floor(Math.log(value) / Math.LN2)
  4513. if (value * (c = Math.pow(2, -e)) < 1) {
  4514. e--
  4515. c *= 2
  4516. }
  4517. if (e + eBias >= 1) {
  4518. value += rt / c
  4519. } else {
  4520. value += rt * Math.pow(2, 1 - eBias)
  4521. }
  4522. if (value * c >= 2) {
  4523. e++
  4524. c /= 2
  4525. }
  4526. if (e + eBias >= eMax) {
  4527. m = 0
  4528. e = eMax
  4529. } else if (e + eBias >= 1) {
  4530. m = ((value * c) - 1) * Math.pow(2, mLen)
  4531. e = e + eBias
  4532. } else {
  4533. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  4534. e = 0
  4535. }
  4536. }
  4537. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  4538. e = (e << mLen) | m
  4539. eLen += mLen
  4540. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  4541. buffer[offset + i - d] |= s * 128
  4542. }
  4543. },{}],12:[function(require,module,exports){
  4544. // shim for using process in browser
  4545. var process = module.exports = {};
  4546. // cached from whatever global is present so that test runners that stub it
  4547. // don't break things. But we need to wrap it in a try catch in case it is
  4548. // wrapped in strict mode code which doesn't define any globals. It's inside a
  4549. // function because try/catches deoptimize in certain engines.
  4550. var cachedSetTimeout;
  4551. var cachedClearTimeout;
  4552. function defaultSetTimout() {
  4553. throw new Error('setTimeout has not been defined');
  4554. }
  4555. function defaultClearTimeout () {
  4556. throw new Error('clearTimeout has not been defined');
  4557. }
  4558. (function () {
  4559. try {
  4560. if (typeof setTimeout === 'function') {
  4561. cachedSetTimeout = setTimeout;
  4562. } else {
  4563. cachedSetTimeout = defaultSetTimout;
  4564. }
  4565. } catch (e) {
  4566. cachedSetTimeout = defaultSetTimout;
  4567. }
  4568. try {
  4569. if (typeof clearTimeout === 'function') {
  4570. cachedClearTimeout = clearTimeout;
  4571. } else {
  4572. cachedClearTimeout = defaultClearTimeout;
  4573. }
  4574. } catch (e) {
  4575. cachedClearTimeout = defaultClearTimeout;
  4576. }
  4577. } ())
  4578. function runTimeout(fun) {
  4579. if (cachedSetTimeout === setTimeout) {
  4580. //normal enviroments in sane situations
  4581. return setTimeout(fun, 0);
  4582. }
  4583. // if setTimeout wasn't available but was latter defined
  4584. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  4585. cachedSetTimeout = setTimeout;
  4586. return setTimeout(fun, 0);
  4587. }
  4588. try {
  4589. // when when somebody has screwed with setTimeout but no I.E. maddness
  4590. return cachedSetTimeout(fun, 0);
  4591. } catch(e){
  4592. try {
  4593. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4594. return cachedSetTimeout.call(null, fun, 0);
  4595. } catch(e){
  4596. // 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
  4597. return cachedSetTimeout.call(this, fun, 0);
  4598. }
  4599. }
  4600. }
  4601. function runClearTimeout(marker) {
  4602. if (cachedClearTimeout === clearTimeout) {
  4603. //normal enviroments in sane situations
  4604. return clearTimeout(marker);
  4605. }
  4606. // if clearTimeout wasn't available but was latter defined
  4607. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  4608. cachedClearTimeout = clearTimeout;
  4609. return clearTimeout(marker);
  4610. }
  4611. try {
  4612. // when when somebody has screwed with setTimeout but no I.E. maddness
  4613. return cachedClearTimeout(marker);
  4614. } catch (e){
  4615. try {
  4616. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4617. return cachedClearTimeout.call(null, marker);
  4618. } catch (e){
  4619. // 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.
  4620. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  4621. return cachedClearTimeout.call(this, marker);
  4622. }
  4623. }
  4624. }
  4625. var queue = [];
  4626. var draining = false;
  4627. var currentQueue;
  4628. var queueIndex = -1;
  4629. function cleanUpNextTick() {
  4630. if (!draining || !currentQueue) {
  4631. return;
  4632. }
  4633. draining = false;
  4634. if (currentQueue.length) {
  4635. queue = currentQueue.concat(queue);
  4636. } else {
  4637. queueIndex = -1;
  4638. }
  4639. if (queue.length) {
  4640. drainQueue();
  4641. }
  4642. }
  4643. function drainQueue() {
  4644. if (draining) {
  4645. return;
  4646. }
  4647. var timeout = runTimeout(cleanUpNextTick);
  4648. draining = true;
  4649. var len = queue.length;
  4650. while(len) {
  4651. currentQueue = queue;
  4652. queue = [];
  4653. while (++queueIndex < len) {
  4654. if (currentQueue) {
  4655. currentQueue[queueIndex].run();
  4656. }
  4657. }
  4658. queueIndex = -1;
  4659. len = queue.length;
  4660. }
  4661. currentQueue = null;
  4662. draining = false;
  4663. runClearTimeout(timeout);
  4664. }
  4665. process.nextTick = function (fun) {
  4666. var args = new Array(arguments.length - 1);
  4667. if (arguments.length > 1) {
  4668. for (var i = 1; i < arguments.length; i++) {
  4669. args[i - 1] = arguments[i];
  4670. }
  4671. }
  4672. queue.push(new Item(fun, args));
  4673. if (queue.length === 1 && !draining) {
  4674. runTimeout(drainQueue);
  4675. }
  4676. };
  4677. // v8 likes predictible objects
  4678. function Item(fun, array) {
  4679. this.fun = fun;
  4680. this.array = array;
  4681. }
  4682. Item.prototype.run = function () {
  4683. this.fun.apply(null, this.array);
  4684. };
  4685. process.title = 'browser';
  4686. process.browser = true;
  4687. process.env = {};
  4688. process.argv = [];
  4689. process.version = ''; // empty string to avoid regexp issues
  4690. process.versions = {};
  4691. function noop() {}
  4692. process.on = noop;
  4693. process.addListener = noop;
  4694. process.once = noop;
  4695. process.off = noop;
  4696. process.removeListener = noop;
  4697. process.removeAllListeners = noop;
  4698. process.emit = noop;
  4699. process.prependListener = noop;
  4700. process.prependOnceListener = noop;
  4701. process.listeners = function (name) { return [] }
  4702. process.binding = function (name) {
  4703. throw new Error('process.binding is not supported');
  4704. };
  4705. process.cwd = function () { return '/' };
  4706. process.chdir = function (dir) {
  4707. throw new Error('process.chdir is not supported');
  4708. };
  4709. process.umask = function() { return 0; };
  4710. },{}]},{},[2]);