less 3.6.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 (142) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/Gruntfile.js +43 -6
  3. package/bin/lessc +32 -3
  4. package/dist/less.js +2810 -326
  5. package/dist/less.min.js +7 -7
  6. package/lib/less/constants.js +13 -0
  7. package/lib/less/contexts.js +45 -10
  8. package/lib/less/default-options.js +12 -4
  9. package/lib/less/functions/color.js +84 -41
  10. package/lib/less/functions/data-uri.js +1 -1
  11. package/lib/less/functions/index.js +1 -0
  12. package/lib/less/functions/list.js +101 -0
  13. package/lib/less/functions/types.js +1 -19
  14. package/lib/less/import-manager.js +3 -3
  15. package/lib/less/index.js +1 -1
  16. package/lib/less/parse.js +3 -3
  17. package/lib/less/parser/parser.js +31 -13
  18. package/lib/less/render.js +2 -2
  19. package/lib/less/source-map-output.js +2 -2
  20. package/lib/less/tree/color.js +58 -18
  21. package/lib/less/tree/declaration.js +11 -7
  22. package/lib/less/tree/expression.js +7 -3
  23. package/lib/less/tree/import.js +9 -8
  24. package/lib/less/tree/mixin-definition.js +1 -1
  25. package/lib/less/tree/operation.js +10 -4
  26. package/lib/less/tree/url.js +12 -8
  27. package/lib/less/utils.js +54 -19
  28. package/lib/less-browser/add-default-options.js +3 -3
  29. package/lib/less-browser/index.js +9 -2
  30. package/lib/less-node/image-size.js +1 -1
  31. package/lib/less-node/lessc-helper.js +12 -4
  32. package/package.json +5 -2
  33. package/test/browser/css/rewrite-urls/urls.css +36 -0
  34. package/test/browser/css/rootpath-rewrite-urls/urls.css +35 -0
  35. package/test/browser/less/rewrite-urls/urls.less +34 -0
  36. package/test/browser/less/rootpath-rewrite-urls/urls.less +33 -0
  37. package/test/browser/less.js +2810 -326
  38. package/test/browser/runner-browser-options.js +1 -1
  39. package/test/browser/runner-errors-options.js +1 -1
  40. package/test/browser/runner-legacy-options.js +1 -1
  41. package/test/browser/runner-rewrite-urls-options.js +3 -0
  42. package/test/browser/runner-rewrite-urls-spec.js +3 -0
  43. package/test/browser/runner-rootpath-relative-spec.js +1 -1
  44. package/test/browser/runner-rootpath-rewrite-urls-options.js +4 -0
  45. package/test/browser/runner-rootpath-rewrite-urls-spec.js +3 -0
  46. package/test/css/calc.css +2 -2
  47. package/test/css/colors.css +20 -3
  48. package/test/css/css-3.css +0 -8
  49. package/test/css/css-escapes.css +3 -0
  50. package/test/css/functions-each.css +48 -0
  51. package/test/css/functions.css +6 -4
  52. package/test/css/math/parens-division/media-math.css +10 -0
  53. package/test/css/math/parens-division/mixins-args.css +169 -0
  54. package/test/css/math/parens-division/new-division.css +16 -0
  55. package/test/css/math/parens-division/parens.css +37 -0
  56. package/test/css/math/strict/css.css +95 -0
  57. package/test/css/math/strict/media-math.css +10 -0
  58. package/test/css/math/strict/mixins-args.css +169 -0
  59. package/test/css/math/strict/parens.css +37 -0
  60. package/test/css/{strict-math → math/strict-legacy}/css.css +0 -0
  61. package/test/css/math/strict-legacy/media-math.css +10 -0
  62. package/test/css/{strict-math → math/strict-legacy}/mixins-args.css +0 -0
  63. package/test/css/{strict-math → math/strict-legacy}/parens.css +5 -1
  64. package/test/css/no-strict-math/no-sm-operations.css +3 -0
  65. package/test/css/rewrite-urls-all/rewrite-urls-all.css +17 -0
  66. package/test/css/rewrite-urls-local/rewrite-urls-local.css +17 -0
  67. package/test/css/rootpath-rewrite-urls-all/rootpath-rewrite-urls-all.css +17 -0
  68. package/test/css/rootpath-rewrite-urls-local/rootpath-rewrite-urls-local.css +17 -0
  69. package/test/css/static-urls/urls.css +2 -2
  70. package/test/css/urls.css +2 -2
  71. package/test/index.js +28 -15
  72. package/test/less/colors.less +18 -0
  73. package/test/less/css-3.less +0 -9
  74. package/test/less/css-escapes.less +4 -0
  75. package/test/less/errors/color-func-invalid-color.txt +1 -1
  76. package/test/less/errors/mixin-not-defined-2.less +7 -0
  77. package/test/less/errors/mixin-not-defined-2.txt +4 -0
  78. package/test/less/functions-each.less +81 -0
  79. package/test/less/functions.less +14 -2
  80. package/test/less/math/parens-division/media-math.less +9 -0
  81. package/test/less/math/parens-division/mixins-args.less +264 -0
  82. package/test/less/math/parens-division/new-division.less +17 -0
  83. package/test/less/{strict-math → math/parens-division}/parens.less +2 -1
  84. package/test/less/math/strict/css.less +108 -0
  85. package/test/less/math/strict/media-math.less +9 -0
  86. package/test/less/math/strict/mixins-args.less +264 -0
  87. package/test/less/math/strict/parens.less +46 -0
  88. package/test/less/{strict-math → math/strict-legacy}/css.less +0 -0
  89. package/test/less/math/strict-legacy/media-math.less +9 -0
  90. package/test/less/{strict-math → math/strict-legacy}/mixins-args.less +0 -0
  91. package/test/less/math/strict-legacy/parens.less +50 -0
  92. package/test/less/no-strict-math/no-sm-operations.less +3 -0
  93. package/test/less/rewrite-urls-all/folder/file.less +8 -0
  94. package/test/less/rewrite-urls-all/rewrite-urls-all.less +11 -0
  95. package/test/less/rewrite-urls-local/folder/file.less +8 -0
  96. package/test/less/rewrite-urls-local/rewrite-urls-local.less +11 -0
  97. package/test/less/rootpath-rewrite-urls-all/folder/file.less +8 -0
  98. package/test/less/rootpath-rewrite-urls-all/rootpath-rewrite-urls-all.less +11 -0
  99. package/test/less/rootpath-rewrite-urls-local/folder/file.less +8 -0
  100. package/test/less/rootpath-rewrite-urls-local/rootpath-rewrite-urls-local.less +11 -0
  101. package/test/less/sourcemaps/custom-props.less +8 -0
  102. package/test/less-bom/colors.less +18 -0
  103. package/test/less-bom/css-3.less +0 -9
  104. package/test/less-bom/css-escapes.less +4 -0
  105. package/test/less-bom/errors/color-func-invalid-color.txt +1 -1
  106. package/test/less-bom/errors/mixin-not-defined-2.less +7 -0
  107. package/test/less-bom/errors/mixin-not-defined-2.txt +4 -0
  108. package/test/less-bom/functions-each.less +81 -0
  109. package/test/less-bom/functions.less +14 -2
  110. package/test/less-bom/math/parens-division/media-math.less +9 -0
  111. package/test/less-bom/math/parens-division/mixins-args.less +264 -0
  112. package/test/less-bom/math/parens-division/new-division.less +17 -0
  113. package/test/less-bom/{strict-math → math/parens-division}/parens.less +2 -1
  114. package/test/less-bom/math/strict/css.less +108 -0
  115. package/test/less-bom/math/strict/media-math.less +9 -0
  116. package/test/less-bom/math/strict/mixins-args.less +264 -0
  117. package/test/less-bom/math/strict/parens.less +46 -0
  118. package/test/less-bom/{strict-math → math/strict-legacy}/css.less +0 -0
  119. package/test/less-bom/math/strict-legacy/media-math.less +9 -0
  120. package/test/less-bom/{strict-math → math/strict-legacy}/mixins-args.less +0 -0
  121. package/test/less-bom/math/strict-legacy/parens.less +50 -0
  122. package/test/less-bom/no-strict-math/no-sm-operations.less +3 -0
  123. package/test/less-bom/rewrite-urls-all/folder/file.less +8 -0
  124. package/test/less-bom/rewrite-urls-all/rewrite-urls-all.less +11 -0
  125. package/test/less-bom/rewrite-urls-local/folder/file.less +8 -0
  126. package/test/less-bom/rewrite-urls-local/rewrite-urls-local.less +11 -0
  127. package/test/less-bom/rootpath-rewrite-urls-all/folder/file.less +8 -0
  128. package/test/less-bom/rootpath-rewrite-urls-all/rootpath-rewrite-urls-all.less +11 -0
  129. package/test/less-bom/rootpath-rewrite-urls-local/folder/file.less +8 -0
  130. package/test/less-bom/rootpath-rewrite-urls-local/rootpath-rewrite-urls-local.less +11 -0
  131. package/test/less-bom/sourcemaps/custom-props.less +8 -0
  132. package/test/less-test.js +26 -12
  133. package/test/sourcemaps/custom-props.json +1 -0
  134. package/.npmignore +0 -8
  135. package/test/less/errors/color-invalid-hex-code.less +0 -4
  136. package/test/less/errors/color-invalid-hex-code.txt +0 -4
  137. package/test/less/errors/color-invalid-hex-code2.less +0 -4
  138. package/test/less/errors/color-invalid-hex-code2.txt +0 -4
  139. package/test/less-bom/errors/color-invalid-hex-code.less +0 -4
  140. package/test/less-bom/errors/color-invalid-hex-code.txt +0 -4
  141. package/test/less-bom/errors/color-invalid-hex-code2.less +0 -4
  142. package/test/less-bom/errors/color-invalid-hex-code2.txt +0 -4
package/dist/less.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Less - Leaner CSS v3.6.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>
@@ -56,9 +56,9 @@ module.exports = function(window, options) {
56
56
  options.onReady = true;
57
57
  }
58
58
 
59
- // TODO: deprecate and remove 'inlineJavaScript' thing - where it came from at all?
60
- options.javascriptEnabled = (options.javascriptEnabled || options.inlineJavaScript) ? true : false;
61
-
59
+ if (options.relativeUrls) {
60
+ options.rewriteUrls = 'all';
61
+ }
62
62
  };
63
63
 
