less 3.8.0 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/Gruntfile.js +1 -3
  2. package/dist/less.js +2352 -98
  3. package/dist/less.min.js +7 -7
  4. package/lib/less/functions/color.js +84 -41
  5. package/lib/less/index.js +1 -1
  6. package/lib/less/parser/parser.js +2 -9
  7. package/lib/less/source-map-output.js +2 -2
  8. package/lib/less/tree/color.js +58 -18
  9. package/lib/less/utils.js +12 -19
  10. package/lib/less-browser/index.js +7 -1
  11. package/package.json +5 -2
  12. package/test/browser/less.js +2352 -98
  13. package/test/css/colors.css +20 -3
  14. package/test/css/css-escapes.css +3 -0
  15. package/test/css/functions.css +4 -4
  16. package/test/less/colors.less +18 -0
  17. package/test/less/css-escapes.less +4 -0
  18. package/test/less/errors/color-func-invalid-color.txt +1 -1
  19. package/test/less/sourcemaps/custom-props.less +8 -0
  20. package/test/less-bom/colors.less +18 -0
  21. package/test/less-bom/css-escapes.less +4 -0
  22. package/test/less-bom/errors/color-func-invalid-color.txt +1 -1
  23. package/test/less-bom/sourcemaps/custom-props.less +8 -0
  24. package/test/less-test.js +26 -12
  25. package/test/sourcemaps/custom-props.json +1 -0
  26. package/test/less/errors/color-invalid-hex-code.less +0 -4
  27. package/test/less/errors/color-invalid-hex-code.txt +0 -4
  28. package/test/less/errors/color-invalid-hex-code2.less +0 -4
  29. package/test/less/errors/color-invalid-hex-code2.txt +0 -4
  30. package/test/less-bom/errors/color-invalid-hex-code.less +0 -4
  31. package/test/less-bom/errors/color-invalid-hex-code.txt +0 -4
  32. package/test/less-bom/errors/color-invalid-hex-code2.less +0 -4
  33. package/test/less-bom/errors/color-invalid-hex-code2.txt +0 -4
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Less - Leaner CSS v3.8.0
2
+ * Less - Leaner CSS v3.8.1
3
3
  * http://lesscss.org
4
4
  *
5
5
  * Copyright (c) 2009-2018, Alexis Sellier <self@cloudhead.net>
@@ -130,7 +130,7 @@ if (options.onReady) {
130
130
  less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);
131
131
  }
132
132
 