64
64
  },{"./browser":3,"./utils":11}],2:[function(require,module,exports){
@@ -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":16,"./add-default-options":1,"./index":8,"promise/polyfill":101}],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) {
@@ -526,7 +526,7 @@ module.exports = function(options, logger) {
526
526
  return FileManager;
527
527
  };
528
528
 
529
- },{"../less/environment/abstract-file-manager.js":17}],7:[function(require,module,exports){
529
+ },{"../less/environment/abstract-file-manager.js":18}],7:[function(require,module,exports){
530
530
  module.exports = function() {
531
531
 
532
532
  var functionRegistry = require('./../less/functions/function-registry');
@@ -556,7 +556,7 @@ module.exports = function() {
556
556
  functionRegistry.addMultiple(imageFunctions);
557
557
  };
558
558
 
559
- },{"./../less/functions/function-registry":26}],8:[function(require,module,exports){
559
+ },{"./../less/functions/function-registry":27}],8:[function(require,module,exports){
560
560
  //
561
561
  // index.js
562
562
  // Should expose the additional browser functions on to the less object
@@ -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
@@ -652,7 +658,8 @@ module.exports = function(window, options) {
652
658
  currentDirectory: fileManager.getPath(path),
653
659
  filename: path,
654
660
  rootFilename: path,
655
- relativeUrls: instanceOptions.relativeUrls};
661
+ rewriteUrls: instanceOptions.rewriteUrls
662
+ };
656
663
 
657
664
  newFileInfo.entryPath = newFileInfo.currentDirectory;
658
665
  newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
@@ -831,7 +838,7 @@ module.exports = function(window, options) {
831
838
  return less;
832
839
  };
833
840
 
834
- },{"../less":35,"./browser":3,"./cache":4,"./error-reporting":5,"./file-manager":6,"./image-size":7,"./log-listener":9,"./plugin-loader":10,"./utils":11}],9:[function(require,module,exports){
841
+ },{"../less":37,"./browser":3,"./cache":4,"./error-reporting":5,"./file-manager":6,"./image-size":7,"./log-listener":9,"./plugin-loader":10,"./utils":11}],9:[function(require,module,exports){
835
842
  module.exports = function(less, options) {
836
843
 
837
844
  var logLevel_debug = 4,
@@ -902,7 +909,7 @@ PluginLoader.prototype.loadPlugin = function(filename, basePath, context, enviro
902
909
  module.exports = PluginLoader;
903
910
 
904
911
 
905
- },{"../less/environment/abstract-plugin-loader.js":18}],11:[function(require,module,exports){
912
+ },{"../less/environment/abstract-plugin-loader.js":19}],11:[function(require,module,exports){
906
913
  module.exports = {
907
914
  extractId: function(href) {
908
915
  return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain
@@ -929,8 +936,23 @@ module.exports = {
929
936
  };
930
937
 
931
938
  },{}],12:[function(require,module,exports){
939
+ module.exports = {
940
+ Math: {
941
+ ALWAYS: 0,
942
+ PARENS_DIVISION: 1,
943
+ PARENS: 2,
944
+ STRICT_LEGACY: 3
945
+ },
946
+ RewriteUrls: {
947
+ OFF: 0,
948
+ LOCAL: 1,
949
+ ALL: 2
950
+ }
951
+ };
952
+ },{}],13:[function(require,module,exports){
932
953
  var contexts = {};
933
954
  module.exports = contexts;
955
+ var Constants = require('./constants');
934
956
 
935
957
  var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {
936
958
  if (!original) { return; }
@@ -948,7 +970,7 @@ var copyFromOriginal = function copyFromOriginal(original, destination, properti
948
970
  var parseCopyProperties = [
949
971
  // options
950
972
  'paths', // option - unmodified - paths to search for imports on
951
- 'relativeUrls', // option - whether to adjust URL's to be relative
973
+ 'rewriteUrls', // option - whether to adjust URL's to be relative
952
974
  'rootpath', // option - rootpath to append to URL's
953
975
  'strictImports', // option -
954
976
  'insecure', // option - whether to allow imports from insecure ssl hosts
@@ -974,14 +996,15 @@ var evalCopyProperties = [
974
996
  'paths', // additional include paths
975
997
  'compress', // whether to compress
976
998
  'ieCompat', // whether to enforce IE compatibility (IE8 data-uri)
977
- 'strictMath', // whether math has to be within parenthesis
999
+ 'math', // whether math has to be within parenthesis
978
1000
  'strictUnits', // whether units need to evaluate correctly
979
1001
  'sourceMap', // whether to output a source map
980
1002
  'importMultiple', // whether we are currently importing multiple copies
981
1003
  'urlArgs', // whether to add args into url tokens
982
1004
  'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false
983
1005
  'pluginManager', // Used as the plugin manager for the session
984
- 'importantScope' // used to bubble up !important statements
1006
+ 'importantScope', // used to bubble up !important statements
1007
+ 'rewriteUrls' // option - whether to adjust URL's to be relative
985
1008
  ];
986
1009
 
987
1010
  contexts.Eval = function(options, frames) {
@@ -1021,24 +1044,49 @@ contexts.Eval.prototype.outOfParenthesis = function () {
1021
1044
 
1022
1045
  contexts.Eval.prototype.inCalc = false;
1023
1046
  contexts.Eval.prototype.mathOn = true;
1024
- contexts.Eval.prototype.isMathOn = function () {
1047
+ contexts.Eval.prototype.isMathOn = function (op) {
1025
1048
  if (!this.mathOn) {
1026
1049
  return false;
1027
1050
  }
1028
- return this.strictMath ? (this.parensStack && this.parensStack.length) : true;
1051
+ if (op === '/' && this.math !== Constants.Math.ALWAYS && (!this.parensStack || !this.parensStack.length)) {
1052
+ return false;
1053
+ }
1054
+ if (this.math > Constants.Math.PARENS_DIVISION) {
1055
+ return this.parensStack && this.parensStack.length;
1056
+ }
1057
+ return true;
1029
1058
  };
1030
1059
 
1031
- contexts.Eval.prototype.isPathRelative = function (path) {
1032
- return !/^(?:[a-z-]+:|\/|#)/i.test(path);
1060
+ contexts.Eval.prototype.pathRequiresRewrite = function (path) {
1061
+ var isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;
1062
+
1063
+ return isRelative(path);
1064
+ };
1065
+
1066
+ contexts.Eval.prototype.rewritePath = function (path, rootpath) {
1067
+ var newPath;
1068
+
1069
+ rootpath = rootpath || '';
1070
+ newPath = this.normalizePath(rootpath + path);
1071
+
1072
+ // If a path was explicit relative and the rootpath was not an absolute path
1073
+ // we must ensure that the new path is also explicit relative.
1074
+ if (isPathLocalRelative(path) &&
1075
+ isPathRelative(rootpath) &&
1076
+ isPathLocalRelative(newPath) === false) {
1077
+ newPath = './' + newPath;
1078
+ }
1079
+
1080
+ return newPath;
1033
1081
  };
1034
1082
 
1035
- contexts.Eval.prototype.normalizePath = function( path ) {
1083
+ contexts.Eval.prototype.normalizePath = function (path) {
1036
1084
  var
1037
1085
  segments = path.split('/').reverse(),
1038
1086
  segment;
1039
1087
 
1040
1088
  path = [];
1041
- while (segments.length !== 0 ) {
1089
+ while (segments.length !== 0) {
1042
1090
  segment = segments.pop();
1043
1091
  switch ( segment ) {
1044
1092
  case '.':
@@ -1051,7 +1099,7 @@ contexts.Eval.prototype.normalizePath = function( path ) {
1051
1099
  }
1052
1100
  break;
1053
1101
  default:
1054
- path.push( segment );
1102
+ path.push(segment);
1055
1103
  break;
1056
1104
  }
1057
1105
  }
@@ -1059,9 +1107,17 @@ contexts.Eval.prototype.normalizePath = function( path ) {
1059
1107
  return path.join('/');
1060
1108
  };
1061
1109
 
1110
+ function isPathRelative(path) {
1111
+ return !/^(?:[a-z-]+:|\/|#)/i.test(path);
1112
+ }
1113
+
1114
+ function isPathLocalRelative(path) {
1115
+ return path.charAt(0) === '.';
1116
+ }
1117
+
1062
1118
  // todo - do the same for the toCSS ?
1063
1119
 
1064
- },{}],13:[function(require,module,exports){
1120
+ },{"./constants":12}],14:[function(require,module,exports){
1065
1121
  module.exports = {
1066
1122
  'aliceblue':'#f0f8ff',
1067
1123
  'antiquewhite':'#faebd7',
@@ -1212,13 +1268,13 @@ module.exports = {
1212
1268
  'yellow':'#ffff00',
1213
1269
  'yellowgreen':'#9acd32'
1214
1270
  };
1215
- },{}],14:[function(require,module,exports){
1271
+ },{}],15:[function(require,module,exports){
1216
1272
  module.exports = {
1217
1273
  colors: require('./colors'),
1218
1274
  unitConversions: require('./unit-conversions')
1219
1275
  };
1220
1276
 
1221
- },{"./colors":13,"./unit-conversions":15}],15:[function(require,module,exports){
1277
+ },{"./colors":14,"./unit-conversions":16}],16:[function(require,module,exports){
1222
1278
  module.exports = {
1223
1279
  length: {
1224
1280
  'm': 1,
@@ -1240,14 +1296,17 @@ module.exports = {
1240
1296
  'turn': 1
1241
1297
  }
1242
1298
  };
1243
- },{}],16:[function(require,module,exports){
1299
+ },{}],17:[function(require,module,exports){
1244
1300
  // Export a new default each time
1245
1301
  module.exports = function() {
1246
1302
  return {
1303
+ /* Inline Javascript - @plugin still allowed */
1304
+ javascriptEnabled: false,
1305
+
1247
1306
  /* Outputs a makefile import dependency list to stdout. */
1248
1307
  depends: false,
1249
1308
 
1250
- /* Compress using less built-in compression.
1309
+ /* (DEPRECATED) Compress using less built-in compression.
1251
1310
  * This does an okay job but does not utilise all the tricks of
1252
1311
  * dedicated css compression. */
1253
1312
  compress: false,
@@ -1282,13 +1341,18 @@ module.exports = function() {
1282
1341
  * that references an image, exactly the same URL will be output in the css.
1283
1342
  * This option allows you to re-write URL's in imported files so that the
1284
1343
  * URL is always relative to the base imported file */
1285
- relativeUrls: false,
1344
+ rewriteUrls: false,
1286
1345
 
1287
1346
  /* Compatibility with IE8. Used for limiting data-uri length */
1288
1347
  ieCompat: false, // true until 3.0
1289
1348
 
1290
- /* Without this option on, Less will try and process all math in your css */
1291
- strictMath: false,
1349
+ /* How to process math
1350
+ * 0 always - eagerly try to solve all operations
1351
+ * 1 parens-division - require parens for division "/"
1352
+ * 2 parens | strict - require parens for all operations
1353
+ * 3 strict-legacy - legacy strict behavior (super-strict)
1354
+ */
1355
+ math: 0,
1292
1356
 
1293
1357
  /* Without this option, less attempts to guess at the output unit when it does maths. */
1294
1358
  strictUnits: false,
@@ -1306,7 +1370,7 @@ module.exports = function() {
1306
1370
  urlArgs: ''
1307
1371
  }
1308
1372
  }
1309
- },{}],17:[function(require,module,exports){
1373
+ },{}],18:[function(require,module,exports){
1310
1374
  var abstractFileManager = function() {
1311
1375
  };
1312
1376
 
@@ -1431,7 +1495,7 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
1431
1495
 
1432
1496
  module.exports = abstractFileManager;
1433
1497
 
1434
- },{}],18:[function(require,module,exports){
1498
+ },{}],19:[function(require,module,exports){
1435
1499
  var functionRegistry = require('../functions/function-registry'),
1436
1500
  LessError = require('../less-error');
1437
1501
 
@@ -1622,7 +1686,7 @@ AbstractPluginLoader.prototype.printUsage = function(plugins) {
1622
1686
  module.exports = AbstractPluginLoader;
1623
1687
 
1624
1688
 
1625
- },{"../functions/function-registry":26,"../less-error":36}],19:[function(require,module,exports){
1689
+ },{"../functions/function-registry":27,"../less-error":38}],20:[function(require,module,exports){
1626
1690
  /**
1627
1691
  * @todo Document why this abstraction exists, and the relationship between
1628
1692
  * environment, file managers, and plugin manager
@@ -1680,7 +1744,7 @@ environment.prototype.clearFileManagers = function () {
1680
1744
 
1681
1745
  module.exports = environment;
1682
1746
 
1683
- },{"../logger":37}],20:[function(require,module,exports){
1747
+ },{"../logger":39}],21:[function(require,module,exports){
1684
1748
 
1685
1749
  var functionRegistry = require('./function-registry'),
1686
1750
  Anonymous = require('../tree/anonymous'),
@@ -1697,7 +1761,7 @@ functionRegistry.addMultiple({
1697
1761
  }
1698
1762
  });
1699
1763
 
1700
- },{"../tree/anonymous":48,"../tree/keyword":68,"./function-registry":26}],21:[function(require,module,exports){
1764
+ },{"../tree/anonymous":50,"../tree/keyword":70,"./function-registry":27}],22:[function(require,module,exports){
1701
1765
  var Color = require('../tree/color'),
1702
1766
  functionRegistry = require('./function-registry');
1703
1767
 
@@ -1773,7 +1837,7 @@ for (var f in colorBlendModeFunctions) {
1773
1837
 
1774
1838
  functionRegistry.addMultiple(colorBlend);
1775
1839
 
1776
- },{"../tree/color":53,"./function-registry":26}],22:[function(require,module,exports){
1840
+ },{"../tree/color":55,"./function-registry":27}],23:[function(require,module,exports){
1777
1841
  var Dimension = require('../tree/dimension'),
1778
1842
  Color = require('../tree/color'),
1779
1843
  Quoted = require('../tree/quoted'),
@@ -1784,8 +1848,17 @@ var Dimension = require('../tree/dimension'),
1784
1848
  function clamp(val) {
1785
1849
  return Math.min(1, Math.max(0, val));
1786
1850
  }
1787
- function hsla(color) {
1788
- 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
+ }
1789
1862
  }
1790
1863
  function number(n) {
1791
1864
  if (n instanceof Dimension) {
@@ -1808,46 +1881,79 @@ function scaled(n, size) {
1808
1881
  }
1809
1882
  colorFunctions = {
1810
1883
  rgb: function (r, g, b) {
1811
- 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
+ }
1812
1889
  },
1813
1890
  rgba: function (r, g, b, a) {
1814
- var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
1815
- a = number(a);
1816
- 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) {}
1817
1905
  },
1818
1906
  hsl: function (h, s, l) {
1819
- 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
+ }
1820
1912
  },
1821
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
+ }
1822
1923
 
1823
- var m1, m2;
1924
+ var m1, m2;
1824
1925
 
1825
- function hue(h) {
1826
- h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1827
- if (h * 6 < 1) {
1828
- return m1 + (m2 - m1) * h * 6;
1829
- }
1830
- else if (h * 2 < 1) {
1831
- return m2;
1832
- }
1833
- else if (h * 3 < 2) {
1834
- return m1 + (m2 - m1) * (2 / 3 - h) * 6;
1835
- }
1836
- else {
1837
- 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
+ }
1838
1940
  }
1839
- }
1840
1941
 
1841
- h = (number(h) % 360) / 360;
1842
- 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));
1843
1944
 
1844
- m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1845
- m1 = l * 2 - m2;
1945
+ m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1946
+ m1 = l * 2 - m2;
1846
1947
 
1847
- return colorFunctions.rgba(hue(h + 1 / 3) * 255,
1848
- hue(h) * 255,
1849
- hue(h - 1 / 3) * 255,
1850
- 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) {}
1851
1957
  },
1852
1958
 
1853
1959
  hsv: function(h, s, v) {
@@ -1935,7 +2041,7 @@ colorFunctions = {
1935
2041
  hsl.s += amount.value / 100;
1936
2042
  }
1937
2043
  hsl.s = clamp(hsl.s);
1938
- return hsla(hsl);
2044
+ return hsla(color, hsl);
1939
2045
  },
1940
2046
  desaturate: function (color, amount, method) {
1941
2047
  var hsl = color.toHSL();
@@ -1947,7 +2053,7 @@ colorFunctions = {
1947
2053
  hsl.s -= amount.value / 100;
1948
2054
  }
1949
2055
  hsl.s = clamp(hsl.s);
1950
- return hsla(hsl);
2056
+ return hsla(color, hsl);
1951
2057
  },
1952
2058
  lighten: function (color, amount, method) {
1953
2059
  var hsl = color.toHSL();
@@ -1959,7 +2065,7 @@ colorFunctions = {
1959
2065
  hsl.l += amount.value / 100;
1960
2066
  }
1961
2067
  hsl.l = clamp(hsl.l);
1962
- return hsla(hsl);
2068
+ return hsla(color, hsl);
1963
2069
  },
1964
2070
  darken: function (color, amount, method) {
1965
2071
  var hsl = color.toHSL();
@@ -1971,7 +2077,7 @@ colorFunctions = {
1971
2077
  hsl.l -= amount.value / 100;
1972
2078
  }
1973
2079
  hsl.l = clamp(hsl.l);
1974
- return hsla(hsl);
2080
+ return hsla(color, hsl);
1975
2081
  },
1976
2082
  fadein: function (color, amount, method) {
1977
2083
  var hsl = color.toHSL();
@@ -1983,7 +2089,7 @@ colorFunctions = {
1983
2089
  hsl.a += amount.value / 100;
1984
2090
  }
1985
2091
  hsl.a = clamp(hsl.a);
1986
- return hsla(hsl);
2092
+ return hsla(color, hsl);
1987
2093
  },
1988
2094
  fadeout: function (color, amount, method) {
1989
2095
  var hsl = color.toHSL();
@@ -1995,14 +2101,14 @@ colorFunctions = {
1995
2101
  hsl.a -= amount.value / 100;
1996
2102
  }
1997
2103
  hsl.a = clamp(hsl.a);
1998
- return hsla(hsl);
2104
+ return hsla(color, hsl);
1999
2105
  },
2000
2106
  fade: function (color, amount) {
2001
2107
  var hsl = color.toHSL();
2002
2108
 
2003
2109
  hsl.a = amount.value / 100;
2004
2110
  hsl.a = clamp(hsl.a);
2005
- return hsla(hsl);
2111
+ return hsla(color, hsl);
2006
2112
  },
2007
2113
  spin: function (color, amount) {
2008
2114
  var hsl = color.toHSL();
@@ -2010,7 +2116,7 @@ colorFunctions = {
2010
2116
 
2011
2117
  hsl.h = hue < 0 ? 360 + hue : hue;
2012
2118
 
2013
- return hsla(hsl);
2119
+ return hsla(color, hsl);
2014
2120
  },
2015
2121
  //
2016
2122
  // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein
@@ -2114,8 +2220,9 @@ colorFunctions = {
2114
2220
  },
2115
2221
  color: function(c) {
2116
2222
  if ((c instanceof Quoted) &&
2117
- (/^#([a-f0-9]{6}|[a-f0-9]{3})$/i.test(c.value))) {
2118
- 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);
2119
2226
  }
2120
2227
  if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {
2121
2228
  c.value = undefined;
@@ -2123,7 +2230,7 @@ colorFunctions = {
2123
2230
  }
2124
2231
  throw {
2125
2232
  type: 'Argument',
2126
- 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'
2127
2234
  };
2128
2235
  },
2129
2236
  tint: function(color, amount) {
@@ -2135,7 +2242,7 @@ colorFunctions = {
2135
2242
  };
2136
2243
  functionRegistry.addMultiple(colorFunctions);
2137
2244
 
2138
- },{"../tree/anonymous":48,"../tree/color":53,"../tree/dimension":60,"../tree/quoted":78,"./function-registry":26}],23:[function(require,module,exports){
2245
+ },{"../tree/anonymous":50,"../tree/color":55,"../tree/dimension":62,"../tree/quoted":80,"./function-registry":27}],24:[function(require,module,exports){
2139
2246
  module.exports = function(environment) {
2140
2247
  var Quoted = require('../tree/quoted'),
2141
2248
  URL = require('../tree/url'),
@@ -2156,7 +2263,7 @@ module.exports = function(environment) {
2156
2263
  var mimetype = mimetypeNode && mimetypeNode.value;
2157
2264
  var filePath = filePathNode.value;
2158
2265
  var currentFileInfo = this.currentFileInfo;
2159
- var currentDirectory = currentFileInfo.relativeUrls ?
2266
+ var currentDirectory = currentFileInfo.rewriteUrls ?
2160
2267
  currentFileInfo.currentDirectory : currentFileInfo.entryPath;
2161
2268
 
2162
2269
  var fragmentStart = filePath.indexOf('#');
@@ -2225,7 +2332,7 @@ module.exports = function(environment) {
2225
2332
  });
2226
2333
  };
2227
2334
 
2228
- },{"../logger":37,"../tree/quoted":78,"../tree/url":83,"../utils":87,"./function-registry":26}],24:[function(require,module,exports){
2335
+ },{"../logger":39,"../tree/quoted":80,"../tree/url":85,"../utils":89,"./function-registry":27}],25:[function(require,module,exports){
2229
2336
  var Keyword = require('../tree/keyword'),
2230
2337
  functionRegistry = require('./function-registry');
2231
2338
 
@@ -2254,7 +2361,7 @@ functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));
2254
2361
 
2255
2362
  module.exports = defaultFunc;
2256
2363
 
2257
- },{"../tree/keyword":68,"./function-registry":26}],25:[function(require,module,exports){
2364
+ },{"../tree/keyword":70,"./function-registry":27}],26:[function(require,module,exports){
2258
2365
  var Expression = require('../tree/expression');
2259
2366
 
2260
2367
  var functionCaller = function(name, context, index, currentFileInfo) {
@@ -2302,7 +2409,7 @@ functionCaller.prototype.call = function(args) {
2302
2409
 
2303
2410
  module.exports = functionCaller;
2304
2411
 
2305
- },{"../tree/expression":62}],26:[function(require,module,exports){
2412
+ },{"../tree/expression":64}],27:[function(require,module,exports){
2306
2413
  function makeRegistry( base ) {
2307
2414
  return {
2308
2415
  _data: {},
@@ -2338,7 +2445,7 @@ function makeRegistry( base ) {
2338
2445
  }
2339
2446
 
2340
2447
  module.exports = makeRegistry( null );
2341
- },{}],27:[function(require,module,exports){
2448
+ },{}],28:[function(require,module,exports){
2342
2449
  module.exports = function(environment) {
2343
2450
  var functions = {
2344
2451
  functionRegistry: require('./function-registry'),
@@ -2351,6 +2458,7 @@ module.exports = function(environment) {
2351
2458
  require('./color');
2352
2459
  require('./color-blending');
2353
2460
  require('./data-uri')(environment);
2461
+ require('./list');
2354
2462
  require('./math');
2355
2463
  require('./number');
2356
2464
  require('./string');
@@ -2360,7 +2468,110 @@ module.exports = function(environment) {
2360
2468
  return functions;
2361
2469
  };
2362
2470
 
2363
- },{"./boolean":20,"./color":22,"./color-blending":21,"./data-uri":23,"./default":24,"./function-caller":25,"./function-registry":26,"./math":29,"./number":30,"./string":31,"./svg":32,"./types":33}],28:[function(require,module,exports){
2471
+ },{"./boolean":21,"./color":23,"./color-blending":22,"./data-uri":24,"./default":25,"./function-caller":26,"./function-registry":27,"./list":29,"./math":31,"./number":32,"./string":33,"./svg":34,"./types":35}],29:[function(require,module,exports){
2472
+ var Dimension = require('../tree/dimension'),
2473
+ Declaration = require('../tree/declaration'),
2474
+ Ruleset = require('../tree/ruleset'),
2475
+ Selector = require('../tree/selector'),
2476
+ Element = require('../tree/element'),
2477
+ functionRegistry = require('./function-registry');
2478
+
2479
+ var getItemsFromNode = function(node) {
2480
+ // handle non-array values as an array of length 1
2481
+ // return 'undefined' if index is invalid
2482
+ var items = Array.isArray(node.value) ?
2483
+ node.value : Array(node);
2484
+
2485
+ return items;
2486
+ };
2487
+
2488
+ functionRegistry.addMultiple({
2489
+ _SELF: function(n) {
2490
+ return n;
2491
+ },
2492
+ extract: function(values, index) {
2493
+ index = index.value - 1; // (1-based index)
2494
+
2495
+ return getItemsFromNode(values)[index];
2496
+ },
2497
+ length: function(values) {
2498
+ return new Dimension(getItemsFromNode(values).length);
2499
+ },
2500
+ each: function(list, rs) {
2501
+ var i = 0, rules = [], newRules, iterator;
2502
+
2503
+ if (list.value) {
2504
+ if (Array.isArray(list.value)) {
2505
+ iterator = list.value;
2506
+ } else {
2507
+ iterator = [list.value];
2508
+ }
2509
+ } else if (list.ruleset) {
2510
+ iterator = list.ruleset.rules;
2511
+ } else if (Array.isArray(list)) {
2512
+ iterator = list;
2513
+ } else {
2514
+ iterator = [list];
2515
+ }
2516
+
2517
+ var valueName = '@value',
2518
+ keyName = '@key',
2519
+ indexName = '@index';
2520
+
2521
+ if (rs.params) {
2522
+ valueName = rs.params[0] && rs.params[0].name;
2523
+ keyName = rs.params[1] && rs.params[1].name;
2524
+ indexName = rs.params[2] && rs.params[2].name;
2525
+ rs = rs.rules;
2526
+ } else {
2527
+ rs = rs.ruleset;
2528
+ }
2529
+
2530
+ iterator.forEach(function(item) {
2531
+ i = i + 1;
2532
+ var key, value;
2533
+ if (item instanceof Declaration) {
2534
+ key = typeof item.name === 'string' ? item.name : item.name[0].value;
2535
+ value = item.value;
2536
+ } else {
2537
+ key = new Dimension(i);
2538
+ value = item;
2539
+ }
2540
+
2541
+ newRules = rs.rules.slice(0);
2542
+ if (valueName) {
2543
+ newRules.push(new Declaration(valueName,
2544
+ value,
2545
+ false, false, this.index, this.currentFileInfo));
2546
+ }
2547
+ if (indexName) {
2548
+ newRules.push(new Declaration(indexName,
2549
+ new Dimension(i),
2550
+ false, false, this.index, this.currentFileInfo));
2551
+ }
2552
+ if (keyName) {
2553
+ newRules.push(new Declaration(keyName,
2554
+ key,
2555
+ false, false, this.index, this.currentFileInfo));
2556
+ }
2557
+
2558
+ rules.push(new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
2559
+ newRules,
2560
+ rs.strictImports,
2561
+ rs.visibilityInfo()
2562
+ ));
2563
+ });
2564
+
2565
+ return new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
2566
+ rules,
2567
+ rs.strictImports,
2568
+ rs.visibilityInfo()
2569
+ ).eval(this.context);
2570
+
2571
+ }
2572
+ });
2573
+
2574
+ },{"../tree/declaration":60,"../tree/dimension":62,"../tree/element":63,"../tree/ruleset":81,"../tree/selector":82,"./function-registry":27}],30:[function(require,module,exports){
2364
2575
  var Dimension = require('../tree/dimension');
2365
2576
 
2366
2577
  var MathHelper = function() {
@@ -2377,7 +2588,7 @@ MathHelper._math = function (fn, unit, n) {
2377
2588
  return new Dimension(fn(parseFloat(n.value)), unit);
2378
2589
  };
2379
2590
  module.exports = MathHelper;
2380
- },{"../tree/dimension":60}],29:[function(require,module,exports){
2591
+ },{"../tree/dimension":62}],31:[function(require,module,exports){
2381
2592
  var functionRegistry = require('./function-registry'),
2382
2593
  mathHelper = require('./math-helper.js');
2383
2594
 
@@ -2408,7 +2619,7 @@ mathFunctions.round = function (n, f) {
2408
2619
 
2409
2620
  functionRegistry.addMultiple(mathFunctions);
2410
2621
 
2411
- },{"./function-registry":26,"./math-helper.js":28}],30:[function(require,module,exports){
2622
+ },{"./function-registry":27,"./math-helper.js":30}],32:[function(require,module,exports){
2412
2623
  var Dimension = require('../tree/dimension'),
2413
2624
  Anonymous = require('../tree/anonymous'),
2414
2625
  functionRegistry = require('./function-registry'),
@@ -2491,7 +2702,7 @@ functionRegistry.addMultiple({
2491
2702
  }
2492
2703
  });
2493
2704
 
2494
- },{"../tree/anonymous":48,"../tree/dimension":60,"./function-registry":26,"./math-helper.js":28}],31:[function(require,module,exports){
2705
+ },{"../tree/anonymous":50,"../tree/dimension":62,"./function-registry":27,"./math-helper.js":30}],33:[function(require,module,exports){
2495
2706
  var Quoted = require('../tree/quoted'),
2496
2707
  Anonymous = require('../tree/anonymous'),
2497
2708
  JavaScript = require('../tree/javascript'),
@@ -2530,7 +2741,7 @@ functionRegistry.addMultiple({
2530
2741
  }
2531
2742
  });
2532
2743
 
2533
- },{"../tree/anonymous":48,"../tree/javascript":66,"../tree/quoted":78,"./function-registry":26}],32:[function(require,module,exports){
2744
+ },{"../tree/anonymous":50,"../tree/javascript":68,"../tree/quoted":80,"./function-registry":27}],34:[function(require,module,exports){
2534
2745
  module.exports = function(environment) {
2535
2746
  var Dimension = require('../tree/dimension'),
2536
2747
  Color = require('../tree/color'),
@@ -2619,7 +2830,7 @@ module.exports = function(environment) {
2619
2830
  });
2620
2831
  };
2621
2832
 
2622
- },{"../tree/color":53,"../tree/dimension":60,"../tree/expression":62,"../tree/quoted":78,"../tree/url":83,"./function-registry":26}],33:[function(require,module,exports){
2833
+ },{"../tree/color":55,"../tree/dimension":62,"../tree/expression":64,"../tree/quoted":80,"../tree/url":85,"./function-registry":27}],35:[function(require,module,exports){
2623
2834
  var Keyword = require('../tree/keyword'),
2624
2835
  DetachedRuleset = require('../tree/detached-ruleset'),
2625
2836
  Dimension = require('../tree/dimension'),
@@ -2642,15 +2853,8 @@ var isa = function (n, Type) {
2642
2853
  throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };
2643
2854
  }
2644
2855
  return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;
2645
- },
2646
- getItemsFromNode = function(node) {
2647
- // handle non-array values as an array of length 1
2648
- // return 'undefined' if index is invalid
2649
- var items = Array.isArray(node.value) ?
2650
- node.value : Array(node);
2651
-
2652
- return items;
2653
2856
  };
2857
+
2654
2858
  functionRegistry.addMultiple({
2655
2859
  isruleset: function (n) {
2656
2860
  return isa(n, DetachedRuleset);
@@ -2699,21 +2903,10 @@ functionRegistry.addMultiple({
2699
2903
  },
2700
2904
  'get-unit': function (n) {
2701
2905
  return new Anonymous(n.unit);
2702
- },
2703
- extract: function(values, index) {
2704
- index = index.value - 1; // (1-based index)
2705
-
2706
- return getItemsFromNode(values)[index];
2707
- },
2708
- length: function(values) {
2709
- return new Dimension(getItemsFromNode(values).length);
2710
- },
2711
- _SELF: function(n) {
2712
- return n;
2713
2906
  }
2714
2907
  });
2715
2908
 
2716
- },{"../tree/anonymous":48,"../tree/color":53,"../tree/detached-ruleset":59,"../tree/dimension":60,"../tree/keyword":68,"../tree/operation":75,"../tree/quoted":78,"../tree/url":83,"./function-registry":26}],34:[function(require,module,exports){
2909
+ },{"../tree/anonymous":50,"../tree/color":55,"../tree/detached-ruleset":61,"../tree/dimension":62,"../tree/keyword":70,"../tree/operation":77,"../tree/quoted":80,"../tree/url":85,"./function-registry":27}],36:[function(require,module,exports){
2717
2910
  var contexts = require('./contexts'),
2718
2911
  Parser = require('./parser/parser'),
2719
2912
  LessError = require('./less-error'),
@@ -2724,7 +2917,7 @@ var contexts = require('./contexts'),
2724
2917
  module.exports = function(environment) {
2725
2918
 
2726
2919
  // FileInfo = {
2727
- // 'relativeUrls' - option - whether to adjust URL's to be relative
2920
+ // 'rewriteUrls' - option - whether to adjust URL's to be relative
2728
2921
  // 'filename' - full resolved filename of current file
2729
2922
  // 'rootpath' - path to append to normal URLs for this node
2730
2923
  // 'currentDirectory' - path to the current file, absolute
@@ -2781,7 +2974,7 @@ module.exports = function(environment) {
2781
2974
  };
2782
2975
 
2783
2976
  var newFileInfo = {
2784
- relativeUrls: this.context.relativeUrls,
2977
+ rewriteUrls: this.context.rewriteUrls,
2785
2978
  entryPath: currentFileInfo.entryPath,
2786
2979
  rootpath: currentFileInfo.rootpath,
2787
2980
  rootFilename: currentFileInfo.rootFilename
@@ -2808,7 +3001,7 @@ module.exports = function(environment) {
2808
3001
  // - If path of imported file is '../mixins.less' and rootpath is 'less/',
2809
3002
  // then rootpath should become 'less/../'
2810
3003
  newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);
2811
- if (newFileInfo.relativeUrls) {
3004
+ if (newFileInfo.rewriteUrls) {
2812
3005
  newFileInfo.rootpath = fileManager.join(
2813
3006
  (importManager.context.rootpath || ''),
2814
3007
  fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));
@@ -2882,12 +3075,12 @@ module.exports = function(environment) {
2882
3075
  return ImportManager;
2883
3076
  };
2884
3077
 
2885
- },{"./contexts":12,"./less-error":36,"./logger":37,"./parser/parser":42,"./utils":87,"promise":undefined}],35:[function(require,module,exports){
3078
+ },{"./contexts":13,"./less-error":38,"./logger":39,"./parser/parser":44,"./utils":89,"promise":undefined}],37:[function(require,module,exports){
2886
3079
  module.exports = function(environment, fileManagers) {
2887
3080
  var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
2888
3081
 
2889
3082
  var initial = {
2890
- version: [3, 6, 0],
3083
+ version: [3, 8, 1],
2891
3084
  data: require('./data'),
2892
3085
  tree: require('./tree'),
2893
3086
  Environment: (Environment = require('./environment/environment')),
@@ -2939,7 +3132,7 @@ module.exports = function(environment, fileManagers) {
2939
3132
  return api;
2940
3133
  };
2941
3134
 
2942
- },{"./contexts":12,"./data":14,"./environment/abstract-file-manager":17,"./environment/abstract-plugin-loader":18,"./environment/environment":19,"./functions":27,"./import-manager":34,"./less-error":36,"./logger":37,"./parse":39,"./parse-tree":38,"./parser/parser":42,"./plugin-manager":43,"./render":44,"./source-map-builder":45,"./source-map-output":46,"./transform-tree":47,"./tree":65,"./utils":87,"./visitors":91}],36:[function(require,module,exports){
3135
+ },{"./contexts":13,"./data":15,"./environment/abstract-file-manager":18,"./environment/abstract-plugin-loader":19,"./environment/environment":20,"./functions":28,"./import-manager":36,"./less-error":38,"./logger":39,"./parse":41,"./parse-tree":40,"./parser/parser":44,"./plugin-manager":45,"./render":46,"./source-map-builder":47,"./source-map-output":48,"./transform-tree":49,"./tree":67,"./utils":89,"./visitors":93}],38:[function(require,module,exports){
2943
3136
  var utils = require('./utils');
2944
3137
  /**
2945
3138
  * This is a centralized class of any error that could be thrown internally (mostly by the parser).
@@ -3082,7 +3275,7 @@ LessError.prototype.toString = function(options) {
3082
3275
  return message;
3083
3276
  };
3084
3277
 
3085
- },{"./utils":87}],37:[function(require,module,exports){
3278
+ },{"./utils":89}],39:[function(require,module,exports){
3086
3279
  module.exports = {
3087
3280
  error: function(msg) {
3088
3281
  this._fireEvent('error', msg);
@@ -3118,7 +3311,7 @@ module.exports = {
3118
3311
  _listeners: []
3119
3312
  };
3120
3313
 
3121
- },{}],38:[function(require,module,exports){
3314
+ },{}],40:[function(require,module,exports){
3122
3315
  var LessError = require('./less-error'),
3123
3316
  transformTree = require('./transform-tree'),
3124
3317
  logger = require('./logger');
@@ -3180,7 +3373,7 @@ module.exports = function(SourceMapBuilder) {
3180
3373
  return ParseTree;
3181
3374
  };
3182
3375
 
3183
- },{"./less-error":36,"./logger":37,"./transform-tree":47}],39:[function(require,module,exports){
3376
+ },{"./less-error":38,"./logger":39,"./transform-tree":49}],41:[function(require,module,exports){
3184
3377
  var PromiseConstructor,
3185
3378
  contexts = require('./contexts'),
3186
3379
  Parser = require('./parser/parser'),
@@ -3193,10 +3386,10 @@ module.exports = function(environment, ParseTree, ImportManager) {
3193
3386
 
3194
3387
  if (typeof options === 'function') {
3195
3388
  callback = options;
3196
- options = utils.defaults(this.options, {});
3389
+ options = utils.copyOptions(this.options, {});
3197
3390
  }
3198
3391
  else {
3199
- options = utils.defaults(this.options, options || {});
3392
+ options = utils.copyOptions(this.options, options || {});
3200
3393
  }
3201
3394
 
3202
3395
  if (!callback) {
@@ -3229,7 +3422,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
3229
3422
  var entryPath = filename.replace(/[^\/\\]*$/, '');
3230
3423
  rootFileInfo = {
3231
3424
  filename: filename,
3232
- relativeUrls: context.relativeUrls,
3425
+ rewriteUrls: context.rewriteUrls,
3233
3426
  rootpath: context.rootpath || '',
3234
3427
  currentDirectory: entryPath,
3235
3428
  entryPath: entryPath,
@@ -3273,7 +3466,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
3273
3466
  return parse;
3274
3467
  };
3275
3468
 
3276
- },{"./contexts":12,"./less-error":36,"./parser/parser":42,"./plugin-manager":43,"./utils":87,"promise":undefined}],40:[function(require,module,exports){
3469
+ },{"./contexts":13,"./less-error":38,"./parser/parser":44,"./plugin-manager":45,"./utils":89,"promise":undefined}],42:[function(require,module,exports){
3277
3470
  // Split the input into chunks.
3278
3471
  module.exports = function (input, fail) {
3279
3472
  var len = input.length, level = 0, parenLevel = 0,
@@ -3387,7 +3580,7 @@ module.exports = function (input, fail) {
3387
3580
  return chunks;
3388
3581
  };
3389
3582
 
3390
- },{}],41:[function(require,module,exports){
3583
+ },{}],43:[function(require,module,exports){
3391
3584
  var chunker = require('./chunker');
3392
3585
 
3393
3586
  module.exports = function() {
@@ -3772,7 +3965,7 @@ module.exports = function() {
3772
3965
  return parserInput;
3773
3966
  };
3774
3967
 
3775
- },{"./chunker":40}],42:[function(require,module,exports){
3968
+ },{"./chunker":42}],44:[function(require,module,exports){
3776
3969
  var LessError = require('../less-error'),
3777
3970
  tree = require('../tree'),
3778
3971
  visitors = require('../visitors'),
@@ -4411,15 +4604,8 @@ var Parser = function Parser(context, imports, fileInfo) {
4411
4604
  color: function () {
4412
4605
  var rgb;
4413
4606
 
4414
- if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))) {
4415
- // strip colons, brackets, whitespaces and other characters that should not
4416
- // definitely be part of color string
4417
- var colorCandidateString = rgb.input.match(/^#([\w]+).*/);
4418
- colorCandidateString = colorCandidateString[1];
4419
- if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters
4420
- error('Invalid HEX color code');
4421
- }
4422
- 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]);
4423
4609
  }
4424
4610
  },
4425
4611
 
@@ -4706,7 +4892,7 @@ var Parser = function Parser(context, imports, fileInfo) {
4706
4892
  returner = { args:null, variadic: false },
4707
4893
  expressions = [], argsSemiColon = [], argsComma = [],
4708
4894
  isSemiColonSeparated, expressionContainsNamed, name, nameLoop,
4709
- value, arg, expand;
4895
+ value, arg, expand, hasSep = true;
4710
4896
 
4711
4897
  parserInput.save();
4712
4898
 
@@ -4727,7 +4913,7 @@ var Parser = function Parser(context, imports, fileInfo) {
4727
4913
  arg = entities.variable() || entities.property() || entities.literal() || entities.keyword() || this.call(true);
4728
4914
  }
4729
4915
 
4730
- if (!arg) {
4916
+ if (!arg || !hasSep) {
4731
4917
  break;
4732
4918
  }
4733
4919
 
@@ -4793,10 +4979,12 @@ var Parser = function Parser(context, imports, fileInfo) {
4793
4979
  argsComma.push({ name:nameLoop, value:value, expand:expand });
4794
4980
 
4795
4981
  if (parserInput.$char(',')) {
4982
+ hasSep = true;
4796
4983
  continue;
4797
4984
  }
4985
+ hasSep = parserInput.$char(';') === ';';
4798
4986
 
4799
- if (parserInput.$char(';') || isSemiColonSeparated) {
4987
+ if (hasSep || isSemiColonSeparated) {
4800
4988
 
4801
4989
  if (expressionContainsNamed) {
4802
4990
  error('Cannot mix ; and , as delimiter types');
@@ -5152,10 +5340,33 @@ var Parser = function Parser(context, imports, fileInfo) {
5152
5340
  },
5153
5341
 
5154
5342
  detachedRuleset: function() {
5343
+ var argInfo, params, variadic;
5344
+
5345
+ parserInput.save();
5346
+ if (parserInput.$re(/^[.#]\(/)) {
5347
+ /**
5348
+ * DR args currently only implemented for each() function, and not
5349
+ * yet settable as `@dr: #(@arg) {}`
5350
+ * This should be done when DRs are merged with mixins.
5351
+ * See: https://github.com/less/less-meta/issues/16
5352
+ */
5353
+ argInfo = this.mixin.args(false);
5354
+ params = argInfo.args;
5355
+ variadic = argInfo.variadic;
5356
+ if (!parserInput.$char(')')) {
5357
+ parserInput.restore();
5358
+ return;
5359
+ }
5360
+ }
5155
5361
  var blockRuleset = this.blockRuleset();
5156
5362
  if (blockRuleset) {
5363
+ parserInput.forget();
5364
+ if (params) {
5365
+ return new tree.mixin.Definition(null, params, blockRuleset, null, variadic);
5366
+ }
5157
5367
  return new tree.DetachedRuleset(blockRuleset);
5158
5368
  }
5369
+ parserInput.restore();
5159
5370
  },
5160
5371
 
5161
5372
  //
@@ -5697,7 +5908,7 @@ var Parser = function Parser(context, imports, fileInfo) {
5697
5908
 
5698
5909
  parserInput.save();
5699
5910
 
5700
- op = parserInput.$char('/') || parserInput.$char('*');
5911
+ op = parserInput.$char('/') || parserInput.$char('*') || parserInput.$str('./');
5701
5912
 
5702
5913
  if (!op) { parserInput.forget(); break; }
5703
5914
 
@@ -6032,7 +6243,7 @@ Parser.serializeVars = function(vars) {
6032
6243
 
6033
6244
  module.exports = Parser;
6034
6245
 
6035
- },{"../functions/function-registry":26,"../less-error":36,"../tree":65,"../utils":87,"../visitors":91,"./parser-input":41}],43:[function(require,module,exports){
6246
+ },{"../functions/function-registry":27,"../less-error":38,"../tree":67,"../utils":89,"../visitors":93,"./parser-input":43}],45:[function(require,module,exports){
6036
6247
  /**
6037
6248
  * Plugin Manager
6038
6249
  */
@@ -6189,7 +6400,7 @@ PluginManager.prototype.getFileManagers = function() {
6189
6400
  //
6190
6401
  module.exports = PluginManagerFactory;
6191
6402
 
6192
- },{}],44:[function(require,module,exports){
6403
+ },{}],46:[function(require,module,exports){
6193
6404
  var PromiseConstructor,
6194
6405
  utils = require('./utils');
6195
6406
 
@@ -6197,10 +6408,10 @@ module.exports = function(environment, ParseTree, ImportManager) {
6197
6408
  var render = function (input, options, callback) {
6198
6409
  if (typeof options === 'function') {
6199
6410
  callback = options;
6200
- options = utils.defaults(this.options, {});
6411
+ options = utils.copyOptions(this.options, {});
6201
6412
  }
6202
6413
  else {
6203
- options = utils.defaults(this.options, options || {});
6414
+ options = utils.copyOptions(this.options, options || {});
6204
6415
  }
6205
6416
 
6206
6417
  if (!callback) {
@@ -6236,7 +6447,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
6236
6447
  return render;
6237
6448
  };
6238
6449
 
6239
- },{"./utils":87,"promise":undefined}],45:[function(require,module,exports){
6450
+ },{"./utils":89,"promise":undefined}],47:[function(require,module,exports){
6240
6451
  module.exports = function (SourceMapOutput, environment) {
6241
6452
 
6242
6453
  var SourceMapBuilder = function (options) {
@@ -6310,7 +6521,7 @@ module.exports = function (SourceMapOutput, environment) {
6310
6521
  return SourceMapBuilder;
6311
6522
  };
6312
6523
 
6313
- },{}],46:[function(require,module,exports){
6524
+ },{}],48:[function(require,module,exports){
6314
6525
  module.exports = function (environment) {
6315
6526
 
6316
6527
  var SourceMapOutput = function (options) {
@@ -6371,7 +6582,7 @@ module.exports = function (environment) {
6371
6582
  sourceColumns,
6372
6583
  i;
6373
6584
 
6374
- if (fileInfo) {
6585
+ if (fileInfo && fileInfo.filename) {
6375
6586
  var inputSource = this._contentsMap[fileInfo.filename];
6376
6587
 
6377
6588
  // remove vars/banner added to the top of the file
@@ -6390,7 +6601,7 @@ module.exports = function (environment) {
6390
6601
  lines = chunk.split('\n');
6391
6602
  columns = lines[lines.length - 1];
6392
6603
 
6393
- if (fileInfo) {
6604
+ if (fileInfo && fileInfo.filename) {
6394
6605
  if (!mapLines) {
6395
6606
  this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},
6396
6607
  original: { line: sourceLines.length, column: sourceColumns.length},
@@ -6455,7 +6666,7 @@ module.exports = function (environment) {
6455
6666
  return SourceMapOutput;
6456
6667
  };
6457
6668
 
6458
- },{}],47:[function(require,module,exports){
6669
+ },{}],49:[function(require,module,exports){
6459
6670
  var contexts = require('./contexts'),
6460
6671
  visitor = require('./visitors'),
6461
6672
  tree = require('./tree');
@@ -6550,7 +6761,7 @@ module.exports = function(root, options) {
6550
6761
  return evaldRoot;
6551
6762
  };
6552
6763
 
6553
- },{"./contexts":12,"./tree":65,"./visitors":91}],48:[function(require,module,exports){
6764
+ },{"./contexts":13,"./tree":67,"./visitors":93}],50:[function(require,module,exports){
6554
6765
  var Node = require('./node');
6555
6766
 
6556
6767
  var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {
@@ -6581,7 +6792,7 @@ Anonymous.prototype.genCSS = function (context, output) {
6581
6792
  };
6582
6793
  module.exports = Anonymous;
6583
6794
 
6584
- },{"./node":74}],49:[function(require,module,exports){
6795
+ },{"./node":76}],51:[function(require,module,exports){
6585
6796
  var Node = require('./node');
6586
6797
 
6587
6798
  var Assignment = function (key, val) {
@@ -6610,7 +6821,7 @@ Assignment.prototype.genCSS = function (context, output) {
6610
6821
  };
6611
6822
  module.exports = Assignment;
6612
6823
 
6613
- },{"./node":74}],50:[function(require,module,exports){
6824
+ },{"./node":76}],52:[function(require,module,exports){
6614
6825
  var Node = require('./node'),
6615
6826
  Selector = require('./selector'),
6616
6827
  Ruleset = require('./ruleset'),
@@ -6748,7 +6959,7 @@ AtRule.prototype.outputRuleset = function (context, output, rules) {
6748
6959
  };
6749
6960
  module.exports = AtRule;
6750
6961
 
6751
- },{"./anonymous":48,"./node":74,"./ruleset":79,"./selector":80}],51:[function(require,module,exports){
6962
+ },{"./anonymous":50,"./node":76,"./ruleset":81,"./selector":82}],53:[function(require,module,exports){
6752
6963
  var Node = require('./node');
6753
6964
 
6754
6965
  var Attribute = function (key, op, value) {
@@ -6777,7 +6988,7 @@ Attribute.prototype.toCSS = function (context) {
6777
6988
  };
6778
6989
  module.exports = Attribute;
6779
6990
 
6780
- },{"./node":74}],52:[function(require,module,exports){
6991
+ },{"./node":76}],54:[function(require,module,exports){
6781
6992
  var Node = require('./node'),
6782
6993
  Anonymous = require('./anonymous'),
6783
6994
  FunctionCaller = require('../functions/function-caller');
@@ -6876,7 +7087,7 @@ Call.prototype.genCSS = function (context, output) {
6876
7087
  };
6877
7088
  module.exports = Call;
6878
7089
 
6879
- },{"../functions/function-caller":25,"./anonymous":48,"./node":74}],53:[function(require,module,exports){
7090
+ },{"../functions/function-caller":26,"./anonymous":50,"./node":76}],55:[function(require,module,exports){
6880
7091
  var Node = require('./node'),
6881
7092
  colors = require('../data/colors');
6882
7093
 
@@ -6884,6 +7095,7 @@ var Node = require('./node'),
6884
7095
  // RGB Colors - #ff0014, #eee
6885
7096
  //
6886
7097
  var Color = function (rgb, a, originalForm) {
7098
+ var self = this;
6887
7099
  //
6888
7100
  // The end goal here, is to parse the arguments
6889
7101
  // into an integer triplet, such as `128, 255, 0`
@@ -6892,16 +7104,26 @@ var Color = function (rgb, a, originalForm) {
6892
7104
  //
6893
7105
  if (Array.isArray(rgb)) {
6894
7106
  this.rgb = rgb;
6895
- } else if (rgb.length == 6) {
6896
- this.rgb = rgb.match(/.{2}/g).map(function (c) {
6897
- 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
+ }
6898
7115
  });
6899
7116
  } else {
6900
- this.rgb = rgb.split('').map(function (c) {
6901
- 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
+ }
6902
7124
  });
6903
7125
  }
6904
- this.alpha = typeof a === 'number' ? a : 1;
7126
+ this.alpha = this.alpha || (typeof a === 'number' ? a : 1);
6905
7127
  if (typeof originalForm !== 'undefined') {
6906
7128
  this.value = originalForm;
6907
7129
  }
@@ -6936,25 +7158,54 @@ Color.prototype.genCSS = function (context, output) {
6936
7158
  output.add(this.toCSS(context));
6937
7159
  };
6938
7160
  Color.prototype.toCSS = function (context, doNotCompress) {
6939
- var compress = context && context.compress && !doNotCompress, color, alpha;
7161
+ var compress = context && context.compress && !doNotCompress, color, alpha,
7162
+ colorFunction, args = [];
6940
7163
 
6941
7164
  // `value` is set if this color was originally
6942
7165
  // converted from a named color string so we need
6943
7166
  // to respect this and try to output named color too.
7167
+ alpha = this.fround(context, this.alpha);
7168
+
6944
7169
  if (this.value) {
6945
- 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
+ }
6946
7187
  }
6947
7188
 
6948
- // If we have some transparency, the only way to represent it
6949
- // is via `rgba`. Otherwise, we use the hex representation,
6950
- // which has better compatibility with older browsers.
6951
- // Values are capped between `0` and `255`, rounded and zero-padded.
6952
- alpha = this.fround(context, this.alpha);
6953
- if (alpha < 1) {
6954
- return 'rgba(' + this.rgb.map(function (c) {
6955
- return clamp(Math.round(c), 255);
6956
- }).concat(clamp(alpha, 1))
6957
- .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 ? '' : ' ')) + ')';
6958
7209
  }
6959
7210
 
6960
7211
  color = this.toRGB();
@@ -7067,7 +7318,7 @@ Color.fromKeyword = function(keyword) {
7067
7318
  };
7068
7319
  module.exports = Color;
7069
7320
 
7070
- },{"../data/colors":13,"./node":74}],54:[function(require,module,exports){
7321
+ },{"../data/colors":14,"./node":76}],56:[function(require,module,exports){
7071
7322
  var Node = require('./node');
7072
7323
 
7073
7324
  var Combinator = function (value) {
@@ -7092,7 +7343,7 @@ Combinator.prototype.genCSS = function (context, output) {
7092
7343
  };
7093
7344
  module.exports = Combinator;
7094
7345
 
7095
- },{"./node":74}],55:[function(require,module,exports){
7346
+ },{"./node":76}],57:[function(require,module,exports){
7096
7347
  var Node = require('./node'),
7097
7348
  getDebugInfo = require('./debug-info');
7098
7349
 
@@ -7117,7 +7368,7 @@ Comment.prototype.isSilent = function(context) {
7117
7368
  };
7118
7369
  module.exports = Comment;
7119
7370
 
7120
- },{"./debug-info":57,"./node":74}],56:[function(require,module,exports){
7371
+ },{"./debug-info":59,"./node":76}],58:[function(require,module,exports){
7121
7372
  var Node = require('./node');
7122
7373
 
7123
7374
  var Condition = function (op, l, r, i, negate) {
@@ -7156,7 +7407,7 @@ Condition.prototype.eval = function (context) {
7156
7407
  };
7157
7408
  module.exports = Condition;
7158
7409
 
7159
- },{"./node":74}],57:[function(require,module,exports){
7410
+ },{"./node":76}],59:[function(require,module,exports){
7160
7411
  var debugInfo = function(context, ctx, lineSeparator) {
7161
7412
  var result = '';
7162
7413
  if (context.dumpLineNumbers && !context.compress) {
@@ -7196,11 +7447,12 @@ debugInfo.asMediaQuery = function(ctx) {
7196
7447
 
7197
7448
  module.exports = debugInfo;
7198
7449
 
7199
- },{}],58:[function(require,module,exports){
7450
+ },{}],60:[function(require,module,exports){
7200
7451
  var Node = require('./node'),
7201
7452
  Value = require('./value'),
7202
7453
  Keyword = require('./keyword'),
7203
- Anonymous = require('./anonymous');
7454
+ Anonymous = require('./anonymous'),
7455
+ MATH = require('../constants').Math;
7204
7456
 
7205
7457
  var Declaration = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
7206
7458
  this.name = name;
@@ -7240,7 +7492,7 @@ Declaration.prototype.genCSS = function (context, output) {
7240
7492
  output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? '' : ';'), this._fileInfo, this._index);
7241
7493
  };
7242
7494
  Declaration.prototype.eval = function (context) {
7243
- var strictMathBypass = false, name = this.name, evaldValue, variable = this.variable;
7495
+ var mathBypass = false, prevMath, name = this.name, evaldValue, variable = this.variable;
7244
7496
  if (typeof name !== 'string') {
7245
7497
  // expand 'primitive' name directly to get
7246
7498
  // things faster (~10% for benchmark.less):
@@ -7248,9 +7500,12 @@ Declaration.prototype.eval = function (context) {
7248
7500
  name[0].value : evalName(context, name);
7249
7501
  variable = false; // never treat expanded interpolation as new variable name
7250
7502
  }
7251
- if (name === 'font' && !context.strictMath) {
7252
- strictMathBypass = true;
7253
- context.strictMath = true;
7503
+
7504
+ // @todo remove when parens-division is default
7505
+ if (name === 'font' && context.math === MATH.ALWAYS) {
7506
+ mathBypass = true;
7507
+ prevMath = context.math;
7508
+ context.math = MATH.PARENS_DIVISION;
7254
7509
  }
7255
7510
  try {
7256
7511
  context.importantScope.push({});
@@ -7281,8 +7536,8 @@ Declaration.prototype.eval = function (context) {
7281
7536
  throw e;
7282
7537
  }
7283
7538
  finally {
7284
- if (strictMathBypass) {
7285
- context.strictMath = false;
7539
+ if (mathBypass) {
7540
+ context.math = prevMath;
7286
7541
  }
7287
7542
  }
7288
7543
  };
@@ -7295,7 +7550,7 @@ Declaration.prototype.makeImportant = function () {
7295
7550
  };
7296
7551
 
7297
7552
  module.exports = Declaration;
7298
- },{"./anonymous":48,"./keyword":68,"./node":74,"./value":84}],59:[function(require,module,exports){
7553
+ },{"../constants":12,"./anonymous":50,"./keyword":70,"./node":76,"./value":86}],61:[function(require,module,exports){
7299
7554
  var Node = require('./node'),
7300
7555
  contexts = require('../contexts'),
7301
7556
  utils = require('../utils');
@@ -7320,7 +7575,7 @@ DetachedRuleset.prototype.callEval = function (context) {
7320
7575
  };
7321
7576
  module.exports = DetachedRuleset;
7322
7577
 
7323
- },{"../contexts":12,"../utils":87,"./node":74}],60:[function(require,module,exports){
7578
+ },{"../contexts":13,"../utils":89,"./node":76}],62:[function(require,module,exports){
7324
7579
  var Node = require('./node'),
7325
7580
  unitConversions = require('../data/unit-conversions'),
7326
7581
  Unit = require('./unit'),
@@ -7483,7 +7738,7 @@ Dimension.prototype.convertTo = function (conversions) {
7483
7738
  };
7484
7739
  module.exports = Dimension;
7485
7740
 
7486
- },{"../data/unit-conversions":15,"./color":53,"./node":74,"./unit":82}],61:[function(require,module,exports){
7741
+ },{"../data/unit-conversions":16,"./color":55,"./node":76,"./unit":84}],63:[function(require,module,exports){
7487
7742
  var Node = require('./node'),
7488
7743
  Paren = require('./paren'),
7489
7744
  Combinator = require('./combinator');
@@ -7549,10 +7804,12 @@ Element.prototype.toCSS = function (context) {
7549
7804
  };
7550
7805
  module.exports = Element;
7551
7806
 
7552
- },{"./combinator":54,"./node":74,"./paren":76}],62:[function(require,module,exports){
7807
+ },{"./combinator":56,"./node":76,"./paren":78}],64:[function(require,module,exports){
7553
7808
  var Node = require('./node'),
7554
7809
  Paren = require('./paren'),
7555
- Comment = require('./comment');
7810
+ Comment = require('./comment'),
7811
+ Dimension = require('./dimension'),
7812
+ MATH = require('../constants').Math;
7556
7813
 
7557
7814
  var Expression = function (value, noSpacing) {
7558
7815
  this.value = value;
@@ -7569,7 +7826,8 @@ Expression.prototype.accept = function (visitor) {
7569
7826
  Expression.prototype.eval = function (context) {
7570
7827
  var returnValue,
7571
7828
  mathOn = context.isMathOn(),
7572
- inParenthesis = this.parens && !this.parensInOp,
7829
+ inParenthesis = this.parens &&
7830
+ (context.math !== MATH.STRICT_LEGACY || !this.parensInOp),
7573
7831
  doubleParen = false;
7574
7832
  if (inParenthesis) {
7575
7833
  context.inParenthesis();
@@ -7592,7 +7850,8 @@ Expression.prototype.eval = function (context) {
7592
7850
  if (inParenthesis) {
7593
7851
  context.outOfParenthesis();
7594
7852
  }
7595
- if (this.parens && this.parensInOp && !mathOn && !doubleParen) {
7853
+ if (this.parens && this.parensInOp && !mathOn && !doubleParen
7854
+ && (!(returnValue instanceof Dimension))) {
7596
7855
  returnValue = new Paren(returnValue);
7597
7856
  }
7598
7857
  return returnValue;
@@ -7612,7 +7871,7 @@ Expression.prototype.throwAwayComments = function () {
7612
7871
  };
7613
7872
  module.exports = Expression;
7614
7873
 
7615
- },{"./comment":55,"./node":74,"./paren":76}],63:[function(require,module,exports){
7874
+ },{"../constants":12,"./comment":57,"./dimension":62,"./node":76,"./paren":78}],65:[function(require,module,exports){
7616
7875
  var Node = require('./node'),
7617
7876
  Selector = require('./selector');
7618
7877
 
@@ -7672,7 +7931,7 @@ Extend.prototype.findSelfSelectors = function (selectors) {
7672
7931
  };
7673
7932
  module.exports = Extend;
7674
7933
 
7675
- },{"./node":74,"./selector":80}],64:[function(require,module,exports){
7934
+ },{"./node":76,"./selector":82}],66:[function(require,module,exports){
7676
7935
  var Node = require('./node'),
7677
7936
  Media = require('./media'),
7678
7937
  URL = require('./url'),
@@ -7772,17 +8031,18 @@ Import.prototype.evalForImport = function (context) {
7772
8031
  };
7773
8032
  Import.prototype.evalPath = function (context) {
7774
8033
  var path = this.path.eval(context);
7775
- var rootpath = this._fileInfo && this._fileInfo.rootpath;
8034
+ var fileInfo = this._fileInfo;
7776
8035
 
7777
8036
  if (!(path instanceof URL)) {
7778
- if (rootpath) {
7779
- var pathValue = path.value;
7780
- // Add the base path if the import is relative
7781
- if (pathValue && context.isPathRelative(pathValue)) {
7782
- path.value = rootpath + pathValue;
7783
- }
8037
+ // Add the rootpath if the URL requires a rewrite
8038
+ var pathValue = path.value;
8039
+ if (fileInfo &&
8040
+ pathValue &&
8041
+ context.pathRequiresRewrite(pathValue)) {
8042
+ path.value = context.rewritePath(pathValue, fileInfo.rootpath);
8043
+ } else {
8044
+ path.value = context.normalizePath(path.value);
7784
8045
  }
7785
- path.value = context.normalizePath(path.value);
7786
8046
  }
7787
8047
 
7788
8048
  return path;
@@ -7854,7 +8114,7 @@ Import.prototype.doEval = function (context) {
7854
8114
  };
7855
8115
  module.exports = Import;
7856
8116
 
7857
- },{"../less-error":36,"../utils":87,"./anonymous":48,"./media":69,"./node":74,"./quoted":78,"./ruleset":79,"./url":83}],65:[function(require,module,exports){
8117
+ },{"../less-error":38,"../utils":89,"./anonymous":50,"./media":71,"./node":76,"./quoted":80,"./ruleset":81,"./url":85}],67:[function(require,module,exports){
7858
8118
  var tree = Object.create(null);
7859
8119
 
7860
8120
  tree.Node = require('./node');
@@ -7898,7 +8158,7 @@ tree.NamespaceValue = require('./namespace-value');
7898
8158
 
7899
8159
  module.exports = tree;
7900
8160
 
7901
- },{"./anonymous":48,"./assignment":49,"./atrule":50,"./attribute":51,"./call":52,"./color":53,"./combinator":54,"./comment":55,"./condition":56,"./declaration":58,"./detached-ruleset":59,"./dimension":60,"./element":61,"./expression":62,"./extend":63,"./import":64,"./javascript":66,"./keyword":68,"./media":69,"./mixin-call":70,"./mixin-definition":71,"./namespace-value":72,"./negative":73,"./node":74,"./operation":75,"./paren":76,"./property":77,"./quoted":78,"./ruleset":79,"./selector":80,"./unicode-descriptor":81,"./unit":82,"./url":83,"./value":84,"./variable":86,"./variable-call":85}],66:[function(require,module,exports){
8161
+ },{"./anonymous":50,"./assignment":51,"./atrule":52,"./attribute":53,"./call":54,"./color":55,"./combinator":56,"./comment":57,"./condition":58,"./declaration":60,"./detached-ruleset":61,"./dimension":62,"./element":63,"./expression":64,"./extend":65,"./import":66,"./javascript":68,"./keyword":70,"./media":71,"./mixin-call":72,"./mixin-definition":73,"./namespace-value":74,"./negative":75,"./node":76,"./operation":77,"./paren":78,"./property":79,"./quoted":80,"./ruleset":81,"./selector":82,"./unicode-descriptor":83,"./unit":84,"./url":85,"./value":86,"./variable":88,"./variable-call":87}],68:[function(require,module,exports){
7902
8162
  var JsEvalNode = require('./js-eval-node'),
7903
8163
  Dimension = require('./dimension'),
7904
8164
  Quoted = require('./quoted'),
@@ -7929,7 +8189,7 @@ JavaScript.prototype.eval = function(context) {
7929
8189
 
7930
8190
  module.exports = JavaScript;
7931
8191
 
7932
- },{"./anonymous":48,"./dimension":60,"./js-eval-node":67,"./quoted":78}],67:[function(require,module,exports){
8192
+ },{"./anonymous":50,"./dimension":62,"./js-eval-node":69,"./quoted":80}],69:[function(require,module,exports){
7933
8193
  var Node = require('./node'),
7934
8194
  Variable = require('./variable');
7935
8195
 
@@ -7992,7 +8252,7 @@ JsEvalNode.prototype.jsify = function (obj) {
7992
8252
 
7993
8253
  module.exports = JsEvalNode;
7994
8254
 
7995
- },{"./node":74,"./variable":86}],68:[function(require,module,exports){
8255
+ },{"./node":76,"./variable":88}],70:[function(require,module,exports){
7996
8256
  var Node = require('./node');
7997
8257
 
7998
8258
  var Keyword = function (value) { this.value = value; };
@@ -8008,7 +8268,7 @@ Keyword.False = new Keyword('false');
8008
8268
 
8009
8269
  module.exports = Keyword;
8010
8270
 
8011
- },{"./node":74}],69:[function(require,module,exports){
8271
+ },{"./node":76}],71:[function(require,module,exports){
8012
8272
  var Ruleset = require('./ruleset'),
8013
8273
  Value = require('./value'),
8014
8274
  Selector = require('./selector'),
@@ -8151,7 +8411,7 @@ Media.prototype.bubbleSelectors = function (selectors) {
8151
8411
  };
8152
8412
  module.exports = Media;
8153
8413
 
8154
- },{"../utils":87,"./anonymous":48,"./atrule":50,"./expression":62,"./ruleset":79,"./selector":80,"./value":84}],70:[function(require,module,exports){
8414
+ },{"../utils":89,"./anonymous":50,"./atrule":52,"./expression":64,"./ruleset":81,"./selector":82,"./value":86}],72:[function(require,module,exports){
8155
8415
  var Node = require('./node'),
8156
8416
  Selector = require('./selector'),
8157
8417
  MixinDefinition = require('./mixin-definition'),
@@ -8339,7 +8599,7 @@ MixinCall.prototype.format = function (args) {
8339
8599
  };
8340
8600
  module.exports = MixinCall;
8341
8601
 
8342
- },{"../functions/default":24,"./mixin-definition":71,"./node":74,"./selector":80}],71:[function(require,module,exports){
8602
+ },{"../functions/default":25,"./mixin-definition":73,"./node":76,"./selector":82}],73:[function(require,module,exports){
8343
8603
  var Selector = require('./selector'),
8344
8604
  Element = require('./element'),
8345
8605
  Ruleset = require('./ruleset'),
@@ -8350,7 +8610,7 @@ var Selector = require('./selector'),
8350
8610
  utils = require('../utils');
8351
8611
 
8352
8612
  var Definition = function (name, params, rules, condition, variadic, frames, visibilityInfo) {
8353
- this.name = name;
8613
+ this.name = name || 'anonymous mixin';
8354
8614
  this.selectors = [new Selector([new Element(null, name, false, this._index, this._fileInfo)])];
8355
8615
  this.params = params;
8356
8616
  this.condition = condition;
@@ -8550,7 +8810,7 @@ Definition.prototype.matchArgs = function (args, context) {
8550
8810
  };
8551
8811
  module.exports = Definition;
8552
8812
 
8553
- },{"../contexts":12,"../utils":87,"./declaration":58,"./detached-ruleset":59,"./element":61,"./expression":62,"./ruleset":79,"./selector":80}],72:[function(require,module,exports){
8813
+ },{"../contexts":13,"../utils":89,"./declaration":60,"./detached-ruleset":61,"./element":63,"./expression":64,"./ruleset":81,"./selector":82}],74:[function(require,module,exports){
8554
8814
  var Node = require('./node'),
8555
8815
  Variable = require('./variable'),
8556
8816
  Ruleset = require('./ruleset'),
@@ -8631,7 +8891,7 @@ NamespaceValue.prototype.eval = function (context) {
8631
8891
  };
8632
8892
  module.exports = NamespaceValue;
8633
8893
 
8634
- },{"./node":74,"./ruleset":79,"./selector":80,"./variable":86}],73:[function(require,module,exports){
8894
+ },{"./node":76,"./ruleset":81,"./selector":82,"./variable":88}],75:[function(require,module,exports){
8635
8895
  var Node = require('./node'),
8636
8896
  Operation = require('./operation'),
8637
8897
  Dimension = require('./dimension');
@@ -8653,7 +8913,7 @@ Negative.prototype.eval = function (context) {
8653
8913
  };
8654
8914
  module.exports = Negative;
8655
8915
 
8656
- },{"./dimension":60,"./node":74,"./operation":75}],74:[function(require,module,exports){
8916
+ },{"./dimension":62,"./node":76,"./operation":77}],76:[function(require,module,exports){
8657
8917
  var Node = function() {
8658
8918
  this.parent = null;
8659
8919
  this.visibilityBlocks = undefined;
@@ -8812,10 +9072,11 @@ Node.prototype.copyVisibilityInfo = function(info) {
8812
9072
  };
8813
9073
  module.exports = Node;
8814
9074
 
8815
- },{}],75:[function(require,module,exports){
9075
+ },{}],77:[function(require,module,exports){
8816
9076
  var Node = require('./node'),
8817
9077
  Color = require('./color'),
8818
- Dimension = require('./dimension');
9078
+ Dimension = require('./dimension'),
9079
+ MATH = require('../constants').Math;
8819
9080
 
8820
9081
  var Operation = function (op, operands, isSpaced) {
8821
9082
  this.op = op.trim();
@@ -8829,9 +9090,11 @@ Operation.prototype.accept = function (visitor) {
8829
9090
  };
8830
9091
  Operation.prototype.eval = function (context) {
8831
9092
  var a = this.operands[0].eval(context),
8832
- b = this.operands[1].eval(context);
9093
+ b = this.operands[1].eval(context),
9094
+ op;
8833
9095
 
8834
- if (context.isMathOn()) {
9096
+ if (context.isMathOn(this.op)) {
9097
+ op = this.op === './' ? '/' : this.op;
8835
9098
  if (a instanceof Dimension && b instanceof Color) {
8836
9099
  a = a.toColor();
8837
9100
  }
@@ -8839,11 +9102,14 @@ Operation.prototype.eval = function (context) {
8839
9102
  b = b.toColor();
8840
9103
  }
8841
9104
  if (!a.operate) {
9105
+ if (a instanceof Operation && a.op === '/' && context.math === MATH.PARENS_DIVISION) {
9106
+ return new Operation(this.op, [a, b], this.isSpaced);
9107
+ }
8842
9108
  throw { type: 'Operation',
8843
9109
  message: 'Operation on an invalid type' };
8844
9110
  }
8845
9111
 
8846
- return a.operate(context, this.op, b);
9112
+ return a.operate(context, op, b);
8847
9113
  } else {
8848
9114
  return new Operation(this.op, [a, b], this.isSpaced);
8849
9115
  }
@@ -8862,7 +9128,7 @@ Operation.prototype.genCSS = function (context, output) {
8862
9128
 
8863
9129
  module.exports = Operation;
8864
9130
 
8865
- },{"./color":53,"./dimension":60,"./node":74}],76:[function(require,module,exports){
9131
+ },{"../constants":12,"./color":55,"./dimension":62,"./node":76}],78:[function(require,module,exports){
8866
9132
  var Node = require('./node');
8867
9133
 
8868
9134
  var Paren = function (node) {
@@ -8880,7 +9146,7 @@ Paren.prototype.eval = function (context) {
8880
9146
  };
8881
9147
  module.exports = Paren;
8882
9148
 
8883
- },{"./node":74}],77:[function(require,module,exports){
9149
+ },{"./node":76}],79:[function(require,module,exports){
8884
9150
  var Node = require('./node'),
8885
9151
  Declaration = require('./declaration');
8886
9152
 
@@ -8952,7 +9218,7 @@ Property.prototype.find = function (obj, fun) {
8952
9218
  };
8953
9219
  module.exports = Property;
8954
9220
 
8955
- },{"./declaration":58,"./node":74}],78:[function(require,module,exports){
9221
+ },{"./declaration":60,"./node":76}],80:[function(require,module,exports){
8956
9222
  var Node = require('./node'),
8957
9223
  Variable = require('./variable'),
8958
9224
  Property = require('./property');
@@ -9012,7 +9278,7 @@ Quoted.prototype.compare = function (other) {
9012
9278
  };
9013
9279
  module.exports = Quoted;
9014
9280
 
9015
- },{"./node":74,"./property":77,"./variable":86}],79:[function(require,module,exports){
9281
+ },{"./node":76,"./property":79,"./variable":88}],81:[function(require,module,exports){
9016
9282
  var Node = require('./node'),
9017
9283
  Declaration = require('./declaration'),
9018
9284
  Keyword = require('./keyword'),
@@ -9822,7 +10088,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
9822
10088
  };
9823
10089
  module.exports = Ruleset;
9824
10090
 
9825
- },{"../contexts":12,"../functions/default":24,"../functions/function-registry":26,"../utils":87,"./anonymous":48,"./comment":55,"./debug-info":57,"./declaration":58,"./element":61,"./keyword":68,"./node":74,"./paren":76,"./selector":80}],80:[function(require,module,exports){
10091
+ },{"../contexts":13,"../functions/default":25,"../functions/function-registry":27,"../utils":89,"./anonymous":50,"./comment":57,"./debug-info":59,"./declaration":60,"./element":63,"./keyword":70,"./node":76,"./paren":78,"./selector":82}],82:[function(require,module,exports){
9826
10092
  var Node = require('./node'),
9827
10093
  Element = require('./element'),
9828
10094
  LessError = require('../less-error');
@@ -9955,7 +10221,7 @@ Selector.prototype.getIsOutput = function() {
9955
10221
  };
9956
10222
  module.exports = Selector;
9957
10223
 
9958
- },{"../less-error":36,"./element":61,"./node":74}],81:[function(require,module,exports){
10224
+ },{"../less-error":38,"./element":63,"./node":76}],83:[function(require,module,exports){
9959
10225
  var Node = require('./node');
9960
10226
 
9961
10227
  var UnicodeDescriptor = function (value) {
@@ -9966,7 +10232,7 @@ UnicodeDescriptor.prototype.type = 'UnicodeDescriptor';
9966
10232
 
9967
10233
  module.exports = UnicodeDescriptor;
9968
10234
 
9969
- },{"./node":74}],82:[function(require,module,exports){
10235
+ },{"./node":76}],84:[function(require,module,exports){
9970
10236
  var Node = require('./node'),
9971
10237
  unitConversions = require('../data/unit-conversions'),
9972
10238
  utils = require('../utils');
@@ -10089,7 +10355,7 @@ Unit.prototype.cancel = function () {
10089
10355
  };
10090
10356
  module.exports = Unit;
10091
10357
 
10092
- },{"../data/unit-conversions":15,"../utils":87,"./node":74}],83:[function(require,module,exports){
10358
+ },{"../data/unit-conversions":16,"../utils":89,"./node":76}],85:[function(require,module,exports){
10093
10359
  var Node = require('./node');
10094
10360
 
10095
10361
  var URL = function (val, index, currentFileInfo, isEvald) {
@@ -10113,20 +10379,19 @@ URL.prototype.eval = function (context) {
10113
10379
  rootpath;
10114
10380
 
10115
10381
  if (!this.isEvald) {
10116
- // Add the base path if the URL is relative
10382
+ // Add the rootpath if the URL requires a rewrite
10117
10383
  rootpath = this.fileInfo() && this.fileInfo().rootpath;
10118
- if (rootpath &&
10384
+ if (typeof rootpath === 'string' &&
10119
10385
  typeof val.value === 'string' &&
10120
- context.isPathRelative(val.value)) {
10121
-
10386
+ context.pathRequiresRewrite(val.value)) {
10122
10387
  if (!val.quote) {
10123
- rootpath = rootpath.replace(/[\(\)'"\s]/g, function(match) { return '\\' + match; });
10388
+ rootpath = escapePath(rootpath);
10124
10389
  }
10125
- val.value = rootpath + val.value;
10390
+ val.value = context.rewritePath(val.value, rootpath);
10391
+ } else {
10392
+ val.value = context.normalizePath(val.value);
10126
10393
  }
10127
10394
 
10128
- val.value = context.normalizePath(val.value);
10129
-
10130
10395
  // Add url args if enabled
10131
10396
  if (context.urlArgs) {
10132
10397
  if (!val.value.match(/^\s*data:/)) {
@@ -10143,9 +10408,14 @@ URL.prototype.eval = function (context) {
10143
10408
 
10144
10409
  return new URL(val, this.getIndex(), this.fileInfo(), true);
10145
10410
  };
10411
+
10412
+ function escapePath(path) {
10413
+ return path.replace(/[\(\)'"\s]/g, function(match) { return '\\' + match; });
10414
+ }
10415
+
10146
10416
  module.exports = URL;
10147
10417
 
10148
- },{"./node":74}],84:[function(require,module,exports){
10418
+ },{"./node":76}],86:[function(require,module,exports){
10149
10419
  var Node = require('./node');
10150
10420
 
10151
10421
  var Value = function (value) {
@@ -10186,7 +10456,7 @@ Value.prototype.genCSS = function (context, output) {
10186
10456
  };
10187
10457
  module.exports = Value;
10188
10458
 
10189
- },{"./node":74}],85:[function(require,module,exports){
10459
+ },{"./node":76}],87:[function(require,module,exports){
10190
10460
  var Node = require('./node'),
10191
10461
  Variable = require('./variable'),
10192
10462
  Ruleset = require('./ruleset'),
@@ -10224,7 +10494,7 @@ VariableCall.prototype.eval = function (context) {
10224
10494
  };
10225
10495
  module.exports = VariableCall;
10226
10496
 
10227
- },{"../less-error":36,"./detached-ruleset":59,"./node":74,"./ruleset":79,"./variable":86}],86:[function(require,module,exports){
10497
+ },{"../less-error":38,"./detached-ruleset":61,"./node":76,"./ruleset":81,"./variable":88}],88:[function(require,module,exports){
10228
10498
  var Node = require('./node'),
10229
10499
  Call = require('./call');
10230
10500
 
@@ -10286,8 +10556,11 @@ Variable.prototype.find = function (obj, fun) {
10286
10556
  };
10287
10557
  module.exports = Variable;
10288
10558
 
10289
- },{"./call":52,"./node":74}],87:[function(require,module,exports){
10559
+ },{"./call":54,"./node":76}],89:[function(require,module,exports){
10290
10560
  /* jshint proto: true */
10561
+ var Constants = require('./constants');
10562
+ var clone = require('clone');
10563
+
10291
10564
  var utils = {
10292
10565
  getLocation: function(index, inputStream) {
10293
10566
  var n = index + 1,
@@ -10325,27 +10598,59 @@ var utils = {
10325
10598
  }
10326
10599
  return cloned;
10327
10600
  },
10328
- defaults: function(obj1, obj2) {
10329
- if (!obj2._defaults || obj2._defaults !== obj1) {
10330
- for (var prop in obj1) {
10331
- if (obj1.hasOwnProperty(prop)) {
10332
- if (!obj2.hasOwnProperty(prop)) {
10333
- obj2[prop] = obj1[prop];
10334
- }
10335
- else if (Array.isArray(obj1[prop])
10336
- && Array.isArray(obj2[prop])) {
10337
-
10338
- obj1[prop].forEach(function(p) {
10339
- if (obj2[prop].indexOf(p) === -1) {
10340
- obj2[prop].push(p);
10341
- }
10342
- });
10343
- }
10344
- }
10601
+ copyOptions: function(obj1, obj2) {
10602
+ if (obj2 && obj2._defaults) {
10603
+ return obj2;
10604
+ }
10605
+ var opts = utils.defaults(obj1, obj2);
10606
+ if (opts.strictMath) {
10607
+ opts.math = Constants.Math.STRICT_LEGACY;
10608
+ }
10609
+ // Back compat with changed relativeUrls option
10610
+ if (opts.relativeUrls) {
10611
+ opts.rewriteUrls = Constants.RewriteUrls.ALL;
10612
+ }
10613
+ if (typeof opts.math === 'string') {
10614
+ switch (opts.math.toLowerCase()) {
10615
+ case 'always':
10616
+ opts.math = Constants.Math.ALWAYS;
10617
+ break;
10618
+ case 'parens-division':
10619
+ opts.math = Constants.Math.PARENS_DIVISION;
10620
+ break;
10621
+ case 'strict':
10622
+ case 'parens':
10623
+ opts.math = Constants.Math.PARENS;
10624
+ break;
10625
+ case 'strict-legacy':
10626
+ opts.math = Constants.Math.STRICT_LEGACY;
10627
+ }
10628
+ }
10629
+ if (typeof opts.rewriteUrls === 'string') {
10630
+ switch (opts.rewriteUrls.toLowerCase()) {
10631
+ case 'off':
10632
+ opts.rewriteUrls = Constants.RewriteUrls.OFF;
10633
+ break;
10634
+ case 'local':
10635
+ opts.rewriteUrls = Constants.RewriteUrls.LOCAL;
10636
+ break;
10637
+ case 'all':
10638
+ opts.rewriteUrls = Constants.RewriteUrls.ALL;
10639
+ break;
10345
10640
  }
10346
10641
  }
10347
- obj2._defaults = obj1;
10348
- return obj2;
10642
+ return opts;
10643
+ },
10644
+ defaults: function(obj1, obj2) {
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);
10652
+ }
10653
+ return newObj;
10349
10654
  },
10350
10655
  merge: function(obj1, obj2) {
10351
10656
  for (var prop in obj2) {
@@ -10372,7 +10677,7 @@ var utils = {
10372
10677
  };
10373
10678
 
10374
10679
  module.exports = utils;
10375
- },{}],88:[function(require,module,exports){
10680
+ },{"./constants":12,"clone":102}],90:[function(require,module,exports){
10376
10681
  var tree = require('../tree'),
10377
10682
  Visitor = require('./visitor'),
10378
10683
  logger = require('../logger'),
@@ -10836,7 +11141,7 @@ ProcessExtendsVisitor.prototype = {
10836
11141
 
10837
11142
  module.exports = ProcessExtendsVisitor;
10838
11143
 
10839
- },{"../logger":37,"../tree":65,"../utils":87,"./visitor":95}],89:[function(require,module,exports){
11144
+ },{"../logger":39,"../tree":67,"../utils":89,"./visitor":97}],91:[function(require,module,exports){
10840
11145
  function ImportSequencer(onSequencerEmpty) {
10841
11146
  this.imports = [];
10842
11147
  this.variableImports = [];
@@ -10892,7 +11197,7 @@ ImportSequencer.prototype.tryRun = function() {
10892
11197
 
10893
11198
  module.exports = ImportSequencer;
10894
11199
 
10895
- },{}],90:[function(require,module,exports){
11200
+ },{}],92:[function(require,module,exports){
10896
11201
  var contexts = require('../contexts'),
10897
11202
  Visitor = require('./visitor'),
10898
11203
  ImportSequencer = require('./import-sequencer'),
@@ -11084,7 +11389,7 @@ ImportVisitor.prototype = {
11084
11389
  };
11085
11390
  module.exports = ImportVisitor;
11086
11391
 
11087
- },{"../contexts":12,"../utils":87,"./import-sequencer":89,"./visitor":95}],91:[function(require,module,exports){
11392
+ },{"../contexts":13,"../utils":89,"./import-sequencer":91,"./visitor":97}],93:[function(require,module,exports){
11088
11393
  var visitors = {
11089
11394
  Visitor: require('./visitor'),
11090
11395
  ImportVisitor: require('./import-visitor'),
@@ -11096,7 +11401,7 @@ var visitors = {
11096
11401
 
11097
11402
  module.exports = visitors;
11098
11403
 
11099
- },{"./extend-visitor":88,"./import-visitor":90,"./join-selector-visitor":92,"./set-tree-visibility-visitor":93,"./to-css-visitor":94,"./visitor":95}],92:[function(require,module,exports){
11404
+ },{"./extend-visitor":90,"./import-visitor":92,"./join-selector-visitor":94,"./set-tree-visibility-visitor":95,"./to-css-visitor":96,"./visitor":97}],94:[function(require,module,exports){
11100
11405
  var Visitor = require('./visitor');
11101
11406
 
11102
11407
  var JoinSelectorVisitor = function() {
@@ -11149,7 +11454,7 @@ JoinSelectorVisitor.prototype = {
11149
11454
 
11150
11455
  module.exports = JoinSelectorVisitor;
11151
11456
 
11152
- },{"./visitor":95}],93:[function(require,module,exports){
11457
+ },{"./visitor":97}],95:[function(require,module,exports){
11153
11458
  var SetTreeVisibilityVisitor = function(visible) {
11154
11459
  this.visible = visible;
11155
11460
  };
@@ -11188,7 +11493,7 @@ SetTreeVisibilityVisitor.prototype.visit = function(node) {
11188
11493
  return node;
11189
11494
  };
11190
11495
  module.exports = SetTreeVisibilityVisitor;
11191
- },{}],94:[function(require,module,exports){
11496
+ },{}],96:[function(require,module,exports){
11192
11497
  var tree = require('../tree'),
11193
11498
  Visitor = require('./visitor');
11194
11499
 
@@ -11550,7 +11855,7 @@ ToCSSVisitor.prototype = {
11550
11855
 
11551
11856
  module.exports = ToCSSVisitor;
11552
11857
 
11553
- },{"../tree":65,"./visitor":95}],95:[function(require,module,exports){
11858
+ },{"../tree":67,"./visitor":97}],97:[function(require,module,exports){
11554
11859
  var tree = require('../tree');
11555
11860
 
11556
11861
  var _visitArgs = { visitDeeper: true },
@@ -11706,7 +12011,7 @@ Visitor.prototype = {
11706
12011
  };
11707
12012
  module.exports = Visitor;
11708
12013
 
11709
- },{"../tree":65}],96:[function(require,module,exports){
12014
+ },{"../tree":67}],98:[function(require,module,exports){
11710
12015
  "use strict";
11711
12016
 
11712
12017
  // rawAsap provides everything we need except exception management.
@@ -11774,7 +12079,7 @@ RawTask.prototype.call = function () {
11774
12079
  }
11775
12080
  };
11776
12081
 
11777
- },{"./raw":97}],97:[function(require,module,exports){
12082
+ },{"./raw":99}],99:[function(require,module,exports){
11778
12083
  (function (global){
11779
12084
  "use strict";
11780
12085
 
@@ -12001,80 +12306,2259 @@ rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
12001
12306
  // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
12002
12307
 
12003
12308
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
12004
- },{}],98:[function(require,module,exports){
12005
- 'use strict';
12309
+ },{}],100:[function(require,module,exports){
12310
+ 'use strict'
12006
12311
 
12007
- var asap = require('asap/raw');
12008
-
12009
- function noop() {}
12312
+ exports.byteLength = byteLength
12313
+ exports.toByteArray = toByteArray
12314
+ exports.fromByteArray = fromByteArray
12010
12315
 
12011
- // States:
12012
- //
12013
- // 0 - pending
12014
- // 1 - fulfilled with _value
12015
- // 2 - rejected with _value
12016
- // 3 - adopted the state of another promise, _value
12017
- //
12018
- // once the state is no longer pending (0) it is immutable
12316
+ var lookup = []
12317
+ var revLookup = []
12318
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
12019
12319
 
12020
- // All `_` prefixed properties will be reduced to `_{random number}`
12021
- // at build time to obfuscate them and discourage their use.
12022
- // We don't use symbols or Object.defineProperty to fully hide them
12023
- // because the performance isn't good enough.
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
+ }
12024
12325
 
12326
+ revLookup['-'.charCodeAt(0)] = 62
12327
+ revLookup['_'.charCodeAt(0)] = 63
12025
12328
 
12026
- // to avoid using try/catch inside critical functions, we
12027
- // extract them to here.
12028
- var LAST_ERROR = null;
12029
- var IS_ERROR = {};
12030
- function getThen(obj) {
12031
- try {
12032
- return obj.then;
12033
- } catch (ex) {
12034
- LAST_ERROR = ex;
12035
- return IS_ERROR;
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')
12036
12333
  }
12037
- }
12038
12334
 
12039
- function tryCallOne(fn, a) {
12040
- try {
12041
- return fn(a);
12042
- } catch (ex) {
12043
- LAST_ERROR = ex;
12044
- return IS_ERROR;
12045
- }
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
12046
12341
  }
12047
- function tryCallTwo(fn, a, b) {
12048
- try {
12049
- fn(a, b);
12050
- } catch (ex) {
12051
- LAST_ERROR = ex;
12052
- return IS_ERROR;
12053
- }
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)
12054
12346
  }
12055
12347
 
12056
- module.exports = Promise;
12348
+ function toByteArray (b64) {
12349
+ var i, l, tmp, placeHolders, arr
12350
+ var len = b64.length
12351
+ placeHolders = placeHoldersCount(b64)
12057
12352
 
12058
- function Promise(fn) {
12059
- if (typeof this !== 'object') {
12060
- throw new TypeError('Promises must be constructed via new');
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
12061
12365
  }
12062
- if (typeof fn !== 'function') {
12063
- throw new TypeError('Promise constructor\'s argument is not a function');
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
12064
12374
  }
12065
- this._40 = 0;
12066
- this._65 = 0;
12067
- this._55 = null;
12068
- this._72 = null;
12069
- if (fn === noop) return;
12070
- doResolve(fn, this);
12375
+
12376
+ return arr
12071
12377
  }
12072
- Promise._37 = null;
12073
- Promise._87 = null;
12074
- Promise._61 = noop;
12075
12378
 
12076
- Promise.prototype.then = function(onFulfilled, onRejected) {
12077
- if (this.constructor !== Promise) {
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){
14489
+ 'use strict';
14490
+
14491
+ var asap = require('asap/raw');
14492
+
14493
+ function noop() {}
14494
+
14495
+ // States:
14496
+ //
14497
+ // 0 - pending
14498
+ // 1 - fulfilled with _value
14499
+ // 2 - rejected with _value
14500
+ // 3 - adopted the state of another promise, _value
14501
+ //
14502
+ // once the state is no longer pending (0) it is immutable
14503
+
14504
+ // All `_` prefixed properties will be reduced to `_{random number}`
14505
+ // at build time to obfuscate them and discourage their use.
14506
+ // We don't use symbols or Object.defineProperty to fully hide them
14507
+ // because the performance isn't good enough.
14508
+
14509
+
14510
+ // to avoid using try/catch inside critical functions, we
14511
+ // extract them to here.
14512
+ var LAST_ERROR = null;
14513
+ var IS_ERROR = {};
14514
+ function getThen(obj) {
14515
+ try {
14516
+ return obj.then;
14517
+ } catch (ex) {
14518
+ LAST_ERROR = ex;
14519
+ return IS_ERROR;
14520
+ }
14521
+ }
14522
+
14523
+ function tryCallOne(fn, a) {
14524
+ try {
14525
+ return fn(a);
14526
+ } catch (ex) {
14527
+ LAST_ERROR = ex;
14528
+ return IS_ERROR;
14529
+ }
14530
+ }
14531
+ function tryCallTwo(fn, a, b) {
14532
+ try {
14533
+ fn(a, b);
14534
+ } catch (ex) {
14535
+ LAST_ERROR = ex;
14536
+ return IS_ERROR;
14537
+ }
14538
+ }
14539
+
14540
+ module.exports = Promise;
14541
+
14542
+ function Promise(fn) {
14543
+ if (typeof this !== 'object') {
14544
+ throw new TypeError('Promises must be constructed via new');
14545
+ }
14546
+ if (typeof fn !== 'function') {
14547
+ throw new TypeError('Promise constructor\'s argument is not a function');
14548
+ }
14549
+ this._40 = 0;
14550
+ this._65 = 0;
14551
+ this._55 = null;
14552
+ this._72 = null;
14553
+ if (fn === noop) return;
14554
+ doResolve(fn, this);
14555
+ }
14556
+ Promise._37 = null;
14557
+ Promise._87 = null;
14558
+ Promise._61 = noop;
14559
+
14560
+ Promise.prototype.then = function(onFulfilled, onRejected) {
14561
+ if (this.constructor !== Promise) {
12078
14562
  return safeThen(this, onFulfilled, onRejected);
12079
14563
  }
12080
14564
  var res = new Promise(noop);
@@ -12216,7 +14700,7 @@ function doResolve(fn, promise) {
12216
14700
  }
12217
14701
  }
12218
14702
 
12219
- },{"asap/raw":97}],99:[function(require,module,exports){
14703
+ },{"asap/raw":99}],105:[function(require,module,exports){
12220
14704
  'use strict';
12221
14705
 
12222
14706
  //This file contains the ES6 extensions to the core Promises/A+ API
@@ -12325,7 +14809,7 @@ Promise.prototype['catch'] = function (onRejected) {
12325
14809
  return this.then(null, onRejected);
12326
14810
  };
12327
14811
 
12328
- },{"./core.js":98}],100:[function(require,module,exports){
14812
+ },{"./core.js":104}],106:[function(require,module,exports){
12329
14813
  // should work in any browser without browserify
12330
14814
 
12331
14815
  if (typeof Promise.prototype.done !== 'function') {
@@ -12338,7 +14822,7 @@ if (typeof Promise.prototype.done !== 'function') {
12338
14822
  })
12339
14823
  }
12340
14824
  }
12341
- },{}],101:[function(require,module,exports){
14825
+ },{}],107:[function(require,module,exports){
12342
14826
  // not "use strict" so we can declare global "Promise"
12343
14827
 
12344
14828
  var asap = require('asap');
@@ -12350,5 +14834,5 @@ if (typeof Promise === 'undefined') {
12350
14834
 
12351
14835
  require('./polyfill-done.js');
12352
14836
 
12353
- },{"./lib/core.js":98,"./lib/es6-extensions.js":99,"./polyfill-done.js":100,"asap":96}]},{},[2])(2)
14837
+ },{"./lib/core.js":104,"./lib/es6-extensions.js":105,"./polyfill-done.js":106,"asap":98}]},{},[2])(2)
12354
14838
  });