133
- },{"../less/default-options":17,"./add-default-options":1,"./index":8,"promise/polyfill":103}],3:[function(require,module,exports){
133
+ },{"../less/default-options":17,"./add-default-options":1,"./index":8,"promise/polyfill":107}],3:[function(require,module,exports){
134
134
  var utils = require('./utils');
135
135
  module.exports = {
136
136
  createCSS: function (document, styles, sheet) {
@@ -589,7 +589,13 @@ module.exports = function(window, options) {
589
589
  var typePattern = /^text\/(x-)?less$/;
590
590
 
591
591
  function clone(obj) {
592
- return JSON.parse(JSON.stringify(obj || {}));
592
+ var cloned = {};
593
+ for (var prop in obj) {
594
+ if (obj.hasOwnProperty(prop)) {
595
+ cloned[prop] = obj[prop];
596
+ }
597
+ }
598
+ return cloned;
593
599
  }
594
600
 
595
601
  // only really needed for phantom
@@ -1842,8 +1848,17 @@ var Dimension = require('../tree/dimension'),
1842
1848
  function clamp(val) {
1843
1849
  return Math.min(1, Math.max(0, val));
1844
1850
  }
1845
- function hsla(color) {
1846
- return colorFunctions.hsla(color.h, color.s, color.l, color.a);
1851
+ function hsla(origColor, hsl) {
1852
+ var color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);
1853
+ if (color) {
1854
+ if (origColor.value &&
1855
+ /^(rgb|hsl)/.test(origColor.value)) {
1856
+ color.value = origColor.value;
1857
+ } else {
1858
+ color.value = 'rgb';
1859
+ }
1860
+ return color;
1861
+ }
1847
1862
  }
1848
1863
  function number(n) {
1849
1864
  if (n instanceof Dimension) {
@@ -1866,46 +1881,79 @@ function scaled(n, size) {
1866
1881
  }
1867
1882
  colorFunctions = {
1868
1883
  rgb: function (r, g, b) {
1869
- return colorFunctions.rgba(r, g, b, 1.0);
1884
+ var color = colorFunctions.rgba(r, g, b, 1.0);
1885
+ if (color) {
1886
+ color.value = 'rgb';
1887
+ return color;
1888
+ }
1870
1889
  },
1871
1890
  rgba: function (r, g, b, a) {
1872
- var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
1873
- a = number(a);
1874
- return new Color(rgb, a);
1891
+ try {
1892
+ if (r instanceof Color) {
1893
+ if (g) {
1894
+ a = number(g);
1895
+ } else {
1896
+ a = r.alpha;
1897
+ }
1898
+ return new Color(r.rgb, a, 'rgba');
1899
+ }
1900
+ var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
1901
+ a = number(a);
1902
+ return new Color(rgb, a, 'rgba');
1903
+ }
1904
+ catch (e) {}
1875
1905
  },
1876
1906
  hsl: function (h, s, l) {
1877
- return colorFunctions.hsla(h, s, l, 1.0);
1907
+ var color = colorFunctions.hsla(h, s, l, 1.0);
1908
+ if (color) {
1909
+ color.value = 'hsl';
1910
+ return color;
1911
+ }
1878
1912
  },
1879
1913
  hsla: function (h, s, l, a) {
1914
+ try {
1915
+ if (h instanceof Color) {
1916
+ if (s) {
1917
+ a = number(s);
1918
+ } else {
1919
+ a = h.alpha;
1920
+ }
1921
+ return new Color(h.rgb, a, 'hsla');
1922
+ }
1880
1923
 
1881
- var m1, m2;
1924
+ var m1, m2;
1882
1925
 
1883
- function hue(h) {
1884
- h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1885
- if (h * 6 < 1) {
1886
- return m1 + (m2 - m1) * h * 6;
1887
- }
1888
- else if (h * 2 < 1) {
1889
- return m2;
1890
- }
1891
- else if (h * 3 < 2) {
1892
- return m1 + (m2 - m1) * (2 / 3 - h) * 6;
1893
- }
1894
- else {
1895
- return m1;
1926
+ function hue(h) {
1927
+ h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1928
+ if (h * 6 < 1) {
1929
+ return m1 + (m2 - m1) * h * 6;
1930
+ }
1931
+ else if (h * 2 < 1) {
1932
+ return m2;
1933
+ }
1934
+ else if (h * 3 < 2) {
1935
+ return m1 + (m2 - m1) * (2 / 3 - h) * 6;
1936
+ }
1937
+ else {
1938
+ return m1;
1939
+ }
1896
1940
  }
1897
- }
1898
1941
 
1899
- h = (number(h) % 360) / 360;
1900
- s = clamp(number(s)); l = clamp(number(l)); a = clamp(number(a));
1942
+ h = (number(h) % 360) / 360;
1943
+ s = clamp(number(s)); l = clamp(number(l)); a = clamp(number(a));
1901
1944
 
1902
- m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1903
- m1 = l * 2 - m2;
1945
+ m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1946
+ m1 = l * 2 - m2;
1904
1947
 
1905
- return colorFunctions.rgba(hue(h + 1 / 3) * 255,
1906
- hue(h) * 255,
1907
- hue(h - 1 / 3) * 255,
1908
- a);
1948
+ var rgb = [
1949
+ hue(h + 1 / 3) * 255,
1950
+ hue(h) * 255,
1951
+ hue(h - 1 / 3) * 255
1952
+ ];
1953
+ a = number(a);
1954
+ return new Color(rgb, a, 'hsla');
1955
+ }
1956
+ catch (e) {}
1909
1957
  },
1910
1958
 
1911
1959
  hsv: function(h, s, v) {
@@ -1993,7 +2041,7 @@ colorFunctions = {
1993
2041
  hsl.s += amount.value / 100;
1994
2042
  }
1995
2043
  hsl.s = clamp(hsl.s);
1996
- return hsla(hsl);
2044
+ return hsla(color, hsl);
1997
2045
  },
1998
2046
  desaturate: function (color, amount, method) {
1999
2047
  var hsl = color.toHSL();
@@ -2005,7 +2053,7 @@ colorFunctions = {
2005
2053
  hsl.s -= amount.value / 100;
2006
2054
  }
2007
2055
  hsl.s = clamp(hsl.s);
2008
- return hsla(hsl);
2056
+ return hsla(color, hsl);
2009
2057
  },
2010
2058
  lighten: function (color, amount, method) {
2011
2059
  var hsl = color.toHSL();
@@ -2017,7 +2065,7 @@ colorFunctions = {
2017
2065
  hsl.l += amount.value / 100;
2018
2066
  }
2019
2067
  hsl.l = clamp(hsl.l);
2020
- return hsla(hsl);
2068
+ return hsla(color, hsl);
2021
2069
  },
2022
2070
  darken: function (color, amount, method) {
2023
2071
  var hsl = color.toHSL();
@@ -2029,7 +2077,7 @@ colorFunctions = {
2029
2077
  hsl.l -= amount.value / 100;
2030
2078
  }
2031
2079
  hsl.l = clamp(hsl.l);
2032
- return hsla(hsl);
2080
+ return hsla(color, hsl);
2033
2081
  },
2034
2082
  fadein: function (color, amount, method) {
2035
2083
  var hsl = color.toHSL();
@@ -2041,7 +2089,7 @@ colorFunctions = {
2041
2089
  hsl.a += amount.value / 100;
2042
2090
  }
2043
2091
  hsl.a = clamp(hsl.a);
2044
- return hsla(hsl);
2092
+ return hsla(color, hsl);
2045
2093
  },
2046
2094
  fadeout: function (color, amount, method) {
2047
2095
  var hsl = color.toHSL();
@@ -2053,14 +2101,14 @@ colorFunctions = {
2053
2101
  hsl.a -= amount.value / 100;
2054
2102
  }
2055
2103
  hsl.a = clamp(hsl.a);
2056
- return hsla(hsl);
2104
+ return hsla(color, hsl);
2057
2105
  },
2058
2106
  fade: function (color, amount) {
2059
2107
  var hsl = color.toHSL();
2060
2108
 
2061
2109
  hsl.a = amount.value / 100;
2062
2110
  hsl.a = clamp(hsl.a);
2063
- return hsla(hsl);
2111
+ return hsla(color, hsl);
2064
2112
  },
2065
2113
  spin: function (color, amount) {
2066
2114
  var hsl = color.toHSL();
@@ -2068,7 +2116,7 @@ colorFunctions = {
2068
2116
 
2069
2117
  hsl.h = hue < 0 ? 360 + hue : hue;
2070
2118
 
2071
- return hsla(hsl);
2119
+ return hsla(color, hsl);
2072
2120
  },
2073
2121
  //
2074
2122
  // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein
@@ -2172,8 +2220,9 @@ colorFunctions = {
2172
2220
  },
2173
2221
  color: function(c) {
2174
2222
  if ((c instanceof Quoted) &&
2175
- (/^#([a-f0-9]{6}|[a-f0-9]{3})$/i.test(c.value))) {
2176
- return new Color(c.value.slice(1));
2223
+ (/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) {
2224
+ var val = c.value.slice(1);
2225
+ return new Color(val, undefined, '#' + val);
2177
2226
  }
2178
2227
  if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {
2179
2228
  c.value = undefined;
@@ -2181,7 +2230,7 @@ colorFunctions = {
2181
2230
  }
2182
2231
  throw {
2183
2232
  type: 'Argument',
2184
- message: 'argument must be a color keyword or 3/6 digit hex e.g. #FFF'
2233
+ message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'
2185
2234
  };
2186
2235
  },
2187
2236
  tint: function(color, amount) {
@@ -3031,7 +3080,7 @@ module.exports = function(environment, fileManagers) {
3031
3080
  var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
3032
3081
 
3033
3082
  var initial = {
3034
- version: [3, 8, 0],
3083
+ version: [3, 8, 1],
3035
3084
  data: require('./data'),
3036
3085
  tree: require('./tree'),
3037
3086
  Environment: (Environment = require('./environment/environment')),
@@ -4555,15 +4604,8 @@ var Parser = function Parser(context, imports, fileInfo) {
4555
4604
  color: function () {
4556
4605
  var rgb;
4557
4606
 
4558
- if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))) {
4559
- // strip colons, brackets, whitespaces and other characters that should not
4560
- // definitely be part of color string
4561
- var colorCandidateString = rgb.input.match(/^#([\w]+).*/);
4562
- colorCandidateString = colorCandidateString[1];
4563
- if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters
4564
- error('Invalid HEX color code');
4565
- }
4566
- return new(tree.Color)(rgb[1], undefined, '#' + colorCandidateString);
4607
+ if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})/))) {
4608
+ return new(tree.Color)(rgb[1], undefined, rgb[0]);
4567
4609
  }
4568
4610
  },
4569
4611
 
@@ -6540,7 +6582,7 @@ module.exports = function (environment) {
6540
6582
  sourceColumns,
6541
6583
  i;
6542
6584
 
6543
- if (fileInfo) {
6585
+ if (fileInfo && fileInfo.filename) {
6544
6586
  var inputSource = this._contentsMap[fileInfo.filename];
6545
6587
 
6546
6588
  // remove vars/banner added to the top of the file
@@ -6559,7 +6601,7 @@ module.exports = function (environment) {
6559
6601
  lines = chunk.split('\n');
6560
6602
  columns = lines[lines.length - 1];
6561
6603
 
6562
- if (fileInfo) {
6604
+ if (fileInfo && fileInfo.filename) {
6563
6605
  if (!mapLines) {
6564
6606
  this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},
6565
6607
  original: { line: sourceLines.length, column: sourceColumns.length},
@@ -7053,6 +7095,7 @@ var Node = require('./node'),
7053
7095
  // RGB Colors - #ff0014, #eee
7054
7096
  //
7055
7097
  var Color = function (rgb, a, originalForm) {
7098
+ var self = this;
7056
7099
  //
7057
7100
  // The end goal here, is to parse the arguments
7058
7101
  // into an integer triplet, such as `128, 255, 0`
@@ -7061,16 +7104,26 @@ var Color = function (rgb, a, originalForm) {
7061
7104
  //
7062
7105
  if (Array.isArray(rgb)) {
7063
7106
  this.rgb = rgb;
7064
- } else if (rgb.length == 6) {
7065
- this.rgb = rgb.match(/.{2}/g).map(function (c) {
7066
- return parseInt(c, 16);
7107
+ } else if (rgb.length >= 6) {
7108
+ this.rgb = [];
7109
+ rgb.match(/.{2}/g).map(function (c, i) {
7110
+ if (i < 3) {
7111
+ self.rgb.push(parseInt(c, 16));
7112
+ } else {
7113
+ self.alpha = (parseInt(c, 16)) / 255;
7114
+ }
7067
7115
  });
7068
7116
  } else {
7069
- this.rgb = rgb.split('').map(function (c) {
7070
- return parseInt(c + c, 16);
7117
+ this.rgb = [];
7118
+ rgb.split('').map(function (c, i) {
7119
+ if (i < 3) {
7120
+ self.rgb.push(parseInt(c + c, 16));
7121
+ } else {
7122
+ self.alpha = (parseInt(c + c, 16)) / 255;
7123
+ }
7071
7124
  });
7072
7125
  }
7073
- this.alpha = typeof a === 'number' ? a : 1;
7126
+ this.alpha = this.alpha || (typeof a === 'number' ? a : 1);
7074
7127
  if (typeof originalForm !== 'undefined') {
7075
7128
  this.value = originalForm;
7076
7129
  }
@@ -7105,25 +7158,54 @@ Color.prototype.genCSS = function (context, output) {
7105
7158
  output.add(this.toCSS(context));
7106
7159
  };
7107
7160
  Color.prototype.toCSS = function (context, doNotCompress) {
7108
- var compress = context && context.compress && !doNotCompress, color, alpha;
7161
+ var compress = context && context.compress && !doNotCompress, color, alpha,
7162
+ colorFunction, args = [];
7109
7163
 
7110
7164
  // `value` is set if this color was originally
7111
7165
  // converted from a named color string so we need
7112
7166
  // to respect this and try to output named color too.
7167
+ alpha = this.fround(context, this.alpha);
7168
+
7113
7169
  if (this.value) {
7114
- return this.value;
7170
+ if (this.value.indexOf('rgb') === 0) {
7171
+ if (alpha < 1) {
7172
+ colorFunction = 'rgba';
7173
+ }
7174
+ } else if (this.value.indexOf('hsl') === 0) {
7175
+ if (alpha < 1) {
7176
+ colorFunction = 'hsla';
7177
+ } else {
7178
+ colorFunction = 'hsl';
7179
+ }
7180
+ } else {
7181
+ return this.value;
7182
+ }
7183
+ } else {
7184
+ if (alpha < 1) {
7185
+ colorFunction = 'rgba';
7186
+ }
7115
7187
  }
7116
7188
 
7117
- // If we have some transparency, the only way to represent it
7118
- // is via `rgba`. Otherwise, we use the hex representation,
7119
- // which has better compatibility with older browsers.
7120
- // Values are capped between `0` and `255`, rounded and zero-padded.
7121
- alpha = this.fround(context, this.alpha);
7122
- if (alpha < 1) {
7123
- return 'rgba(' + this.rgb.map(function (c) {
7124
- return clamp(Math.round(c), 255);
7125
- }).concat(clamp(alpha, 1))
7126
- .join(',' + (compress ? '' : ' ')) + ')';
7189
+ switch (colorFunction) {
7190
+ case 'rgba':
7191
+ args = this.rgb.map(function (c) {
7192
+ return clamp(Math.round(c), 255);
7193
+ }).concat(clamp(alpha, 1));
7194
+ break;
7195
+ case 'hsla':
7196
+ args.push(clamp(alpha, 1));
7197
+ case 'hsl':
7198
+ color = this.toHSL();
7199
+ args = [
7200
+ this.fround(context, color.h),
7201
+ this.fround(context, color.s * 100) + '%',
7202
+ this.fround(context, color.l * 100) + '%'
7203
+ ].concat(args);
7204
+ }
7205
+
7206
+ if (colorFunction) {
7207
+ // Values are capped between `0` and `255`, rounded and zero-padded.
7208
+ return colorFunction + '(' + args.join(',' + (compress ? '' : ' ')) + ')';
7127
7209
  }
7128
7210
 
7129
7211
  color = this.toRGB();
@@ -10477,6 +10559,7 @@ module.exports = Variable;
10477
10559
  },{"./call":54,"./node":76}],89:[function(require,module,exports){
10478
10560
  /* jshint proto: true */
10479
10561
  var Constants = require('./constants');
10562
+ var clone = require('clone');
10480
10563
 
10481
10564
  var utils = {
10482
10565
  getLocation: function(index, inputStream) {
@@ -10516,6 +10599,9 @@ var utils = {
10516
10599
  return cloned;
10517
10600
  },
10518
10601
  copyOptions: function(obj1, obj2) {
10602
+ if (obj2 && obj2._defaults) {
10603
+ return obj2;
10604
+ }
10519
10605
  var opts = utils.defaults(obj1, obj2);
10520
10606
  if (opts.strictMath) {
10521
10607
  opts.math = Constants.Math.STRICT_LEGACY;
@@ -10556,26 +10642,15 @@ var utils = {
10556
10642
  return opts;
10557
10643
  },
10558
10644
  defaults: function(obj1, obj2) {
10559
- if (!obj2._defaults || obj2._defaults !== obj1) {
10560
- for (var prop in obj1) {
10561
- if (obj1.hasOwnProperty(prop)) {
10562
- if (!obj2.hasOwnProperty(prop)) {
10563
- obj2[prop] = obj1[prop];
10564
- }
10565
- else if (Array.isArray(obj1[prop])
10566
- && Array.isArray(obj2[prop])) {
10567
-
10568
- obj1[prop].forEach(function(p) {
10569
- if (obj2[prop].indexOf(p) === -1) {
10570
- obj2[prop].push(p);
10571
- }
10572
- });
10573
- }
10574
- }
10575
- }
10645
+ var newObj = obj2 || {};
10646
+ if (!obj2._defaults) {
10647
+ newObj = {};
10648
+ var defaults = clone(obj1);
10649
+ newObj._defaults = defaults;
10650
+ var cloned = obj2 ? clone(obj2) : {};
10651
+ Object.assign(newObj, defaults, cloned);
10576
10652
  }
10577
- obj2._defaults = obj1;
10578
- return obj2;
10653
+ return newObj;
10579
10654
  },
10580
10655
  merge: function(obj1, obj2) {
10581
10656
  for (var prop in obj2) {
@@ -10602,7 +10677,7 @@ var utils = {
10602
10677
  };
10603
10678
 
10604
10679
  module.exports = utils;
10605
- },{"./constants":12}],90:[function(require,module,exports){
10680
+ },{"./constants":12,"clone":102}],90:[function(require,module,exports){
10606
10681
  var tree = require('../tree'),
10607
10682
  Visitor = require('./visitor'),
10608
10683
  logger = require('../logger'),
@@ -12232,6 +12307,2185 @@ rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
12232
12307
 
12233
12308
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
12234
12309
  },{}],100:[function(require,module,exports){
12310
+ 'use strict'
12311
+
12312
+ exports.byteLength = byteLength
12313
+ exports.toByteArray = toByteArray
12314
+ exports.fromByteArray = fromByteArray
12315
+
12316
+ var lookup = []
12317
+ var revLookup = []
12318
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
12319
+
12320
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
12321
+ for (var i = 0, len = code.length; i < len; ++i) {
12322
+ lookup[i] = code[i]
12323
+ revLookup[code.charCodeAt(i)] = i
12324
+ }
12325
+
12326
+ revLookup['-'.charCodeAt(0)] = 62
12327
+ revLookup['_'.charCodeAt(0)] = 63
12328
+
12329
+ function placeHoldersCount (b64) {
12330
+ var len = b64.length
12331
+ if (len % 4 > 0) {
12332
+ throw new Error('Invalid string. Length must be a multiple of 4')
12333
+ }
12334
+
12335
+ // the number of equal signs (place holders)
12336
+ // if there are two placeholders, than the two characters before it
12337
+ // represent one byte
12338
+ // if there is only one, then the three characters before it represent 2 bytes
12339
+ // this is just a cheap hack to not do indexOf twice
12340
+ return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
12341
+ }
12342
+
12343
+ function byteLength (b64) {
12344
+ // base64 is 4/3 + up to two characters of the original data
12345
+ return (b64.length * 3 / 4) - placeHoldersCount(b64)
12346
+ }
12347
+
12348
+ function toByteArray (b64) {
12349
+ var i, l, tmp, placeHolders, arr
12350
+ var len = b64.length
12351
+ placeHolders = placeHoldersCount(b64)
12352
+
12353
+ arr = new Arr((len * 3 / 4) - placeHolders)
12354
+
12355
+ // if there are placeholders, only get up to the last complete 4 chars
12356
+ l = placeHolders > 0 ? len - 4 : len
12357
+
12358
+ var L = 0
12359
+
12360
+ for (i = 0; i < l; i += 4) {
12361
+ tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
12362
+ arr[L++] = (tmp >> 16) & 0xFF
12363
+ arr[L++] = (tmp >> 8) & 0xFF
12364
+ arr[L++] = tmp & 0xFF
12365
+ }
12366
+
12367
+ if (placeHolders === 2) {
12368
+ tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
12369
+ arr[L++] = tmp & 0xFF
12370
+ } else if (placeHolders === 1) {
12371
+ tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
12372
+ arr[L++] = (tmp >> 8) & 0xFF
12373
+ arr[L++] = tmp & 0xFF
12374
+ }
12375
+
12376
+ return arr
12377
+ }
12378
+
12379
+ function tripletToBase64 (num) {
12380
+ return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
12381
+ }
12382
+
12383
+ function encodeChunk (uint8, start, end) {
12384
+ var tmp
12385
+ var output = []
12386
+ for (var i = start; i < end; i += 3) {
12387
+ tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
12388
+ output.push(tripletToBase64(tmp))
12389
+ }
12390
+ return output.join('')
12391
+ }
12392
+
12393
+ function fromByteArray (uint8) {
12394
+ var tmp
12395
+ var len = uint8.length
12396
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
12397
+ var output = ''
12398
+ var parts = []
12399
+ var maxChunkLength = 16383 // must be multiple of 3
12400
+
12401
+ // go through the array every three bytes, we'll deal with trailing stuff later
12402
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
12403
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
12404
+ }
12405
+
12406
+ // pad the end with zeros, but make sure to not forget the extra bytes
12407
+ if (extraBytes === 1) {
12408
+ tmp = uint8[len - 1]
12409
+ output += lookup[tmp >> 2]
12410
+ output += lookup[(tmp << 4) & 0x3F]
12411
+ output += '=='
12412
+ } else if (extraBytes === 2) {
12413
+ tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
12414
+ output += lookup[tmp >> 10]
12415
+ output += lookup[(tmp >> 4) & 0x3F]
12416
+ output += lookup[(tmp << 2) & 0x3F]
12417
+ output += '='
12418
+ }
12419
+
12420
+ parts.push(output)
12421
+
12422
+ return parts.join('')
12423
+ }
12424
+
12425
+ },{}],101:[function(require,module,exports){
12426
+ /*!
12427
+ * The buffer module from node.js, for the browser.
12428
+ *
12429
+ * @author Feross Aboukhadijeh <https://feross.org>
12430
+ * @license MIT
12431
+ */
12432
+ /* eslint-disable no-proto */
12433
+
12434
+ 'use strict'
12435
+
12436
+ var base64 = require('base64-js')
12437
+ var ieee754 = require('ieee754')
12438
+
12439
+ exports.Buffer = Buffer
12440
+ exports.SlowBuffer = SlowBuffer
12441
+ exports.INSPECT_MAX_BYTES = 50
12442
+
12443
+ var K_MAX_LENGTH = 0x7fffffff
12444
+ exports.kMaxLength = K_MAX_LENGTH
12445
+
12446
+ /**
12447
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
12448
+ * === true Use Uint8Array implementation (fastest)
12449
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
12450
+ * implementation (most compatible, even IE6)
12451
+ *
12452
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
12453
+ * Opera 11.6+, iOS 4.2+.
12454
+ *
12455
+ * We report that the browser does not support typed arrays if the are not subclassable
12456
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
12457
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
12458
+ * for __proto__ and has a buggy typed array implementation.
12459
+ */
12460
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
12461
+
12462
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
12463
+ typeof console.error === 'function') {
12464
+ console.error(
12465
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
12466
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
12467
+ )
12468
+ }
12469
+
12470
+ function typedArraySupport () {
12471
+ // Can typed array instances can be augmented?
12472
+ try {
12473
+ var arr = new Uint8Array(1)
12474
+ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
12475
+ return arr.foo() === 42
12476
+ } catch (e) {
12477
+ return false
12478
+ }
12479
+ }
12480
+
12481
+ function createBuffer (length) {
12482
+ if (length > K_MAX_LENGTH) {
12483
+ throw new RangeError('Invalid typed array length')
12484
+ }
12485
+ // Return an augmented `Uint8Array` instance
12486
+ var buf = new Uint8Array(length)
12487
+ buf.__proto__ = Buffer.prototype
12488
+ return buf
12489
+ }
12490
+
12491
+ /**
12492
+ * The Buffer constructor returns instances of `Uint8Array` that have their
12493
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
12494
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
12495
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
12496
+ * returns a single octet.
12497
+ *
12498
+ * The `Uint8Array` prototype remains unmodified.
12499
+ */
12500
+
12501
+ function Buffer (arg, encodingOrOffset, length) {
12502
+ // Common case.
12503
+ if (typeof arg === 'number') {
12504
+ if (typeof encodingOrOffset === 'string') {
12505
+ throw new Error(
12506
+ 'If encoding is specified then the first argument must be a string'
12507
+ )
12508
+ }
12509
+ return allocUnsafe(arg)
12510
+ }
12511
+ return from(arg, encodingOrOffset, length)
12512
+ }
12513
+
12514
+ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
12515
+ if (typeof Symbol !== 'undefined' && Symbol.species &&
12516
+ Buffer[Symbol.species] === Buffer) {
12517
+ Object.defineProperty(Buffer, Symbol.species, {
12518
+ value: null,
12519
+ configurable: true,
12520
+ enumerable: false,
12521
+ writable: false
12522
+ })
12523
+ }
12524
+
12525
+ Buffer.poolSize = 8192 // not used by this implementation
12526
+
12527
+ function from (value, encodingOrOffset, length) {
12528
+ if (typeof value === 'number') {
12529
+ throw new TypeError('"value" argument must not be a number')
12530
+ }
12531
+
12532
+ if (isArrayBuffer(value)) {
12533
+ return fromArrayBuffer(value, encodingOrOffset, length)
12534
+ }
12535
+
12536
+ if (typeof value === 'string') {
12537
+ return fromString(value, encodingOrOffset)
12538
+ }
12539
+
12540
+ return fromObject(value)
12541
+ }
12542
+
12543
+ /**
12544
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
12545
+ * if value is a number.
12546
+ * Buffer.from(str[, encoding])
12547
+ * Buffer.from(array)
12548
+ * Buffer.from(buffer)
12549
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
12550
+ **/
12551
+ Buffer.from = function (value, encodingOrOffset, length) {
12552
+ return from(value, encodingOrOffset, length)
12553
+ }
12554
+
12555
+ // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
12556
+ // https://github.com/feross/buffer/pull/148
12557
+ Buffer.prototype.__proto__ = Uint8Array.prototype
12558
+ Buffer.__proto__ = Uint8Array
12559
+
12560
+ function assertSize (size) {
12561
+ if (typeof size !== 'number') {
12562
+ throw new TypeError('"size" argument must be a number')
12563
+ } else if (size < 0) {
12564
+ throw new RangeError('"size" argument must not be negative')
12565
+ }
12566
+ }
12567
+
12568
+ function alloc (size, fill, encoding) {
12569
+ assertSize(size)
12570
+ if (size <= 0) {
12571
+ return createBuffer(size)
12572
+ }
12573
+ if (fill !== undefined) {
12574
+ // Only pay attention to encoding if it's a string. This
12575
+ // prevents accidentally sending in a number that would
12576
+ // be interpretted as a start offset.
12577
+ return typeof encoding === 'string'
12578
+ ? createBuffer(size).fill(fill, encoding)
12579
+ : createBuffer(size).fill(fill)
12580
+ }
12581
+ return createBuffer(size)
12582
+ }
12583
+
12584
+ /**
12585
+ * Creates a new filled Buffer instance.
12586
+ * alloc(size[, fill[, encoding]])
12587
+ **/
12588
+ Buffer.alloc = function (size, fill, encoding) {
12589
+ return alloc(size, fill, encoding)
12590
+ }
12591
+
12592
+ function allocUnsafe (size) {
12593
+ assertSize(size)
12594
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
12595
+ }
12596
+
12597
+ /**
12598
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
12599
+ * */
12600
+ Buffer.allocUnsafe = function (size) {
12601
+ return allocUnsafe(size)
12602
+ }
12603
+ /**
12604
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
12605
+ */
12606
+ Buffer.allocUnsafeSlow = function (size) {
12607
+ return allocUnsafe(size)
12608
+ }
12609
+
12610
+ function fromString (string, encoding) {
12611
+ if (typeof encoding !== 'string' || encoding === '') {
12612
+ encoding = 'utf8'
12613
+ }
12614
+
12615
+ if (!Buffer.isEncoding(encoding)) {
12616
+ throw new TypeError('"encoding" must be a valid string encoding')
12617
+ }
12618
+
12619
+ var length = byteLength(string, encoding) | 0
12620
+ var buf = createBuffer(length)
12621
+
12622
+ var actual = buf.write(string, encoding)
12623
+
12624
+ if (actual !== length) {
12625
+ // Writing a hex string, for example, that contains invalid characters will
12626
+ // cause everything after the first invalid character to be ignored. (e.g.
12627
+ // 'abxxcd' will be treated as 'ab')
12628
+ buf = buf.slice(0, actual)
12629
+ }
12630
+
12631
+ return buf
12632
+ }
12633
+
12634
+ function fromArrayLike (array) {
12635
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
12636
+ var buf = createBuffer(length)
12637
+ for (var i = 0; i < length; i += 1) {
12638
+ buf[i] = array[i] & 255
12639
+ }
12640
+ return buf
12641
+ }
12642
+
12643
+ function fromArrayBuffer (array, byteOffset, length) {
12644
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
12645
+ throw new RangeError('\'offset\' is out of bounds')
12646
+ }
12647
+
12648
+ if (array.byteLength < byteOffset + (length || 0)) {
12649
+ throw new RangeError('\'length\' is out of bounds')
12650
+ }
12651
+
12652
+ var buf
12653
+ if (byteOffset === undefined && length === undefined) {
12654
+ buf = new Uint8Array(array)
12655
+ } else if (length === undefined) {
12656
+ buf = new Uint8Array(array, byteOffset)
12657
+ } else {
12658
+ buf = new Uint8Array(array, byteOffset, length)
12659
+ }
12660
+
12661
+ // Return an augmented `Uint8Array` instance
12662
+ buf.__proto__ = Buffer.prototype
12663
+ return buf
12664
+ }
12665
+
12666
+ function fromObject (obj) {
12667
+ if (Buffer.isBuffer(obj)) {
12668
+ var len = checked(obj.length) | 0
12669
+ var buf = createBuffer(len)
12670
+
12671
+ if (buf.length === 0) {
12672
+ return buf
12673
+ }
12674
+
12675
+ obj.copy(buf, 0, 0, len)
12676
+ return buf
12677
+ }
12678
+
12679
+ if (obj) {
12680
+ if (isArrayBufferView(obj) || 'length' in obj) {
12681
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
12682
+ return createBuffer(0)
12683
+ }
12684
+ return fromArrayLike(obj)
12685
+ }
12686
+
12687
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
12688
+ return fromArrayLike(obj.data)
12689
+ }
12690
+ }
12691
+
12692
+ throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
12693
+ }
12694
+
12695
+ function checked (length) {
12696
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
12697
+ // length is NaN (which is otherwise coerced to zero.)
12698
+ if (length >= K_MAX_LENGTH) {
12699
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
12700
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
12701
+ }
12702
+ return length | 0
12703
+ }
12704
+
12705
+ function SlowBuffer (length) {
12706
+ if (+length != length) { // eslint-disable-line eqeqeq
12707
+ length = 0
12708
+ }
12709
+ return Buffer.alloc(+length)
12710
+ }
12711
+
12712
+ Buffer.isBuffer = function isBuffer (b) {
12713
+ return b != null && b._isBuffer === true
12714
+ }
12715
+
12716
+ Buffer.compare = function compare (a, b) {
12717
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
12718
+ throw new TypeError('Arguments must be Buffers')
12719
+ }
12720
+
12721
+ if (a === b) return 0
12722
+
12723
+ var x = a.length
12724
+ var y = b.length
12725
+
12726
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
12727
+ if (a[i] !== b[i]) {
12728
+ x = a[i]
12729
+ y = b[i]
12730
+ break
12731
+ }
12732
+ }
12733
+
12734
+ if (x < y) return -1
12735
+ if (y < x) return 1
12736
+ return 0
12737
+ }
12738
+
12739
+ Buffer.isEncoding = function isEncoding (encoding) {
12740
+ switch (String(encoding).toLowerCase()) {
12741
+ case 'hex':
12742
+ case 'utf8':
12743
+ case 'utf-8':
12744
+ case 'ascii':
12745
+ case 'latin1':
12746
+ case 'binary':
12747
+ case 'base64':
12748
+ case 'ucs2':
12749
+ case 'ucs-2':
12750
+ case 'utf16le':
12751
+ case 'utf-16le':
12752
+ return true
12753
+ default:
12754
+ return false
12755
+ }
12756
+ }
12757
+
12758
+ Buffer.concat = function concat (list, length) {
12759
+ if (!Array.isArray(list)) {
12760
+ throw new TypeError('"list" argument must be an Array of Buffers')
12761
+ }
12762
+
12763
+ if (list.length === 0) {
12764
+ return Buffer.alloc(0)
12765
+ }
12766
+
12767
+ var i
12768
+ if (length === undefined) {
12769
+ length = 0
12770
+ for (i = 0; i < list.length; ++i) {
12771
+ length += list[i].length
12772
+ }
12773
+ }
12774
+
12775
+ var buffer = Buffer.allocUnsafe(length)
12776
+ var pos = 0
12777
+ for (i = 0; i < list.length; ++i) {
12778
+ var buf = list[i]
12779
+ if (!Buffer.isBuffer(buf)) {
12780
+ throw new TypeError('"list" argument must be an Array of Buffers')
12781
+ }
12782
+ buf.copy(buffer, pos)
12783
+ pos += buf.length
12784
+ }
12785
+ return buffer
12786
+ }
12787
+
12788
+ function byteLength (string, encoding) {
12789
+ if (Buffer.isBuffer(string)) {
12790
+ return string.length
12791
+ }
12792
+ if (isArrayBufferView(string) || isArrayBuffer(string)) {
12793
+ return string.byteLength
12794
+ }
12795
+ if (typeof string !== 'string') {
12796
+ string = '' + string
12797
+ }
12798
+
12799
+ var len = string.length
12800
+ if (len === 0) return 0
12801
+
12802
+ // Use a for loop to avoid recursion
12803
+ var loweredCase = false
12804
+ for (;;) {
12805
+ switch (encoding) {
12806
+ case 'ascii':
12807
+ case 'latin1':
12808
+ case 'binary':
12809
+ return len
12810
+ case 'utf8':
12811
+ case 'utf-8':
12812
+ case undefined:
12813
+ return utf8ToBytes(string).length
12814
+ case 'ucs2':
12815
+ case 'ucs-2':
12816
+ case 'utf16le':
12817
+ case 'utf-16le':
12818
+ return len * 2
12819
+ case 'hex':
12820
+ return len >>> 1
12821
+ case 'base64':
12822
+ return base64ToBytes(string).length
12823
+ default:
12824
+ if (loweredCase) return utf8ToBytes(string).length // assume utf8
12825
+ encoding = ('' + encoding).toLowerCase()
12826
+ loweredCase = true
12827
+ }
12828
+ }
12829
+ }
12830
+ Buffer.byteLength = byteLength
12831
+
12832
+ function slowToString (encoding, start, end) {
12833
+ var loweredCase = false
12834
+
12835
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
12836
+ // property of a typed array.
12837
+
12838
+ // This behaves neither like String nor Uint8Array in that we set start/end
12839
+ // to their upper/lower bounds if the value passed is out of range.
12840
+ // undefined is handled specially as per ECMA-262 6th Edition,
12841
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
12842
+ if (start === undefined || start < 0) {
12843
+ start = 0
12844
+ }
12845
+ // Return early if start > this.length. Done here to prevent potential uint32
12846
+ // coercion fail below.
12847
+ if (start > this.length) {
12848
+ return ''
12849
+ }
12850
+
12851
+ if (end === undefined || end > this.length) {
12852
+ end = this.length
12853
+ }
12854
+
12855
+ if (end <= 0) {
12856
+ return ''
12857
+ }
12858
+
12859
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
12860
+ end >>>= 0
12861
+ start >>>= 0
12862
+
12863
+ if (end <= start) {
12864
+ return ''
12865
+ }
12866
+
12867
+ if (!encoding) encoding = 'utf8'
12868
+
12869
+ while (true) {
12870
+ switch (encoding) {
12871
+ case 'hex':
12872
+ return hexSlice(this, start, end)
12873
+
12874
+ case 'utf8':
12875
+ case 'utf-8':
12876
+ return utf8Slice(this, start, end)
12877
+
12878
+ case 'ascii':
12879
+ return asciiSlice(this, start, end)
12880
+
12881
+ case 'latin1':
12882
+ case 'binary':
12883
+ return latin1Slice(this, start, end)
12884
+
12885
+ case 'base64':
12886
+ return base64Slice(this, start, end)
12887
+
12888
+ case 'ucs2':
12889
+ case 'ucs-2':
12890
+ case 'utf16le':
12891
+ case 'utf-16le':
12892
+ return utf16leSlice(this, start, end)
12893
+
12894
+ default:
12895
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
12896
+ encoding = (encoding + '').toLowerCase()
12897
+ loweredCase = true
12898
+ }
12899
+ }
12900
+ }
12901
+
12902
+ // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
12903
+ // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
12904
+ // reliably in a browserify context because there could be multiple different
12905
+ // copies of the 'buffer' package in use. This method works even for Buffer
12906
+ // instances that were created from another copy of the `buffer` package.
12907
+ // See: https://github.com/feross/buffer/issues/154
12908
+ Buffer.prototype._isBuffer = true
12909
+
12910
+ function swap (b, n, m) {
12911
+ var i = b[n]
12912
+ b[n] = b[m]
12913
+ b[m] = i
12914
+ }
12915
+
12916
+ Buffer.prototype.swap16 = function swap16 () {
12917
+ var len = this.length
12918
+ if (len % 2 !== 0) {
12919
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
12920
+ }
12921
+ for (var i = 0; i < len; i += 2) {
12922
+ swap(this, i, i + 1)
12923
+ }
12924
+ return this
12925
+ }
12926
+
12927
+ Buffer.prototype.swap32 = function swap32 () {
12928
+ var len = this.length
12929
+ if (len % 4 !== 0) {
12930
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
12931
+ }
12932
+ for (var i = 0; i < len; i += 4) {
12933
+ swap(this, i, i + 3)
12934
+ swap(this, i + 1, i + 2)
12935
+ }
12936
+ return this
12937
+ }
12938
+
12939
+ Buffer.prototype.swap64 = function swap64 () {
12940
+ var len = this.length
12941
+ if (len % 8 !== 0) {
12942
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
12943
+ }
12944
+ for (var i = 0; i < len; i += 8) {
12945
+ swap(this, i, i + 7)
12946
+ swap(this, i + 1, i + 6)
12947
+ swap(this, i + 2, i + 5)
12948
+ swap(this, i + 3, i + 4)
12949
+ }
12950
+ return this
12951
+ }
12952
+
12953
+ Buffer.prototype.toString = function toString () {
12954
+ var length = this.length
12955
+ if (length === 0) return ''
12956
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
12957
+ return slowToString.apply(this, arguments)
12958
+ }
12959
+
12960
+ Buffer.prototype.equals = function equals (b) {
12961
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
12962
+ if (this === b) return true
12963
+ return Buffer.compare(this, b) === 0
12964
+ }
12965
+
12966
+ Buffer.prototype.inspect = function inspect () {
12967
+ var str = ''
12968
+ var max = exports.INSPECT_MAX_BYTES
12969
+ if (this.length > 0) {
12970
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
12971
+ if (this.length > max) str += ' ... '
12972
+ }
12973
+ return '<Buffer ' + str + '>'
12974
+ }
12975
+
12976
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
12977
+ if (!Buffer.isBuffer(target)) {
12978
+ throw new TypeError('Argument must be a Buffer')
12979
+ }
12980
+
12981
+ if (start === undefined) {
12982
+ start = 0
12983
+ }
12984
+ if (end === undefined) {
12985
+ end = target ? target.length : 0
12986
+ }
12987
+ if (thisStart === undefined) {
12988
+ thisStart = 0
12989
+ }
12990
+ if (thisEnd === undefined) {
12991
+ thisEnd = this.length
12992
+ }
12993
+
12994
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
12995
+ throw new RangeError('out of range index')
12996
+ }
12997
+
12998
+ if (thisStart >= thisEnd && start >= end) {
12999
+ return 0
13000
+ }
13001
+ if (thisStart >= thisEnd) {
13002
+ return -1
13003
+ }
13004
+ if (start >= end) {
13005
+ return 1
13006
+ }
13007
+
13008
+ start >>>= 0
13009
+ end >>>= 0
13010
+ thisStart >>>= 0
13011
+ thisEnd >>>= 0
13012
+
13013
+ if (this === target) return 0
13014
+
13015
+ var x = thisEnd - thisStart
13016
+ var y = end - start
13017
+ var len = Math.min(x, y)
13018
+
13019
+ var thisCopy = this.slice(thisStart, thisEnd)
13020
+ var targetCopy = target.slice(start, end)
13021
+
13022
+ for (var i = 0; i < len; ++i) {
13023
+ if (thisCopy[i] !== targetCopy[i]) {
13024
+ x = thisCopy[i]
13025
+ y = targetCopy[i]
13026
+ break
13027
+ }
13028
+ }
13029
+
13030
+ if (x < y) return -1
13031
+ if (y < x) return 1
13032
+ return 0
13033
+ }
13034
+
13035
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
13036
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
13037
+ //
13038
+ // Arguments:
13039
+ // - buffer - a Buffer to search
13040
+ // - val - a string, Buffer, or number
13041
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
13042
+ // - encoding - an optional encoding, relevant is val is a string
13043
+ // - dir - true for indexOf, false for lastIndexOf
13044
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
13045
+ // Empty buffer means no match
13046
+ if (buffer.length === 0) return -1
13047
+
13048
+ // Normalize byteOffset
13049
+ if (typeof byteOffset === 'string') {
13050
+ encoding = byteOffset
13051
+ byteOffset = 0
13052
+ } else if (byteOffset > 0x7fffffff) {
13053
+ byteOffset = 0x7fffffff
13054
+ } else if (byteOffset < -0x80000000) {
13055
+ byteOffset = -0x80000000
13056
+ }
13057
+ byteOffset = +byteOffset // Coerce to Number.
13058
+ if (numberIsNaN(byteOffset)) {
13059
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
13060
+ byteOffset = dir ? 0 : (buffer.length - 1)
13061
+ }
13062
+
13063
+ // Normalize byteOffset: negative offsets start from the end of the buffer
13064
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
13065
+ if (byteOffset >= buffer.length) {
13066
+ if (dir) return -1
13067
+ else byteOffset = buffer.length - 1
13068
+ } else if (byteOffset < 0) {
13069
+ if (dir) byteOffset = 0
13070
+ else return -1
13071
+ }
13072
+
13073
+ // Normalize val
13074
+ if (typeof val === 'string') {
13075
+ val = Buffer.from(val, encoding)
13076
+ }
13077
+
13078
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
13079
+ if (Buffer.isBuffer(val)) {
13080
+ // Special case: looking for empty string/buffer always fails
13081
+ if (val.length === 0) {
13082
+ return -1
13083
+ }
13084
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
13085
+ } else if (typeof val === 'number') {
13086
+ val = val & 0xFF // Search for a byte value [0-255]
13087
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
13088
+ if (dir) {
13089
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
13090
+ } else {
13091
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
13092
+ }
13093
+ }
13094
+ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
13095
+ }
13096
+
13097
+ throw new TypeError('val must be string, number or Buffer')
13098
+ }
13099
+
13100
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
13101
+ var indexSize = 1
13102
+ var arrLength = arr.length
13103
+ var valLength = val.length
13104
+
13105
+ if (encoding !== undefined) {
13106
+ encoding = String(encoding).toLowerCase()
13107
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
13108
+ encoding === 'utf16le' || encoding === 'utf-16le') {
13109
+ if (arr.length < 2 || val.length < 2) {
13110
+ return -1
13111
+ }
13112
+ indexSize = 2
13113
+ arrLength /= 2
13114
+ valLength /= 2
13115
+ byteOffset /= 2
13116
+ }
13117
+ }
13118
+
13119
+ function read (buf, i) {
13120
+ if (indexSize === 1) {
13121
+ return buf[i]
13122
+ } else {
13123
+ return buf.readUInt16BE(i * indexSize)
13124
+ }
13125
+ }
13126
+
13127
+ var i
13128
+ if (dir) {
13129
+ var foundIndex = -1
13130
+ for (i = byteOffset; i < arrLength; i++) {
13131
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
13132
+ if (foundIndex === -1) foundIndex = i
13133
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
13134
+ } else {
13135
+ if (foundIndex !== -1) i -= i - foundIndex
13136
+ foundIndex = -1
13137
+ }
13138
+ }
13139
+ } else {
13140
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
13141
+ for (i = byteOffset; i >= 0; i--) {
13142
+ var found = true
13143
+ for (var j = 0; j < valLength; j++) {
13144
+ if (read(arr, i + j) !== read(val, j)) {
13145
+ found = false
13146
+ break
13147
+ }
13148
+ }
13149
+ if (found) return i
13150
+ }
13151
+ }
13152
+
13153
+ return -1
13154
+ }
13155
+
13156
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
13157
+ return this.indexOf(val, byteOffset, encoding) !== -1
13158
+ }
13159
+
13160
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
13161
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
13162
+ }
13163
+
13164
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
13165
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
13166
+ }
13167
+
13168
+ function hexWrite (buf, string, offset, length) {
13169
+ offset = Number(offset) || 0
13170
+ var remaining = buf.length - offset
13171
+ if (!length) {
13172
+ length = remaining
13173
+ } else {
13174
+ length = Number(length)
13175
+ if (length > remaining) {
13176
+ length = remaining
13177
+ }
13178
+ }
13179
+
13180
+ // must be an even number of digits
13181
+ var strLen = string.length
13182
+ if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
13183
+
13184
+ if (length > strLen / 2) {
13185
+ length = strLen / 2
13186
+ }
13187
+ for (var i = 0; i < length; ++i) {
13188
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
13189
+ if (numberIsNaN(parsed)) return i
13190
+ buf[offset + i] = parsed
13191
+ }
13192
+ return i
13193
+ }
13194
+
13195
+ function utf8Write (buf, string, offset, length) {
13196
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
13197
+ }
13198
+
13199
+ function asciiWrite (buf, string, offset, length) {
13200
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
13201
+ }
13202
+
13203
+ function latin1Write (buf, string, offset, length) {
13204
+ return asciiWrite(buf, string, offset, length)
13205
+ }
13206
+
13207
+ function base64Write (buf, string, offset, length) {
13208
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
13209
+ }
13210
+
13211
+ function ucs2Write (buf, string, offset, length) {
13212
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
13213
+ }
13214
+
13215
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
13216
+ // Buffer#write(string)
13217
+ if (offset === undefined) {
13218
+ encoding = 'utf8'
13219
+ length = this.length
13220
+ offset = 0
13221
+ // Buffer#write(string, encoding)
13222
+ } else if (length === undefined && typeof offset === 'string') {
13223
+ encoding = offset
13224
+ length = this.length
13225
+ offset = 0
13226
+ // Buffer#write(string, offset[, length][, encoding])
13227
+ } else if (isFinite(offset)) {
13228
+ offset = offset >>> 0
13229
+ if (isFinite(length)) {
13230
+ length = length >>> 0
13231
+ if (encoding === undefined) encoding = 'utf8'
13232
+ } else {
13233
+ encoding = length
13234
+ length = undefined
13235
+ }
13236
+ } else {
13237
+ throw new Error(
13238
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
13239
+ )
13240
+ }
13241
+
13242
+ var remaining = this.length - offset
13243
+ if (length === undefined || length > remaining) length = remaining
13244
+
13245
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
13246
+ throw new RangeError('Attempt to write outside buffer bounds')
13247
+ }
13248
+
13249
+ if (!encoding) encoding = 'utf8'
13250
+
13251
+ var loweredCase = false
13252
+ for (;;) {
13253
+ switch (encoding) {
13254
+ case 'hex':
13255
+ return hexWrite(this, string, offset, length)
13256
+
13257
+ case 'utf8':
13258
+ case 'utf-8':
13259
+ return utf8Write(this, string, offset, length)
13260
+
13261
+ case 'ascii':
13262
+ return asciiWrite(this, string, offset, length)
13263
+
13264
+ case 'latin1':
13265
+ case 'binary':
13266
+ return latin1Write(this, string, offset, length)
13267
+
13268
+ case 'base64':
13269
+ // Warning: maxLength not taken into account in base64Write
13270
+ return base64Write(this, string, offset, length)
13271
+
13272
+ case 'ucs2':
13273
+ case 'ucs-2':
13274
+ case 'utf16le':
13275
+ case 'utf-16le':
13276
+ return ucs2Write(this, string, offset, length)
13277
+
13278
+ default:
13279
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
13280
+ encoding = ('' + encoding).toLowerCase()
13281
+ loweredCase = true
13282
+ }
13283
+ }
13284
+ }
13285
+
13286
+ Buffer.prototype.toJSON = function toJSON () {
13287
+ return {
13288
+ type: 'Buffer',
13289
+ data: Array.prototype.slice.call(this._arr || this, 0)
13290
+ }
13291
+ }
13292
+
13293
+ function base64Slice (buf, start, end) {
13294
+ if (start === 0 && end === buf.length) {
13295
+ return base64.fromByteArray(buf)
13296
+ } else {
13297
+ return base64.fromByteArray(buf.slice(start, end))
13298
+ }
13299
+ }
13300
+
13301
+ function utf8Slice (buf, start, end) {
13302
+ end = Math.min(buf.length, end)
13303
+ var res = []
13304
+
13305
+ var i = start
13306
+ while (i < end) {
13307
+ var firstByte = buf[i]
13308
+ var codePoint = null
13309
+ var bytesPerSequence = (firstByte > 0xEF) ? 4
13310
+ : (firstByte > 0xDF) ? 3
13311
+ : (firstByte > 0xBF) ? 2
13312
+ : 1
13313
+
13314
+ if (i + bytesPerSequence <= end) {
13315
+ var secondByte, thirdByte, fourthByte, tempCodePoint
13316
+
13317
+ switch (bytesPerSequence) {
13318
+ case 1:
13319
+ if (firstByte < 0x80) {
13320
+ codePoint = firstByte
13321
+ }
13322
+ break
13323
+ case 2:
13324
+ secondByte = buf[i + 1]
13325
+ if ((secondByte & 0xC0) === 0x80) {
13326
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
13327
+ if (tempCodePoint > 0x7F) {
13328
+ codePoint = tempCodePoint
13329
+ }
13330
+ }
13331
+ break
13332
+ case 3:
13333
+ secondByte = buf[i + 1]
13334
+ thirdByte = buf[i + 2]
13335
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
13336
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
13337
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
13338
+ codePoint = tempCodePoint
13339
+ }
13340
+ }
13341
+ break
13342
+ case 4:
13343
+ secondByte = buf[i + 1]
13344
+ thirdByte = buf[i + 2]
13345
+ fourthByte = buf[i + 3]
13346
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
13347
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
13348
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
13349
+ codePoint = tempCodePoint
13350
+ }
13351
+ }
13352
+ }
13353
+ }
13354
+
13355
+ if (codePoint === null) {
13356
+ // we did not generate a valid codePoint so insert a
13357
+ // replacement char (U+FFFD) and advance only 1 byte
13358
+ codePoint = 0xFFFD
13359
+ bytesPerSequence = 1
13360
+ } else if (codePoint > 0xFFFF) {
13361
+ // encode to utf16 (surrogate pair dance)
13362
+ codePoint -= 0x10000
13363
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
13364
+ codePoint = 0xDC00 | codePoint & 0x3FF
13365
+ }
13366
+
13367
+ res.push(codePoint)
13368
+ i += bytesPerSequence
13369
+ }
13370
+
13371
+ return decodeCodePointsArray(res)
13372
+ }
13373
+
13374
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
13375
+ // the lowest limit is Chrome, with 0x10000 args.
13376
+ // We go 1 magnitude less, for safety
13377
+ var MAX_ARGUMENTS_LENGTH = 0x1000
13378
+
13379
+ function decodeCodePointsArray (codePoints) {
13380
+ var len = codePoints.length
13381
+ if (len <= MAX_ARGUMENTS_LENGTH) {
13382
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
13383
+ }
13384
+
13385
+ // Decode in chunks to avoid "call stack size exceeded".
13386
+ var res = ''
13387
+ var i = 0
13388
+ while (i < len) {
13389
+ res += String.fromCharCode.apply(
13390
+ String,
13391
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
13392
+ )
13393
+ }
13394
+ return res
13395
+ }
13396
+
13397
+ function asciiSlice (buf, start, end) {
13398
+ var ret = ''
13399
+ end = Math.min(buf.length, end)
13400
+
13401
+ for (var i = start; i < end; ++i) {
13402
+ ret += String.fromCharCode(buf[i] & 0x7F)
13403
+ }
13404
+ return ret
13405
+ }
13406
+
13407
+ function latin1Slice (buf, start, end) {
13408
+ var ret = ''
13409
+ end = Math.min(buf.length, end)
13410
+
13411
+ for (var i = start; i < end; ++i) {
13412
+ ret += String.fromCharCode(buf[i])
13413
+ }
13414
+ return ret
13415
+ }
13416
+
13417
+ function hexSlice (buf, start, end) {
13418
+ var len = buf.length
13419
+
13420
+ if (!start || start < 0) start = 0
13421
+ if (!end || end < 0 || end > len) end = len
13422
+
13423
+ var out = ''
13424
+ for (var i = start; i < end; ++i) {
13425
+ out += toHex(buf[i])
13426
+ }
13427
+ return out
13428
+ }
13429
+
13430
+ function utf16leSlice (buf, start, end) {
13431
+ var bytes = buf.slice(start, end)
13432
+ var res = ''
13433
+ for (var i = 0; i < bytes.length; i += 2) {
13434
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
13435
+ }
13436
+ return res
13437
+ }
13438
+
13439
+ Buffer.prototype.slice = function slice (start, end) {
13440
+ var len = this.length
13441
+ start = ~~start
13442
+ end = end === undefined ? len : ~~end
13443
+
13444
+ if (start < 0) {
13445
+ start += len
13446
+ if (start < 0) start = 0
13447
+ } else if (start > len) {
13448
+ start = len
13449
+ }
13450
+
13451
+ if (end < 0) {
13452
+ end += len
13453
+ if (end < 0) end = 0
13454
+ } else if (end > len) {
13455
+ end = len
13456
+ }
13457
+
13458
+ if (end < start) end = start
13459
+
13460
+ var newBuf = this.subarray(start, end)
13461
+ // Return an augmented `Uint8Array` instance
13462
+ newBuf.__proto__ = Buffer.prototype
13463
+ return newBuf
13464
+ }
13465
+
13466
+ /*
13467
+ * Need to make sure that buffer isn't trying to write out of bounds.
13468
+ */
13469
+ function checkOffset (offset, ext, length) {
13470
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
13471
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
13472
+ }
13473
+
13474
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
13475
+ offset = offset >>> 0
13476
+ byteLength = byteLength >>> 0
13477
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
13478
+
13479
+ var val = this[offset]
13480
+ var mul = 1
13481
+ var i = 0
13482
+ while (++i < byteLength && (mul *= 0x100)) {
13483
+ val += this[offset + i] * mul
13484
+ }
13485
+
13486
+ return val
13487
+ }
13488
+
13489
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
13490
+ offset = offset >>> 0
13491
+ byteLength = byteLength >>> 0
13492
+ if (!noAssert) {
13493
+ checkOffset(offset, byteLength, this.length)
13494
+ }
13495
+
13496
+ var val = this[offset + --byteLength]
13497
+ var mul = 1
13498
+ while (byteLength > 0 && (mul *= 0x100)) {
13499
+ val += this[offset + --byteLength] * mul
13500
+ }
13501
+
13502
+ return val
13503
+ }
13504
+
13505
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
13506
+ offset = offset >>> 0
13507
+ if (!noAssert) checkOffset(offset, 1, this.length)
13508
+ return this[offset]
13509
+ }
13510
+
13511
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
13512
+ offset = offset >>> 0
13513
+ if (!noAssert) checkOffset(offset, 2, this.length)
13514
+ return this[offset] | (this[offset + 1] << 8)
13515
+ }
13516
+
13517
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
13518
+ offset = offset >>> 0
13519
+ if (!noAssert) checkOffset(offset, 2, this.length)
13520
+ return (this[offset] << 8) | this[offset + 1]
13521
+ }
13522
+
13523
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
13524
+ offset = offset >>> 0
13525
+ if (!noAssert) checkOffset(offset, 4, this.length)
13526
+
13527
+ return ((this[offset]) |
13528
+ (this[offset + 1] << 8) |
13529
+ (this[offset + 2] << 16)) +
13530
+ (this[offset + 3] * 0x1000000)
13531
+ }
13532
+
13533
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
13534
+ offset = offset >>> 0
13535
+ if (!noAssert) checkOffset(offset, 4, this.length)
13536
+
13537
+ return (this[offset] * 0x1000000) +
13538
+ ((this[offset + 1] << 16) |
13539
+ (this[offset + 2] << 8) |
13540
+ this[offset + 3])
13541
+ }
13542
+
13543
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
13544
+ offset = offset >>> 0
13545
+ byteLength = byteLength >>> 0
13546
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
13547
+
13548
+ var val = this[offset]
13549
+ var mul = 1
13550
+ var i = 0
13551
+ while (++i < byteLength && (mul *= 0x100)) {
13552
+ val += this[offset + i] * mul
13553
+ }
13554
+ mul *= 0x80
13555
+
13556
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
13557
+
13558
+ return val
13559
+ }
13560
+
13561
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
13562
+ offset = offset >>> 0
13563
+ byteLength = byteLength >>> 0
13564
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
13565
+
13566
+ var i = byteLength
13567
+ var mul = 1
13568
+ var val = this[offset + --i]
13569
+ while (i > 0 && (mul *= 0x100)) {
13570
+ val += this[offset + --i] * mul
13571
+ }
13572
+ mul *= 0x80
13573
+
13574
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
13575
+
13576
+ return val
13577
+ }
13578
+
13579
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
13580
+ offset = offset >>> 0
13581
+ if (!noAssert) checkOffset(offset, 1, this.length)
13582
+ if (!(this[offset] & 0x80)) return (this[offset])
13583
+ return ((0xff - this[offset] + 1) * -1)
13584
+ }
13585
+
13586
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
13587
+ offset = offset >>> 0
13588
+ if (!noAssert) checkOffset(offset, 2, this.length)
13589
+ var val = this[offset] | (this[offset + 1] << 8)
13590
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
13591
+ }
13592
+
13593
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
13594
+ offset = offset >>> 0
13595
+ if (!noAssert) checkOffset(offset, 2, this.length)
13596
+ var val = this[offset + 1] | (this[offset] << 8)
13597
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
13598
+ }
13599
+
13600
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
13601
+ offset = offset >>> 0
13602
+ if (!noAssert) checkOffset(offset, 4, this.length)
13603
+
13604
+ return (this[offset]) |
13605
+ (this[offset + 1] << 8) |
13606
+ (this[offset + 2] << 16) |
13607
+ (this[offset + 3] << 24)
13608
+ }
13609
+
13610
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
13611
+ offset = offset >>> 0
13612
+ if (!noAssert) checkOffset(offset, 4, this.length)
13613
+
13614
+ return (this[offset] << 24) |
13615
+ (this[offset + 1] << 16) |
13616
+ (this[offset + 2] << 8) |
13617
+ (this[offset + 3])
13618
+ }
13619
+
13620
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
13621
+ offset = offset >>> 0
13622
+ if (!noAssert) checkOffset(offset, 4, this.length)
13623
+ return ieee754.read(this, offset, true, 23, 4)
13624
+ }
13625
+
13626
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
13627
+ offset = offset >>> 0
13628
+ if (!noAssert) checkOffset(offset, 4, this.length)
13629
+ return ieee754.read(this, offset, false, 23, 4)
13630
+ }
13631
+
13632
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
13633
+ offset = offset >>> 0
13634
+ if (!noAssert) checkOffset(offset, 8, this.length)
13635
+ return ieee754.read(this, offset, true, 52, 8)
13636
+ }
13637
+
13638
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
13639
+ offset = offset >>> 0
13640
+ if (!noAssert) checkOffset(offset, 8, this.length)
13641
+ return ieee754.read(this, offset, false, 52, 8)
13642
+ }
13643
+
13644
+ function checkInt (buf, value, offset, ext, max, min) {
13645
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
13646
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
13647
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
13648
+ }
13649
+
13650
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
13651
+ value = +value
13652
+ offset = offset >>> 0
13653
+ byteLength = byteLength >>> 0
13654
+ if (!noAssert) {
13655
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
13656
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
13657
+ }
13658
+
13659
+ var mul = 1
13660
+ var i = 0
13661
+ this[offset] = value & 0xFF
13662
+ while (++i < byteLength && (mul *= 0x100)) {
13663
+ this[offset + i] = (value / mul) & 0xFF
13664
+ }
13665
+
13666
+ return offset + byteLength
13667
+ }
13668
+
13669
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
13670
+ value = +value
13671
+ offset = offset >>> 0
13672
+ byteLength = byteLength >>> 0
13673
+ if (!noAssert) {
13674
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
13675
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
13676
+ }
13677
+
13678
+ var i = byteLength - 1
13679
+ var mul = 1
13680
+ this[offset + i] = value & 0xFF
13681
+ while (--i >= 0 && (mul *= 0x100)) {
13682
+ this[offset + i] = (value / mul) & 0xFF
13683
+ }
13684
+
13685
+ return offset + byteLength
13686
+ }
13687
+
13688
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
13689
+ value = +value
13690
+ offset = offset >>> 0
13691
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
13692
+ this[offset] = (value & 0xff)
13693
+ return offset + 1
13694
+ }
13695
+
13696
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
13697
+ value = +value
13698
+ offset = offset >>> 0
13699
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
13700
+ this[offset] = (value & 0xff)
13701
+ this[offset + 1] = (value >>> 8)
13702
+ return offset + 2
13703
+ }
13704
+
13705
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
13706
+ value = +value
13707
+ offset = offset >>> 0
13708
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
13709
+ this[offset] = (value >>> 8)
13710
+ this[offset + 1] = (value & 0xff)
13711
+ return offset + 2
13712
+ }
13713
+
13714
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
13715
+ value = +value
13716
+ offset = offset >>> 0
13717
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
13718
+ this[offset + 3] = (value >>> 24)
13719
+ this[offset + 2] = (value >>> 16)
13720
+ this[offset + 1] = (value >>> 8)
13721
+ this[offset] = (value & 0xff)
13722
+ return offset + 4
13723
+ }
13724
+
13725
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
13726
+ value = +value
13727
+ offset = offset >>> 0
13728
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
13729
+ this[offset] = (value >>> 24)
13730
+ this[offset + 1] = (value >>> 16)
13731
+ this[offset + 2] = (value >>> 8)
13732
+ this[offset + 3] = (value & 0xff)
13733
+ return offset + 4
13734
+ }
13735
+
13736
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
13737
+ value = +value
13738
+ offset = offset >>> 0
13739
+ if (!noAssert) {
13740
+ var limit = Math.pow(2, (8 * byteLength) - 1)
13741
+
13742
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
13743
+ }
13744
+
13745
+ var i = 0
13746
+ var mul = 1
13747
+ var sub = 0
13748
+ this[offset] = value & 0xFF
13749
+ while (++i < byteLength && (mul *= 0x100)) {
13750
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
13751
+ sub = 1
13752
+ }
13753
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
13754
+ }
13755
+
13756
+ return offset + byteLength
13757
+ }
13758
+
13759
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
13760
+ value = +value
13761
+ offset = offset >>> 0
13762
+ if (!noAssert) {
13763
+ var limit = Math.pow(2, (8 * byteLength) - 1)
13764
+
13765
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
13766
+ }
13767
+
13768
+ var i = byteLength - 1
13769
+ var mul = 1
13770
+ var sub = 0
13771
+ this[offset + i] = value & 0xFF
13772
+ while (--i >= 0 && (mul *= 0x100)) {
13773
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
13774
+ sub = 1
13775
+ }
13776
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
13777
+ }
13778
+
13779
+ return offset + byteLength
13780
+ }
13781
+
13782
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
13783
+ value = +value
13784
+ offset = offset >>> 0
13785
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
13786
+ if (value < 0) value = 0xff + value + 1
13787
+ this[offset] = (value & 0xff)
13788
+ return offset + 1
13789
+ }
13790
+
13791
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
13792
+ value = +value
13793
+ offset = offset >>> 0
13794
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
13795
+ this[offset] = (value & 0xff)
13796
+ this[offset + 1] = (value >>> 8)
13797
+ return offset + 2
13798
+ }
13799
+
13800
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
13801
+ value = +value
13802
+ offset = offset >>> 0
13803
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
13804
+ this[offset] = (value >>> 8)
13805
+ this[offset + 1] = (value & 0xff)
13806
+ return offset + 2
13807
+ }
13808
+
13809
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
13810
+ value = +value
13811
+ offset = offset >>> 0
13812
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
13813
+ this[offset] = (value & 0xff)
13814
+ this[offset + 1] = (value >>> 8)
13815
+ this[offset + 2] = (value >>> 16)
13816
+ this[offset + 3] = (value >>> 24)
13817
+ return offset + 4
13818
+ }
13819
+
13820
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
13821
+ value = +value
13822
+ offset = offset >>> 0
13823
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
13824
+ if (value < 0) value = 0xffffffff + value + 1
13825
+ this[offset] = (value >>> 24)
13826
+ this[offset + 1] = (value >>> 16)
13827
+ this[offset + 2] = (value >>> 8)
13828
+ this[offset + 3] = (value & 0xff)
13829
+ return offset + 4
13830
+ }
13831
+
13832
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
13833
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
13834
+ if (offset < 0) throw new RangeError('Index out of range')
13835
+ }
13836
+
13837
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
13838
+ value = +value
13839
+ offset = offset >>> 0
13840
+ if (!noAssert) {
13841
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
13842
+ }
13843
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
13844
+ return offset + 4
13845
+ }
13846
+
13847
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
13848
+ return writeFloat(this, value, offset, true, noAssert)
13849
+ }
13850
+
13851
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
13852
+ return writeFloat(this, value, offset, false, noAssert)
13853
+ }
13854
+
13855
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
13856
+ value = +value
13857
+ offset = offset >>> 0
13858
+ if (!noAssert) {
13859
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
13860
+ }
13861
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
13862
+ return offset + 8
13863
+ }
13864
+
13865
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
13866
+ return writeDouble(this, value, offset, true, noAssert)
13867
+ }
13868
+
13869
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
13870
+ return writeDouble(this, value, offset, false, noAssert)
13871
+ }
13872
+
13873
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
13874
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
13875
+ if (!start) start = 0
13876
+ if (!end && end !== 0) end = this.length
13877
+ if (targetStart >= target.length) targetStart = target.length
13878
+ if (!targetStart) targetStart = 0
13879
+ if (end > 0 && end < start) end = start
13880
+
13881
+ // Copy 0 bytes; we're done
13882
+ if (end === start) return 0
13883
+ if (target.length === 0 || this.length === 0) return 0
13884
+
13885
+ // Fatal error conditions
13886
+ if (targetStart < 0) {
13887
+ throw new RangeError('targetStart out of bounds')
13888
+ }
13889
+ if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
13890
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
13891
+
13892
+ // Are we oob?
13893
+ if (end > this.length) end = this.length
13894
+ if (target.length - targetStart < end - start) {
13895
+ end = target.length - targetStart + start
13896
+ }
13897
+
13898
+ var len = end - start
13899
+ var i
13900
+
13901
+ if (this === target && start < targetStart && targetStart < end) {
13902
+ // descending copy from end
13903
+ for (i = len - 1; i >= 0; --i) {
13904
+ target[i + targetStart] = this[i + start]
13905
+ }
13906
+ } else if (len < 1000) {
13907
+ // ascending copy from start
13908
+ for (i = 0; i < len; ++i) {
13909
+ target[i + targetStart] = this[i + start]
13910
+ }
13911
+ } else {
13912
+ Uint8Array.prototype.set.call(
13913
+ target,
13914
+ this.subarray(start, start + len),
13915
+ targetStart
13916
+ )
13917
+ }
13918
+
13919
+ return len
13920
+ }
13921
+
13922
+ // Usage:
13923
+ // buffer.fill(number[, offset[, end]])
13924
+ // buffer.fill(buffer[, offset[, end]])
13925
+ // buffer.fill(string[, offset[, end]][, encoding])
13926
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
13927
+ // Handle string cases:
13928
+ if (typeof val === 'string') {
13929
+ if (typeof start === 'string') {
13930
+ encoding = start
13931
+ start = 0
13932
+ end = this.length
13933
+ } else if (typeof end === 'string') {
13934
+ encoding = end
13935
+ end = this.length
13936
+ }
13937
+ if (val.length === 1) {
13938
+ var code = val.charCodeAt(0)
13939
+ if (code < 256) {
13940
+ val = code
13941
+ }
13942
+ }
13943
+ if (encoding !== undefined && typeof encoding !== 'string') {
13944
+ throw new TypeError('encoding must be a string')
13945
+ }
13946
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
13947
+ throw new TypeError('Unknown encoding: ' + encoding)
13948
+ }
13949
+ } else if (typeof val === 'number') {
13950
+ val = val & 255
13951
+ }
13952
+
13953
+ // Invalid ranges are not set to a default, so can range check early.
13954
+ if (start < 0 || this.length < start || this.length < end) {
13955
+ throw new RangeError('Out of range index')
13956
+ }
13957
+
13958
+ if (end <= start) {
13959
+ return this
13960
+ }
13961
+
13962
+ start = start >>> 0
13963
+ end = end === undefined ? this.length : end >>> 0
13964
+
13965
+ if (!val) val = 0
13966
+
13967
+ var i
13968
+ if (typeof val === 'number') {
13969
+ for (i = start; i < end; ++i) {
13970
+ this[i] = val
13971
+ }
13972
+ } else {
13973
+ var bytes = Buffer.isBuffer(val)
13974
+ ? val
13975
+ : new Buffer(val, encoding)
13976
+ var len = bytes.length
13977
+ for (i = 0; i < end - start; ++i) {
13978
+ this[i + start] = bytes[i % len]
13979
+ }
13980
+ }
13981
+
13982
+ return this
13983
+ }
13984
+
13985
+ // HELPER FUNCTIONS
13986
+ // ================
13987
+
13988
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
13989
+
13990
+ function base64clean (str) {
13991
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
13992
+ str = str.trim().replace(INVALID_BASE64_RE, '')
13993
+ // Node converts strings with length < 2 to ''
13994
+ if (str.length < 2) return ''
13995
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
13996
+ while (str.length % 4 !== 0) {
13997
+ str = str + '='
13998
+ }
13999
+ return str
14000
+ }
14001
+
14002
+ function toHex (n) {
14003
+ if (n < 16) return '0' + n.toString(16)
14004
+ return n.toString(16)
14005
+ }
14006
+
14007
+ function utf8ToBytes (string, units) {
14008
+ units = units || Infinity
14009
+ var codePoint
14010
+ var length = string.length
14011
+ var leadSurrogate = null
14012
+ var bytes = []
14013
+
14014
+ for (var i = 0; i < length; ++i) {
14015
+ codePoint = string.charCodeAt(i)
14016
+
14017
+ // is surrogate component
14018
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
14019
+ // last char was a lead
14020
+ if (!leadSurrogate) {
14021
+ // no lead yet
14022
+ if (codePoint > 0xDBFF) {
14023
+ // unexpected trail
14024
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14025
+ continue
14026
+ } else if (i + 1 === length) {
14027
+ // unpaired lead
14028
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14029
+ continue
14030
+ }
14031
+
14032
+ // valid lead
14033
+ leadSurrogate = codePoint
14034
+
14035
+ continue
14036
+ }
14037
+
14038
+ // 2 leads in a row
14039
+ if (codePoint < 0xDC00) {
14040
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14041
+ leadSurrogate = codePoint
14042
+ continue
14043
+ }
14044
+
14045
+ // valid surrogate pair
14046
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
14047
+ } else if (leadSurrogate) {
14048
+ // valid bmp char, but last char was a lead
14049
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
14050
+ }
14051
+
14052
+ leadSurrogate = null
14053
+
14054
+ // encode utf8
14055
+ if (codePoint < 0x80) {
14056
+ if ((units -= 1) < 0) break
14057
+ bytes.push(codePoint)
14058
+ } else if (codePoint < 0x800) {
14059
+ if ((units -= 2) < 0) break
14060
+ bytes.push(
14061
+ codePoint >> 0x6 | 0xC0,
14062
+ codePoint & 0x3F | 0x80
14063
+ )
14064
+ } else if (codePoint < 0x10000) {
14065
+ if ((units -= 3) < 0) break
14066
+ bytes.push(
14067
+ codePoint >> 0xC | 0xE0,
14068
+ codePoint >> 0x6 & 0x3F | 0x80,
14069
+ codePoint & 0x3F | 0x80
14070
+ )
14071
+ } else if (codePoint < 0x110000) {
14072
+ if ((units -= 4) < 0) break
14073
+ bytes.push(
14074
+ codePoint >> 0x12 | 0xF0,
14075
+ codePoint >> 0xC & 0x3F | 0x80,
14076
+ codePoint >> 0x6 & 0x3F | 0x80,
14077
+ codePoint & 0x3F | 0x80
14078
+ )
14079
+ } else {
14080
+ throw new Error('Invalid code point')
14081
+ }
14082
+ }
14083
+
14084
+ return bytes
14085
+ }
14086
+
14087
+ function asciiToBytes (str) {
14088
+ var byteArray = []
14089
+ for (var i = 0; i < str.length; ++i) {
14090
+ // Node's code seems to be doing this and not & 0x7F..
14091
+ byteArray.push(str.charCodeAt(i) & 0xFF)
14092
+ }
14093
+ return byteArray
14094
+ }
14095
+
14096
+ function utf16leToBytes (str, units) {
14097
+ var c, hi, lo
14098
+ var byteArray = []
14099
+ for (var i = 0; i < str.length; ++i) {
14100
+ if ((units -= 2) < 0) break
14101
+
14102
+ c = str.charCodeAt(i)
14103
+ hi = c >> 8
14104
+ lo = c % 256
14105
+ byteArray.push(lo)
14106
+ byteArray.push(hi)
14107
+ }
14108
+
14109
+ return byteArray
14110
+ }
14111
+
14112
+ function base64ToBytes (str) {
14113
+ return base64.toByteArray(base64clean(str))
14114
+ }
14115
+
14116
+ function blitBuffer (src, dst, offset, length) {
14117
+ for (var i = 0; i < length; ++i) {
14118
+ if ((i + offset >= dst.length) || (i >= src.length)) break
14119
+ dst[i + offset] = src[i]
14120
+ }
14121
+ return i
14122
+ }
14123
+
14124
+ // ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
14125
+ // but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
14126
+ function isArrayBuffer (obj) {
14127
+ return obj instanceof ArrayBuffer ||
14128
+ (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
14129
+ typeof obj.byteLength === 'number')
14130
+ }
14131
+
14132
+ // Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`
14133
+ function isArrayBufferView (obj) {
14134
+ return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
14135
+ }
14136
+
14137
+ function numberIsNaN (obj) {
14138
+ return obj !== obj // eslint-disable-line no-self-compare
14139
+ }
14140
+
14141
+ },{"base64-js":100,"ieee754":103}],102:[function(require,module,exports){
14142
+ (function (Buffer){
14143
+ var clone = (function() {
14144
+ 'use strict';
14145
+
14146
+ function _instanceof(obj, type) {
14147
+ return type != null && obj instanceof type;
14148
+ }
14149
+
14150
+ var nativeMap;
14151
+ try {
14152
+ nativeMap = Map;
14153
+ } catch(_) {
14154
+ // maybe a reference error because no `Map`. Give it a dummy value that no
14155
+ // value will ever be an instanceof.
14156
+ nativeMap = function() {};
14157
+ }
14158
+
14159
+ var nativeSet;
14160
+ try {
14161
+ nativeSet = Set;
14162
+ } catch(_) {
14163
+ nativeSet = function() {};
14164
+ }
14165
+
14166
+ var nativePromise;
14167
+ try {
14168
+ nativePromise = Promise;
14169
+ } catch(_) {
14170
+ nativePromise = function() {};
14171
+ }
14172
+
14173
+ /**
14174
+ * Clones (copies) an Object using deep copying.
14175
+ *
14176
+ * This function supports circular references by default, but if you are certain
14177
+ * there are no circular references in your object, you can save some CPU time
14178
+ * by calling clone(obj, false).
14179
+ *
14180
+ * Caution: if `circular` is false and `parent` contains circular references,
14181
+ * your program may enter an infinite loop and crash.
14182
+ *
14183
+ * @param `parent` - the object to be cloned
14184
+ * @param `circular` - set to true if the object to be cloned may contain
14185
+ * circular references. (optional - true by default)
14186
+ * @param `depth` - set to a number if the object is only to be cloned to
14187
+ * a particular depth. (optional - defaults to Infinity)
14188
+ * @param `prototype` - sets the prototype to be used when cloning an object.
14189
+ * (optional - defaults to parent prototype).
14190
+ * @param `includeNonEnumerable` - set to true if the non-enumerable properties
14191
+ * should be cloned as well. Non-enumerable properties on the prototype
14192
+ * chain will be ignored. (optional - false by default)
14193
+ */
14194
+ function clone(parent, circular, depth, prototype, includeNonEnumerable) {
14195
+ if (typeof circular === 'object') {
14196
+ depth = circular.depth;
14197
+ prototype = circular.prototype;
14198
+ includeNonEnumerable = circular.includeNonEnumerable;
14199
+ circular = circular.circular;
14200
+ }
14201
+ // maintain two arrays for circular references, where corresponding parents
14202
+ // and children have the same index
14203
+ var allParents = [];
14204
+ var allChildren = [];
14205
+
14206
+ var useBuffer = typeof Buffer != 'undefined';
14207
+
14208
+ if (typeof circular == 'undefined')
14209
+ circular = true;
14210
+
14211
+ if (typeof depth == 'undefined')
14212
+ depth = Infinity;
14213
+
14214
+ // recurse this function so we don't reset allParents and allChildren
14215
+ function _clone(parent, depth) {
14216
+ // cloning null always returns null
14217
+ if (parent === null)
14218
+ return null;
14219
+
14220
+ if (depth === 0)
14221
+ return parent;
14222
+
14223
+ var child;
14224
+ var proto;
14225
+ if (typeof parent != 'object') {
14226
+ return parent;
14227
+ }
14228
+
14229
+ if (_instanceof(parent, nativeMap)) {
14230
+ child = new nativeMap();
14231
+ } else if (_instanceof(parent, nativeSet)) {
14232
+ child = new nativeSet();
14233
+ } else if (_instanceof(parent, nativePromise)) {
14234
+ child = new nativePromise(function (resolve, reject) {
14235
+ parent.then(function(value) {
14236
+ resolve(_clone(value, depth - 1));
14237
+ }, function(err) {
14238
+ reject(_clone(err, depth - 1));
14239
+ });
14240
+ });
14241
+ } else if (clone.__isArray(parent)) {
14242
+ child = [];
14243
+ } else if (clone.__isRegExp(parent)) {
14244
+ child = new RegExp(parent.source, __getRegExpFlags(parent));
14245
+ if (parent.lastIndex) child.lastIndex = parent.lastIndex;
14246
+ } else if (clone.__isDate(parent)) {
14247
+ child = new Date(parent.getTime());
14248
+ } else if (useBuffer && Buffer.isBuffer(parent)) {
14249
+ if (Buffer.allocUnsafe) {
14250
+ // Node.js >= 4.5.0
14251
+ child = Buffer.allocUnsafe(parent.length);
14252
+ } else {
14253
+ // Older Node.js versions
14254
+ child = new Buffer(parent.length);
14255
+ }
14256
+ parent.copy(child);
14257
+ return child;
14258
+ } else if (_instanceof(parent, Error)) {
14259
+ child = Object.create(parent);
14260
+ } else {
14261
+ if (typeof prototype == 'undefined') {
14262
+ proto = Object.getPrototypeOf(parent);
14263
+ child = Object.create(proto);
14264
+ }
14265
+ else {
14266
+ child = Object.create(prototype);
14267
+ proto = prototype;
14268
+ }
14269
+ }
14270
+
14271
+ if (circular) {
14272
+ var index = allParents.indexOf(parent);
14273
+
14274
+ if (index != -1) {
14275
+ return allChildren[index];
14276
+ }
14277
+ allParents.push(parent);
14278
+ allChildren.push(child);
14279
+ }
14280
+
14281
+ if (_instanceof(parent, nativeMap)) {
14282
+ parent.forEach(function(value, key) {
14283
+ var keyChild = _clone(key, depth - 1);
14284
+ var valueChild = _clone(value, depth - 1);
14285
+ child.set(keyChild, valueChild);
14286
+ });
14287
+ }
14288
+ if (_instanceof(parent, nativeSet)) {
14289
+ parent.forEach(function(value) {
14290
+ var entryChild = _clone(value, depth - 1);
14291
+ child.add(entryChild);
14292
+ });
14293
+ }
14294
+
14295
+ for (var i in parent) {
14296
+ var attrs;
14297
+ if (proto) {
14298
+ attrs = Object.getOwnPropertyDescriptor(proto, i);
14299
+ }
14300
+
14301
+ if (attrs && attrs.set == null) {
14302
+ continue;
14303
+ }
14304
+ child[i] = _clone(parent[i], depth - 1);
14305
+ }
14306
+
14307
+ if (Object.getOwnPropertySymbols) {
14308
+ var symbols = Object.getOwnPropertySymbols(parent);
14309
+ for (var i = 0; i < symbols.length; i++) {
14310
+ // Don't need to worry about cloning a symbol because it is a primitive,
14311
+ // like a number or string.
14312
+ var symbol = symbols[i];
14313
+ var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
14314
+ if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
14315
+ continue;
14316
+ }
14317
+ child[symbol] = _clone(parent[symbol], depth - 1);
14318
+ if (!descriptor.enumerable) {
14319
+ Object.defineProperty(child, symbol, {
14320
+ enumerable: false
14321
+ });
14322
+ }
14323
+ }
14324
+ }
14325
+
14326
+ if (includeNonEnumerable) {
14327
+ var allPropertyNames = Object.getOwnPropertyNames(parent);
14328
+ for (var i = 0; i < allPropertyNames.length; i++) {
14329
+ var propertyName = allPropertyNames[i];
14330
+ var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
14331
+ if (descriptor && descriptor.enumerable) {
14332
+ continue;
14333
+ }
14334
+ child[propertyName] = _clone(parent[propertyName], depth - 1);
14335
+ Object.defineProperty(child, propertyName, {
14336
+ enumerable: false
14337
+ });
14338
+ }
14339
+ }
14340
+
14341
+ return child;
14342
+ }
14343
+
14344
+ return _clone(parent, depth);
14345
+ }
14346
+
14347
+ /**
14348
+ * Simple flat clone using prototype, accepts only objects, usefull for property
14349
+ * override on FLAT configuration object (no nested props).
14350
+ *
14351
+ * USE WITH CAUTION! This may not behave as you wish if you do not know how this
14352
+ * works.
14353
+ */
14354
+ clone.clonePrototype = function clonePrototype(parent) {
14355
+ if (parent === null)
14356
+ return null;
14357
+
14358
+ var c = function () {};
14359
+ c.prototype = parent;
14360
+ return new c();
14361
+ };
14362
+
14363
+ // private utility functions
14364
+
14365
+ function __objToStr(o) {
14366
+ return Object.prototype.toString.call(o);
14367
+ }
14368
+ clone.__objToStr = __objToStr;
14369
+
14370
+ function __isDate(o) {
14371
+ return typeof o === 'object' && __objToStr(o) === '[object Date]';
14372
+ }
14373
+ clone.__isDate = __isDate;
14374
+
14375
+ function __isArray(o) {
14376
+ return typeof o === 'object' && __objToStr(o) === '[object Array]';
14377
+ }
14378
+ clone.__isArray = __isArray;
14379
+
14380
+ function __isRegExp(o) {
14381
+ return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
14382
+ }
14383
+ clone.__isRegExp = __isRegExp;
14384
+
14385
+ function __getRegExpFlags(re) {
14386
+ var flags = '';
14387
+ if (re.global) flags += 'g';
14388
+ if (re.ignoreCase) flags += 'i';
14389
+ if (re.multiline) flags += 'm';
14390
+ return flags;
14391
+ }
14392
+ clone.__getRegExpFlags = __getRegExpFlags;
14393
+
14394
+ return clone;
14395
+ })();
14396
+
14397
+ if (typeof module === 'object' && module.exports) {
14398
+ module.exports = clone;
14399
+ }
14400
+
14401
+ }).call(this,require("buffer").Buffer)
14402
+ },{"buffer":101}],103:[function(require,module,exports){
14403
+ exports.read = function (buffer, offset, isLE, mLen, nBytes) {
14404
+ var e, m
14405
+ var eLen = nBytes * 8 - mLen - 1
14406
+ var eMax = (1 << eLen) - 1
14407
+ var eBias = eMax >> 1
14408
+ var nBits = -7
14409
+ var i = isLE ? (nBytes - 1) : 0
14410
+ var d = isLE ? -1 : 1
14411
+ var s = buffer[offset + i]
14412
+
14413
+ i += d
14414
+
14415
+ e = s & ((1 << (-nBits)) - 1)
14416
+ s >>= (-nBits)
14417
+ nBits += eLen
14418
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
14419
+
14420
+ m = e & ((1 << (-nBits)) - 1)
14421
+ e >>= (-nBits)
14422
+ nBits += mLen
14423
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
14424
+
14425
+ if (e === 0) {
14426
+ e = 1 - eBias
14427
+ } else if (e === eMax) {
14428
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
14429
+ } else {
14430
+ m = m + Math.pow(2, mLen)
14431
+ e = e - eBias
14432
+ }
14433
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
14434
+ }
14435
+
14436
+ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
14437
+ var e, m, c
14438
+ var eLen = nBytes * 8 - mLen - 1
14439
+ var eMax = (1 << eLen) - 1
14440
+ var eBias = eMax >> 1
14441
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
14442
+ var i = isLE ? 0 : (nBytes - 1)
14443
+ var d = isLE ? 1 : -1
14444
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
14445
+
14446
+ value = Math.abs(value)
14447
+
14448
+ if (isNaN(value) || value === Infinity) {
14449
+ m = isNaN(value) ? 1 : 0
14450
+ e = eMax
14451
+ } else {
14452
+ e = Math.floor(Math.log(value) / Math.LN2)
14453
+ if (value * (c = Math.pow(2, -e)) < 1) {
14454
+ e--
14455
+ c *= 2
14456
+ }
14457
+ if (e + eBias >= 1) {
14458
+ value += rt / c
14459
+ } else {
14460
+ value += rt * Math.pow(2, 1 - eBias)
14461
+ }
14462
+ if (value * c >= 2) {
14463
+ e++
14464
+ c /= 2
14465
+ }
14466
+
14467
+ if (e + eBias >= eMax) {
14468
+ m = 0
14469
+ e = eMax
14470
+ } else if (e + eBias >= 1) {
14471
+ m = (value * c - 1) * Math.pow(2, mLen)
14472
+ e = e + eBias
14473
+ } else {
14474
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
14475
+ e = 0
14476
+ }
14477
+ }
14478
+
14479
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
14480
+
14481
+ e = (e << mLen) | m
14482
+ eLen += mLen
14483
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
14484
+
14485
+ buffer[offset + i - d] |= s * 128
14486
+ }
14487
+
14488
+ },{}],104:[function(require,module,exports){
12235
14489
  'use strict';
12236
14490
 
12237
14491
  var asap = require('asap/raw');
@@ -12446,7 +14700,7 @@ function doResolve(fn, promise) {
12446
14700
  }
12447
14701
  }
12448
14702
 
12449
- },{"asap/raw":99}],101:[function(require,module,exports){
14703
+ },{"asap/raw":99}],105:[function(require,module,exports){
12450
14704
  'use strict';
12451
14705
 
12452
14706
  //This file contains the ES6 extensions to the core Promises/A+ API
@@ -12555,7 +14809,7 @@ Promise.prototype['catch'] = function (onRejected) {
12555
14809
  return this.then(null, onRejected);
12556
14810
  };
12557
14811
 
12558
- },{"./core.js":100}],102:[function(require,module,exports){
14812
+ },{"./core.js":104}],106:[function(require,module,exports){
12559
14813
  // should work in any browser without browserify
12560
14814
 
12561
14815
  if (typeof Promise.prototype.done !== 'function') {
@@ -12568,7 +14822,7 @@ if (typeof Promise.prototype.done !== 'function') {
12568
14822
  })
12569
14823
  }
12570
14824
  }
12571
- },{}],103:[function(require,module,exports){
14825
+ },{}],107:[function(require,module,exports){
12572
14826
  // not "use strict" so we can declare global "Promise"
12573
14827
 
12574
14828
  var asap = require('asap');
@@ -12580,5 +14834,5 @@ if (typeof Promise === 'undefined') {
12580
14834
 
12581
14835
  require('./polyfill-done.js');
12582
14836
 
12583
- },{"./lib/core.js":100,"./lib/es6-extensions.js":101,"./polyfill-done.js":102,"asap":98}]},{},[2])(2)
14837
+ },{"./lib/core.js":104,"./lib/es6-extensions.js":105,"./polyfill-done.js":106,"asap":98}]},{},[2])(2)
12584
14838
  });