@shijiu/jsview 1.9.782 → 1.9.825

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 (34) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -1
  4. package/dom/jsv-browser-debug-dom.js +6 -3
  5. package/dom/jsv-code-debug.mjs +5 -5
  6. package/dom/jsv-dom.js +5 -2
  7. package/dom/jsv-engine-js-browser.js +3 -0
  8. package/dom/jsv-forge-define.js +5 -2
  9. package/dom/target_core_revision.mjs +4 -4
  10. package/loader/jsview-browser-forgeapp.js +13 -0
  11. package/loader/jsview-loader.js +198 -0
  12. package/loader/jsview-main.js +14 -33
  13. package/loader/jsview-react-main.js +36 -0
  14. package/loader/{header_script_loader.js → jsview-react-script-loader.js} +0 -0
  15. package/package.json +1 -1
  16. package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +925 -921
  17. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1 -0
  18. package/patches/node_modules/postcss-js/objectifier.js +1 -0
  19. package/patches/node_modules/react-dev-utils/WebpackDevServerUtils.js +450 -0
  20. package/patches/node_modules/react-dev-utils/package.json +88 -0
  21. package/patches/node_modules/react-scripts/config/paths.js +17 -6
  22. package/patches/node_modules/react-scripts/config/webpack.config.js +36 -15
  23. package/patches/node_modules/vite/dist/node/chunks/dep-ed9cb113.js +12 -8
  24. package/patches/node_modules/vue-router/dist/vue-router.mjs +1 -0
  25. package/patches/node_modules/webpack-dev-server/client/utils/reloadApp.js +76 -0
  26. package/patches/node_modules/webpack-dev-server/client/utils/sendMessage.js +21 -0
  27. package/patches/node_modules/webpack-dev-server/package.json +141 -0
  28. package/tools/jsview-common.js +54 -21
  29. package/tools/jsview-post-build.js +16 -6
  30. package/tools/jsview-post-install.js +60 -9
  31. package/loader/jsview.default.config.js +0 -37
  32. package/loader/loader.js +0 -183
  33. package/loader/loader_webkit.js +0 -40
  34. package/tools/index.js +0 -209
@@ -3227,6 +3227,7 @@ function doCompileTemplate({ filename, id, scoped, slotted, inMap, source, ssr =
3227
3227
  mode: 'module',
3228
3228
  prefixIdentifiers: true,
3229
3229
  // JsView Added >>>
3230
+ // 解决xxx问题。
3230
3231
  // hoistStatic: true,
3231
3232
  hoistStatic: false,
3232
3233
  // JsView Added <<<
@@ -3519,6 +3520,7 @@ function compileScript(sfc, options) {
3519
3520
  content += `\nexport default ${DEFAULT_VAR}`;
3520
3521
  }
3521
3522
  // JsView Added >>>
3523
+ // 在标准写法下,将Css转换为Js, 并注入到Js文件。
3522
3524
  content += jsvCssToJs.compileCssToJs(sfc, options);
3523
3525
  // JsView Added <<<
3524
3526
  return {
@@ -4603,6 +4605,7 @@ function compileScript(sfc, options) {
4603
4605
  }
4604
4606
  s.trim();
4605
4607
  // JsView Added >>>
4608
+ // 在setup写法下,将Css转换为Js, 并注入到Js文件。
4606
4609
  s.append(jsvCssToJs.compileCssToJs(sfc, options));
4607
4610
  // JsView Added <<<
4608
4611
  return {
@@ -5285,6 +5288,7 @@ function parse(source, { sourceMap = true, filename = DEFAULT_FILENAME, sourceRo
5285
5288
  const slottedRE = /(?:::v-|:)slotted\(/;
5286
5289
  descriptor.slotted = descriptor.styles.some(s => s.scoped && slottedRE.test(s.content));
5287
5290
  // JsView Added >>>
5291
+ // 如果不存在<script>标签,则手动添加一个用于处理Css转为Js。
5288
5292
  jsvCssToJs.ensureSfcDescriptor(descriptor);
5289
5293
  // JsView Added <<<
5290
5294
  const result = {
@@ -10776,927 +10780,927 @@ function parseString(str) {
10776
10780
 
10777
10781
  var parseString_1 = parseString;
10778
10782
 
10779
- /*
10780
- * big.js v5.2.2
10781
- * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
10782
- * Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com>
10783
- * https://github.com/MikeMcl/big.js/LICENCE
10784
- */
10785
-
10786
-
10787
- /************************************** EDITABLE DEFAULTS *****************************************/
10788
-
10789
-
10790
- // The default values below must be integers within the stated ranges.
10791
-
10792
- /*
10793
- * The maximum number of decimal places (DP) of the results of operations involving division:
10794
- * div and sqrt, and pow with negative exponents.
10795
- */
10796
- var DP = 20, // 0 to MAX_DP
10797
-
10798
- /*
10799
- * The rounding mode (RM) used when rounding to the above decimal places.
10800
- *
10801
- * 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN)
10802
- * 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP)
10803
- * 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN)
10804
- * 3 Away from zero. (ROUND_UP)
10805
- */
10806
- RM = 1, // 0, 1, 2 or 3
10807
-
10808
- // The maximum value of DP and Big.DP.
10809
- MAX_DP = 1E6, // 0 to 1000000
10810
-
10811
- // The maximum magnitude of the exponent argument to the pow method.
10812
- MAX_POWER = 1E6, // 1 to 1000000
10813
-
10814
- /*
10815
- * The negative exponent (NE) at and beneath which toString returns exponential notation.
10816
- * (JavaScript numbers: -7)
10817
- * -1000000 is the minimum recommended exponent value of a Big.
10818
- */
10819
- NE = -7, // 0 to -1000000
10820
-
10821
- /*
10822
- * The positive exponent (PE) at and above which toString returns exponential notation.
10823
- * (JavaScript numbers: 21)
10824
- * 1000000 is the maximum recommended exponent value of a Big.
10825
- * (This limit is not enforced or checked.)
10826
- */
10827
- PE = 21, // 0 to 1000000
10828
-
10829
-
10830
- /**************************************************************************************************/
10831
-
10832
-
10833
- // Error messages.
10834
- NAME = '[big.js] ',
10835
- INVALID = NAME + 'Invalid ',
10836
- INVALID_DP = INVALID + 'decimal places',
10837
- INVALID_RM = INVALID + 'rounding mode',
10838
- DIV_BY_ZERO = NAME + 'Division by zero',
10839
-
10840
- // The shared prototype object.
10841
- P = {},
10842
- UNDEFINED = void 0,
10843
- NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
10844
-
10845
-
10846
- /*
10847
- * Create and return a Big constructor.
10848
- *
10849
- */
10850
- function _Big_() {
10851
-
10852
- /*
10853
- * The Big constructor and exported function.
10854
- * Create and return a new instance of a Big number object.
10855
- *
10856
- * n {number|string|Big} A numeric value.
10857
- */
10858
- function Big(n) {
10859
- var x = this;
10860
-
10861
- // Enable constructor usage without new.
10862
- if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n);
10863
-
10864
- // Duplicate.
10865
- if (n instanceof Big) {
10866
- x.s = n.s;
10867
- x.e = n.e;
10868
- x.c = n.c.slice();
10869
- } else {
10870
- parse$1(x, n);
10871
- }
10872
-
10873
- /*
10874
- * Retain a reference to this Big constructor, and shadow Big.prototype.constructor which
10875
- * points to Object.
10876
- */
10877
- x.constructor = Big;
10878
- }
10879
-
10880
- Big.prototype = P;
10881
- Big.DP = DP;
10882
- Big.RM = RM;
10883
- Big.NE = NE;
10884
- Big.PE = PE;
10885
- Big.version = '5.2.2';
10886
-
10887
- return Big;
10888
- }
10889
-
10890
-
10891
- /*
10892
- * Parse the number or string value passed to a Big constructor.
10893
- *
10894
- * x {Big} A Big number instance.
10895
- * n {number|string} A numeric value.
10896
- */
10897
- function parse$1(x, n) {
10898
- var e, i, nl;
10899
-
10900
- // Minus zero?
10901
- if (n === 0 && 1 / n < 0) n = '-0';
10902
- else if (!NUMERIC.test(n += '')) throw Error(INVALID + 'number');
10903
-
10904
- // Determine sign.
10905
- x.s = n.charAt(0) == '-' ? (n = n.slice(1), -1) : 1;
10906
-
10907
- // Decimal point?
10908
- if ((e = n.indexOf('.')) > -1) n = n.replace('.', '');
10909
-
10910
- // Exponential form?
10911
- if ((i = n.search(/e/i)) > 0) {
10912
-
10913
- // Determine exponent.
10914
- if (e < 0) e = i;
10915
- e += +n.slice(i + 1);
10916
- n = n.substring(0, i);
10917
- } else if (e < 0) {
10918
-
10919
- // Integer.
10920
- e = n.length;
10921
- }
10922
-
10923
- nl = n.length;
10924
-
10925
- // Determine leading zeros.
10926
- for (i = 0; i < nl && n.charAt(i) == '0';) ++i;
10927
-
10928
- if (i == nl) {
10929
-
10930
- // Zero.
10931
- x.c = [x.e = 0];
10932
- } else {
10933
-
10934
- // Determine trailing zeros.
10935
- for (; nl > 0 && n.charAt(--nl) == '0';);
10936
- x.e = e - i - 1;
10937
- x.c = [];
10938
-
10939
- // Convert string to array of digits without leading/trailing zeros.
10940
- for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++);
10941
- }
10942
-
10943
- return x;
10944
- }
10945
-
10946
-
10947
- /*
10948
- * Round Big x to a maximum of dp decimal places using rounding mode rm.
10949
- * Called by stringify, P.div, P.round and P.sqrt.
10950
- *
10951
- * x {Big} The Big to round.
10952
- * dp {number} Integer, 0 to MAX_DP inclusive.
10953
- * rm {number} 0, 1, 2 or 3 (DOWN, HALF_UP, HALF_EVEN, UP)
10954
- * [more] {boolean} Whether the result of division was truncated.
10955
- */
10956
- function round(x, dp, rm, more) {
10957
- var xc = x.c,
10958
- i = x.e + dp + 1;
10959
-
10960
- if (i < xc.length) {
10961
- if (rm === 1) {
10962
-
10963
- // xc[i] is the digit after the digit that may be rounded up.
10964
- more = xc[i] >= 5;
10965
- } else if (rm === 2) {
10966
- more = xc[i] > 5 || xc[i] == 5 &&
10967
- (more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1);
10968
- } else if (rm === 3) {
10969
- more = more || !!xc[0];
10970
- } else {
10971
- more = false;
10972
- if (rm !== 0) throw Error(INVALID_RM);
10973
- }
10974
-
10975
- if (i < 1) {
10976
- xc.length = 1;
10977
-
10978
- if (more) {
10979
-
10980
- // 1, 0.1, 0.01, 0.001, 0.0001 etc.
10981
- x.e = -dp;
10982
- xc[0] = 1;
10983
- } else {
10984
-
10985
- // Zero.
10986
- xc[0] = x.e = 0;
10987
- }
10988
- } else {
10989
-
10990
- // Remove any digits after the required decimal places.
10991
- xc.length = i--;
10992
-
10993
- // Round up?
10994
- if (more) {
10995
-
10996
- // Rounding up may mean the previous digit has to be rounded up.
10997
- for (; ++xc[i] > 9;) {
10998
- xc[i] = 0;
10999
- if (!i--) {
11000
- ++x.e;
11001
- xc.unshift(1);
11002
- }
11003
- }
11004
- }
11005
-
11006
- // Remove trailing zeros.
11007
- for (i = xc.length; !xc[--i];) xc.pop();
11008
- }
11009
- } else if (rm < 0 || rm > 3 || rm !== ~~rm) {
11010
- throw Error(INVALID_RM);
11011
- }
11012
-
11013
- return x;
11014
- }
11015
-
11016
-
11017
- /*
11018
- * Return a string representing the value of Big x in normal or exponential notation.
11019
- * Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf.
11020
- *
11021
- * x {Big}
11022
- * id? {number} Caller id.
11023
- * 1 toExponential
11024
- * 2 toFixed
11025
- * 3 toPrecision
11026
- * 4 valueOf
11027
- * n? {number|undefined} Caller's argument.
11028
- * k? {number|undefined}
11029
- */
11030
- function stringify(x, id, n, k) {
11031
- var e, s,
11032
- Big = x.constructor,
11033
- z = !x.c[0];
11034
-
11035
- if (n !== UNDEFINED) {
11036
- if (n !== ~~n || n < (id == 3) || n > MAX_DP) {
11037
- throw Error(id == 3 ? INVALID + 'precision' : INVALID_DP);
11038
- }
11039
-
11040
- x = new Big(x);
11041
-
11042
- // The index of the digit that may be rounded up.
11043
- n = k - x.e;
11044
-
11045
- // Round?
11046
- if (x.c.length > ++k) round(x, n, Big.RM);
11047
-
11048
- // toFixed: recalculate k as x.e may have changed if value rounded up.
11049
- if (id == 2) k = x.e + n + 1;
11050
-
11051
- // Append zeros?
11052
- for (; x.c.length < k;) x.c.push(0);
11053
- }
11054
-
11055
- e = x.e;
11056
- s = x.c.join('');
11057
- n = s.length;
11058
-
11059
- // Exponential notation?
11060
- if (id != 2 && (id == 1 || id == 3 && k <= e || e <= Big.NE || e >= Big.PE)) {
11061
- s = s.charAt(0) + (n > 1 ? '.' + s.slice(1) : '') + (e < 0 ? 'e' : 'e+') + e;
11062
-
11063
- // Normal notation.
11064
- } else if (e < 0) {
11065
- for (; ++e;) s = '0' + s;
11066
- s = '0.' + s;
11067
- } else if (e > 0) {
11068
- if (++e > n) for (e -= n; e--;) s += '0';
11069
- else if (e < n) s = s.slice(0, e) + '.' + s.slice(e);
11070
- } else if (n > 1) {
11071
- s = s.charAt(0) + '.' + s.slice(1);
11072
- }
11073
-
11074
- return x.s < 0 && (!z || id == 4) ? '-' + s : s;
11075
- }
11076
-
11077
-
11078
- // Prototype/instance methods
11079
-
11080
-
11081
- /*
11082
- * Return a new Big whose value is the absolute value of this Big.
11083
- */
11084
- P.abs = function () {
11085
- var x = new this.constructor(this);
11086
- x.s = 1;
11087
- return x;
11088
- };
11089
-
11090
-
11091
- /*
11092
- * Return 1 if the value of this Big is greater than the value of Big y,
11093
- * -1 if the value of this Big is less than the value of Big y, or
11094
- * 0 if they have the same value.
11095
- */
11096
- P.cmp = function (y) {
11097
- var isneg,
11098
- x = this,
11099
- xc = x.c,
11100
- yc = (y = new x.constructor(y)).c,
11101
- i = x.s,
11102
- j = y.s,
11103
- k = x.e,
11104
- l = y.e;
11105
-
11106
- // Either zero?
11107
- if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i;
11108
-
11109
- // Signs differ?
11110
- if (i != j) return i;
11111
-
11112
- isneg = i < 0;
11113
-
11114
- // Compare exponents.
11115
- if (k != l) return k > l ^ isneg ? 1 : -1;
11116
-
11117
- j = (k = xc.length) < (l = yc.length) ? k : l;
11118
-
11119
- // Compare digit by digit.
11120
- for (i = -1; ++i < j;) {
11121
- if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1;
11122
- }
11123
-
11124
- // Compare lengths.
11125
- return k == l ? 0 : k > l ^ isneg ? 1 : -1;
11126
- };
11127
-
11128
-
11129
- /*
11130
- * Return a new Big whose value is the value of this Big divided by the value of Big y, rounded,
11131
- * if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
11132
- */
11133
- P.div = function (y) {
11134
- var x = this,
11135
- Big = x.constructor,
11136
- a = x.c, // dividend
11137
- b = (y = new Big(y)).c, // divisor
11138
- k = x.s == y.s ? 1 : -1,
11139
- dp = Big.DP;
11140
-
11141
- if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
11142
-
11143
- // Divisor is zero?
11144
- if (!b[0]) throw Error(DIV_BY_ZERO);
11145
-
11146
- // Dividend is 0? Return +-0.
11147
- if (!a[0]) return new Big(k * 0);
11148
-
11149
- var bl, bt, n, cmp, ri,
11150
- bz = b.slice(),
11151
- ai = bl = b.length,
11152
- al = a.length,
11153
- r = a.slice(0, bl), // remainder
11154
- rl = r.length,
11155
- q = y, // quotient
11156
- qc = q.c = [],
11157
- qi = 0,
11158
- d = dp + (q.e = x.e - y.e) + 1; // number of digits of the result
11159
-
11160
- q.s = k;
11161
- k = d < 0 ? 0 : d;
11162
-
11163
- // Create version of divisor with leading zero.
11164
- bz.unshift(0);
11165
-
11166
- // Add zeros to make remainder as long as divisor.
11167
- for (; rl++ < bl;) r.push(0);
11168
-
11169
- do {
11170
-
11171
- // n is how many times the divisor goes into current remainder.
11172
- for (n = 0; n < 10; n++) {
11173
-
11174
- // Compare divisor and remainder.
11175
- if (bl != (rl = r.length)) {
11176
- cmp = bl > rl ? 1 : -1;
11177
- } else {
11178
- for (ri = -1, cmp = 0; ++ri < bl;) {
11179
- if (b[ri] != r[ri]) {
11180
- cmp = b[ri] > r[ri] ? 1 : -1;
11181
- break;
11182
- }
11183
- }
11184
- }
11185
-
11186
- // If divisor < remainder, subtract divisor from remainder.
11187
- if (cmp < 0) {
11188
-
11189
- // Remainder can't be more than 1 digit longer than divisor.
11190
- // Equalise lengths using divisor with extra leading zero?
11191
- for (bt = rl == bl ? b : bz; rl;) {
11192
- if (r[--rl] < bt[rl]) {
11193
- ri = rl;
11194
- for (; ri && !r[--ri];) r[ri] = 9;
11195
- --r[ri];
11196
- r[rl] += 10;
11197
- }
11198
- r[rl] -= bt[rl];
11199
- }
11200
-
11201
- for (; !r[0];) r.shift();
11202
- } else {
11203
- break;
11204
- }
11205
- }
11206
-
11207
- // Add the digit n to the result array.
11208
- qc[qi++] = cmp ? n : ++n;
11209
-
11210
- // Update the remainder.
11211
- if (r[0] && cmp) r[rl] = a[ai] || 0;
11212
- else r = [a[ai]];
11213
-
11214
- } while ((ai++ < al || r[0] !== UNDEFINED) && k--);
11215
-
11216
- // Leading zero? Do not remove if result is simply zero (qi == 1).
11217
- if (!qc[0] && qi != 1) {
11218
-
11219
- // There can't be more than one zero.
11220
- qc.shift();
11221
- q.e--;
11222
- }
11223
-
11224
- // Round?
11225
- if (qi > d) round(q, dp, Big.RM, r[0] !== UNDEFINED);
11226
-
11227
- return q;
11228
- };
11229
-
11230
-
11231
- /*
11232
- * Return true if the value of this Big is equal to the value of Big y, otherwise return false.
11233
- */
11234
- P.eq = function (y) {
11235
- return !this.cmp(y);
11236
- };
11237
-
11238
-
11239
- /*
11240
- * Return true if the value of this Big is greater than the value of Big y, otherwise return
11241
- * false.
11242
- */
11243
- P.gt = function (y) {
11244
- return this.cmp(y) > 0;
11245
- };
11246
-
11247
-
11248
- /*
11249
- * Return true if the value of this Big is greater than or equal to the value of Big y, otherwise
11250
- * return false.
11251
- */
11252
- P.gte = function (y) {
11253
- return this.cmp(y) > -1;
11254
- };
11255
-
11256
-
11257
- /*
11258
- * Return true if the value of this Big is less than the value of Big y, otherwise return false.
11259
- */
11260
- P.lt = function (y) {
11261
- return this.cmp(y) < 0;
11262
- };
11263
-
11264
-
11265
- /*
11266
- * Return true if the value of this Big is less than or equal to the value of Big y, otherwise
11267
- * return false.
11268
- */
11269
- P.lte = function (y) {
11270
- return this.cmp(y) < 1;
11271
- };
11272
-
11273
-
11274
- /*
11275
- * Return a new Big whose value is the value of this Big minus the value of Big y.
11276
- */
11277
- P.minus = P.sub = function (y) {
11278
- var i, j, t, xlty,
11279
- x = this,
11280
- Big = x.constructor,
11281
- a = x.s,
11282
- b = (y = new Big(y)).s;
11283
-
11284
- // Signs differ?
11285
- if (a != b) {
11286
- y.s = -b;
11287
- return x.plus(y);
11288
- }
11289
-
11290
- var xc = x.c.slice(),
11291
- xe = x.e,
11292
- yc = y.c,
11293
- ye = y.e;
11294
-
11295
- // Either zero?
11296
- if (!xc[0] || !yc[0]) {
11297
-
11298
- // y is non-zero? x is non-zero? Or both are zero.
11299
- return yc[0] ? (y.s = -b, y) : new Big(xc[0] ? x : 0);
11300
- }
11301
-
11302
- // Determine which is the bigger number. Prepend zeros to equalise exponents.
11303
- if (a = xe - ye) {
11304
-
11305
- if (xlty = a < 0) {
11306
- a = -a;
11307
- t = xc;
11308
- } else {
11309
- ye = xe;
11310
- t = yc;
11311
- }
11312
-
11313
- t.reverse();
11314
- for (b = a; b--;) t.push(0);
11315
- t.reverse();
11316
- } else {
11317
-
11318
- // Exponents equal. Check digit by digit.
11319
- j = ((xlty = xc.length < yc.length) ? xc : yc).length;
11320
-
11321
- for (a = b = 0; b < j; b++) {
11322
- if (xc[b] != yc[b]) {
11323
- xlty = xc[b] < yc[b];
11324
- break;
11325
- }
11326
- }
11327
- }
11328
-
11329
- // x < y? Point xc to the array of the bigger number.
11330
- if (xlty) {
11331
- t = xc;
11332
- xc = yc;
11333
- yc = t;
11334
- y.s = -y.s;
11335
- }
11336
-
11337
- /*
11338
- * Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only
11339
- * needs to start at yc.length.
11340
- */
11341
- if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0;
11342
-
11343
- // Subtract yc from xc.
11344
- for (b = i; j > a;) {
11345
- if (xc[--j] < yc[j]) {
11346
- for (i = j; i && !xc[--i];) xc[i] = 9;
11347
- --xc[i];
11348
- xc[j] += 10;
11349
- }
11350
-
11351
- xc[j] -= yc[j];
11352
- }
11353
-
11354
- // Remove trailing zeros.
11355
- for (; xc[--b] === 0;) xc.pop();
11356
-
11357
- // Remove leading zeros and adjust exponent accordingly.
11358
- for (; xc[0] === 0;) {
11359
- xc.shift();
11360
- --ye;
11361
- }
11362
-
11363
- if (!xc[0]) {
11364
-
11365
- // n - n = +0
11366
- y.s = 1;
11367
-
11368
- // Result must be zero.
11369
- xc = [ye = 0];
11370
- }
11371
-
11372
- y.c = xc;
11373
- y.e = ye;
11374
-
11375
- return y;
11376
- };
11377
-
11378
-
11379
- /*
11380
- * Return a new Big whose value is the value of this Big modulo the value of Big y.
11381
- */
11382
- P.mod = function (y) {
11383
- var ygtx,
11384
- x = this,
11385
- Big = x.constructor,
11386
- a = x.s,
11387
- b = (y = new Big(y)).s;
11388
-
11389
- if (!y.c[0]) throw Error(DIV_BY_ZERO);
11390
-
11391
- x.s = y.s = 1;
11392
- ygtx = y.cmp(x) == 1;
11393
- x.s = a;
11394
- y.s = b;
11395
-
11396
- if (ygtx) return new Big(x);
11397
-
11398
- a = Big.DP;
11399
- b = Big.RM;
11400
- Big.DP = Big.RM = 0;
11401
- x = x.div(y);
11402
- Big.DP = a;
11403
- Big.RM = b;
11404
-
11405
- return this.minus(x.times(y));
11406
- };
11407
-
11408
-
11409
- /*
11410
- * Return a new Big whose value is the value of this Big plus the value of Big y.
11411
- */
11412
- P.plus = P.add = function (y) {
11413
- var t,
11414
- x = this,
11415
- Big = x.constructor,
11416
- a = x.s,
11417
- b = (y = new Big(y)).s;
11418
-
11419
- // Signs differ?
11420
- if (a != b) {
11421
- y.s = -b;
11422
- return x.minus(y);
11423
- }
11424
-
11425
- var xe = x.e,
11426
- xc = x.c,
11427
- ye = y.e,
11428
- yc = y.c;
11429
-
11430
- // Either zero? y is non-zero? x is non-zero? Or both are zero.
11431
- if (!xc[0] || !yc[0]) return yc[0] ? y : new Big(xc[0] ? x : a * 0);
11432
-
11433
- xc = xc.slice();
11434
-
11435
- // Prepend zeros to equalise exponents.
11436
- // Note: reverse faster than unshifts.
11437
- if (a = xe - ye) {
11438
- if (a > 0) {
11439
- ye = xe;
11440
- t = yc;
11441
- } else {
11442
- a = -a;
11443
- t = xc;
11444
- }
11445
-
11446
- t.reverse();
11447
- for (; a--;) t.push(0);
11448
- t.reverse();
11449
- }
11450
-
11451
- // Point xc to the longer array.
11452
- if (xc.length - yc.length < 0) {
11453
- t = yc;
11454
- yc = xc;
11455
- xc = t;
11456
- }
11457
-
11458
- a = yc.length;
11459
-
11460
- // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.
11461
- for (b = 0; a; xc[a] %= 10) b = (xc[--a] = xc[a] + yc[a] + b) / 10 | 0;
11462
-
11463
- // No need to check for zero, as +x + +y != 0 && -x + -y != 0
11464
-
11465
- if (b) {
11466
- xc.unshift(b);
11467
- ++ye;
11468
- }
11469
-
11470
- // Remove trailing zeros.
11471
- for (a = xc.length; xc[--a] === 0;) xc.pop();
11472
-
11473
- y.c = xc;
11474
- y.e = ye;
11475
-
11476
- return y;
11477
- };
11478
-
11479
-
11480
- /*
11481
- * Return a Big whose value is the value of this Big raised to the power n.
11482
- * If n is negative, round to a maximum of Big.DP decimal places using rounding
11483
- * mode Big.RM.
11484
- *
11485
- * n {number} Integer, -MAX_POWER to MAX_POWER inclusive.
11486
- */
11487
- P.pow = function (n) {
11488
- var x = this,
11489
- one = new x.constructor(1),
11490
- y = one,
11491
- isneg = n < 0;
11492
-
11493
- if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) throw Error(INVALID + 'exponent');
11494
- if (isneg) n = -n;
11495
-
11496
- for (;;) {
11497
- if (n & 1) y = y.times(x);
11498
- n >>= 1;
11499
- if (!n) break;
11500
- x = x.times(x);
11501
- }
11502
-
11503
- return isneg ? one.div(y) : y;
11504
- };
11505
-
11506
-
11507
- /*
11508
- * Return a new Big whose value is the value of this Big rounded using rounding mode rm
11509
- * to a maximum of dp decimal places, or, if dp is negative, to an integer which is a
11510
- * multiple of 10**-dp.
11511
- * If dp is not specified, round to 0 decimal places.
11512
- * If rm is not specified, use Big.RM.
11513
- *
11514
- * dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
11515
- * rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP)
11516
- */
11517
- P.round = function (dp, rm) {
11518
- var Big = this.constructor;
11519
- if (dp === UNDEFINED) dp = 0;
11520
- else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
11521
- return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm);
11522
- };
11523
-
11524
-
11525
- /*
11526
- * Return a new Big whose value is the square root of the value of this Big, rounded, if
11527
- * necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
11528
- */
11529
- P.sqrt = function () {
11530
- var r, c, t,
11531
- x = this,
11532
- Big = x.constructor,
11533
- s = x.s,
11534
- e = x.e,
11535
- half = new Big(0.5);
11536
-
11537
- // Zero?
11538
- if (!x.c[0]) return new Big(x);
11539
-
11540
- // Negative?
11541
- if (s < 0) throw Error(NAME + 'No square root');
11542
-
11543
- // Estimate.
11544
- s = Math.sqrt(x + '');
11545
-
11546
- // Math.sqrt underflow/overflow?
11547
- // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
11548
- if (s === 0 || s === 1 / 0) {
11549
- c = x.c.join('');
11550
- if (!(c.length + e & 1)) c += '0';
11551
- s = Math.sqrt(c);
11552
- e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
11553
- r = new Big((s == 1 / 0 ? '1e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e);
11554
- } else {
11555
- r = new Big(s);
11556
- }
11557
-
11558
- e = r.e + (Big.DP += 4);
11559
-
11560
- // Newton-Raphson iteration.
11561
- do {
11562
- t = r;
11563
- r = half.times(t.plus(x.div(t)));
11564
- } while (t.c.slice(0, e).join('') !== r.c.slice(0, e).join(''));
11565
-
11566
- return round(r, Big.DP -= 4, Big.RM);
11567
- };
11568
-
11569
-
11570
- /*
11571
- * Return a new Big whose value is the value of this Big times the value of Big y.
11572
- */
11573
- P.times = P.mul = function (y) {
11574
- var c,
11575
- x = this,
11576
- Big = x.constructor,
11577
- xc = x.c,
11578
- yc = (y = new Big(y)).c,
11579
- a = xc.length,
11580
- b = yc.length,
11581
- i = x.e,
11582
- j = y.e;
11583
-
11584
- // Determine sign of result.
11585
- y.s = x.s == y.s ? 1 : -1;
11586
-
11587
- // Return signed 0 if either 0.
11588
- if (!xc[0] || !yc[0]) return new Big(y.s * 0);
11589
-
11590
- // Initialise exponent of result as x.e + y.e.
11591
- y.e = i + j;
11592
-
11593
- // If array xc has fewer digits than yc, swap xc and yc, and lengths.
11594
- if (a < b) {
11595
- c = xc;
11596
- xc = yc;
11597
- yc = c;
11598
- j = a;
11599
- a = b;
11600
- b = j;
11601
- }
11602
-
11603
- // Initialise coefficient array of result with zeros.
11604
- for (c = new Array(j = a + b); j--;) c[j] = 0;
11605
-
11606
- // Multiply.
11607
-
11608
- // i is initially xc.length.
11609
- for (i = b; i--;) {
11610
- b = 0;
11611
-
11612
- // a is yc.length.
11613
- for (j = a + i; j > i;) {
11614
-
11615
- // Current sum of products at this digit position, plus carry.
11616
- b = c[j] + yc[i] * xc[j - i - 1] + b;
11617
- c[j--] = b % 10;
11618
-
11619
- // carry
11620
- b = b / 10 | 0;
11621
- }
11622
-
11623
- c[j] = (c[j] + b) % 10;
11624
- }
11625
-
11626
- // Increment result exponent if there is a final carry, otherwise remove leading zero.
11627
- if (b) ++y.e;
11628
- else c.shift();
11629
-
11630
- // Remove trailing zeros.
11631
- for (i = c.length; !c[--i];) c.pop();
11632
- y.c = c;
11633
-
11634
- return y;
11635
- };
11636
-
11637
-
11638
- /*
11639
- * Return a string representing the value of this Big in exponential notation to dp fixed decimal
11640
- * places and rounded using Big.RM.
11641
- *
11642
- * dp? {number} Integer, 0 to MAX_DP inclusive.
11643
- */
11644
- P.toExponential = function (dp) {
11645
- return stringify(this, 1, dp, dp);
11646
- };
11647
-
11648
-
11649
- /*
11650
- * Return a string representing the value of this Big in normal notation to dp fixed decimal
11651
- * places and rounded using Big.RM.
11652
- *
11653
- * dp? {number} Integer, 0 to MAX_DP inclusive.
11654
- *
11655
- * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
11656
- * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
11657
- */
11658
- P.toFixed = function (dp) {
11659
- return stringify(this, 2, dp, this.e + dp);
11660
- };
11661
-
11662
-
11663
- /*
11664
- * Return a string representing the value of this Big rounded to sd significant digits using
11665
- * Big.RM. Use exponential notation if sd is less than the number of digits necessary to represent
11666
- * the integer part of the value in normal notation.
11667
- *
11668
- * sd {number} Integer, 1 to MAX_DP inclusive.
11669
- */
11670
- P.toPrecision = function (sd) {
11671
- return stringify(this, 3, sd, sd - 1);
11672
- };
11673
-
11674
-
11675
- /*
11676
- * Return a string representing the value of this Big.
11677
- * Return exponential notation if this Big has a positive exponent equal to or greater than
11678
- * Big.PE, or a negative exponent equal to or less than Big.NE.
11679
- * Omit the sign for negative zero.
11680
- */
11681
- P.toString = function () {
11682
- return stringify(this);
11683
- };
11684
-
11685
-
11686
- /*
11687
- * Return a string representing the value of this Big.
11688
- * Return exponential notation if this Big has a positive exponent equal to or greater than
11689
- * Big.PE, or a negative exponent equal to or less than Big.NE.
11690
- * Include the sign for negative zero.
11691
- */
11692
- P.valueOf = P.toJSON = function () {
11693
- return stringify(this, 4);
11694
- };
11695
-
11696
-
11697
- // Export
11698
-
11699
-
10783
+ /*
10784
+ * big.js v5.2.2
10785
+ * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
10786
+ * Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com>
10787
+ * https://github.com/MikeMcl/big.js/LICENCE
10788
+ */
10789
+
10790
+
10791
+ /************************************** EDITABLE DEFAULTS *****************************************/
10792
+
10793
+
10794
+ // The default values below must be integers within the stated ranges.
10795
+
10796
+ /*
10797
+ * The maximum number of decimal places (DP) of the results of operations involving division:
10798
+ * div and sqrt, and pow with negative exponents.
10799
+ */
10800
+ var DP = 20, // 0 to MAX_DP
10801
+
10802
+ /*
10803
+ * The rounding mode (RM) used when rounding to the above decimal places.
10804
+ *
10805
+ * 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN)
10806
+ * 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP)
10807
+ * 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN)
10808
+ * 3 Away from zero. (ROUND_UP)
10809
+ */
10810
+ RM = 1, // 0, 1, 2 or 3
10811
+
10812
+ // The maximum value of DP and Big.DP.
10813
+ MAX_DP = 1E6, // 0 to 1000000
10814
+
10815
+ // The maximum magnitude of the exponent argument to the pow method.
10816
+ MAX_POWER = 1E6, // 1 to 1000000
10817
+
10818
+ /*
10819
+ * The negative exponent (NE) at and beneath which toString returns exponential notation.
10820
+ * (JavaScript numbers: -7)
10821
+ * -1000000 is the minimum recommended exponent value of a Big.
10822
+ */
10823
+ NE = -7, // 0 to -1000000
10824
+
10825
+ /*
10826
+ * The positive exponent (PE) at and above which toString returns exponential notation.
10827
+ * (JavaScript numbers: 21)
10828
+ * 1000000 is the maximum recommended exponent value of a Big.
10829
+ * (This limit is not enforced or checked.)
10830
+ */
10831
+ PE = 21, // 0 to 1000000
10832
+
10833
+
10834
+ /**************************************************************************************************/
10835
+
10836
+
10837
+ // Error messages.
10838
+ NAME = '[big.js] ',
10839
+ INVALID = NAME + 'Invalid ',
10840
+ INVALID_DP = INVALID + 'decimal places',
10841
+ INVALID_RM = INVALID + 'rounding mode',
10842
+ DIV_BY_ZERO = NAME + 'Division by zero',
10843
+
10844
+ // The shared prototype object.
10845
+ P = {},
10846
+ UNDEFINED = void 0,
10847
+ NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
10848
+
10849
+
10850
+ /*
10851
+ * Create and return a Big constructor.
10852
+ *
10853
+ */
10854
+ function _Big_() {
10855
+
10856
+ /*
10857
+ * The Big constructor and exported function.
10858
+ * Create and return a new instance of a Big number object.
10859
+ *
10860
+ * n {number|string|Big} A numeric value.
10861
+ */
10862
+ function Big(n) {
10863
+ var x = this;
10864
+
10865
+ // Enable constructor usage without new.
10866
+ if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n);
10867
+
10868
+ // Duplicate.
10869
+ if (n instanceof Big) {
10870
+ x.s = n.s;
10871
+ x.e = n.e;
10872
+ x.c = n.c.slice();
10873
+ } else {
10874
+ parse$1(x, n);
10875
+ }
10876
+
10877
+ /*
10878
+ * Retain a reference to this Big constructor, and shadow Big.prototype.constructor which
10879
+ * points to Object.
10880
+ */
10881
+ x.constructor = Big;
10882
+ }
10883
+
10884
+ Big.prototype = P;
10885
+ Big.DP = DP;
10886
+ Big.RM = RM;
10887
+ Big.NE = NE;
10888
+ Big.PE = PE;
10889
+ Big.version = '5.2.2';
10890
+
10891
+ return Big;
10892
+ }
10893
+
10894
+
10895
+ /*
10896
+ * Parse the number or string value passed to a Big constructor.
10897
+ *
10898
+ * x {Big} A Big number instance.
10899
+ * n {number|string} A numeric value.
10900
+ */
10901
+ function parse$1(x, n) {
10902
+ var e, i, nl;
10903
+
10904
+ // Minus zero?
10905
+ if (n === 0 && 1 / n < 0) n = '-0';
10906
+ else if (!NUMERIC.test(n += '')) throw Error(INVALID + 'number');
10907
+
10908
+ // Determine sign.
10909
+ x.s = n.charAt(0) == '-' ? (n = n.slice(1), -1) : 1;
10910
+
10911
+ // Decimal point?
10912
+ if ((e = n.indexOf('.')) > -1) n = n.replace('.', '');
10913
+
10914
+ // Exponential form?
10915
+ if ((i = n.search(/e/i)) > 0) {
10916
+
10917
+ // Determine exponent.
10918
+ if (e < 0) e = i;
10919
+ e += +n.slice(i + 1);
10920
+ n = n.substring(0, i);
10921
+ } else if (e < 0) {
10922
+
10923
+ // Integer.
10924
+ e = n.length;
10925
+ }
10926
+
10927
+ nl = n.length;
10928
+
10929
+ // Determine leading zeros.
10930
+ for (i = 0; i < nl && n.charAt(i) == '0';) ++i;
10931
+
10932
+ if (i == nl) {
10933
+
10934
+ // Zero.
10935
+ x.c = [x.e = 0];
10936
+ } else {
10937
+
10938
+ // Determine trailing zeros.
10939
+ for (; nl > 0 && n.charAt(--nl) == '0';);
10940
+ x.e = e - i - 1;
10941
+ x.c = [];
10942
+
10943
+ // Convert string to array of digits without leading/trailing zeros.
10944
+ for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++);
10945
+ }
10946
+
10947
+ return x;
10948
+ }
10949
+
10950
+
10951
+ /*
10952
+ * Round Big x to a maximum of dp decimal places using rounding mode rm.
10953
+ * Called by stringify, P.div, P.round and P.sqrt.
10954
+ *
10955
+ * x {Big} The Big to round.
10956
+ * dp {number} Integer, 0 to MAX_DP inclusive.
10957
+ * rm {number} 0, 1, 2 or 3 (DOWN, HALF_UP, HALF_EVEN, UP)
10958
+ * [more] {boolean} Whether the result of division was truncated.
10959
+ */
10960
+ function round(x, dp, rm, more) {
10961
+ var xc = x.c,
10962
+ i = x.e + dp + 1;
10963
+
10964
+ if (i < xc.length) {
10965
+ if (rm === 1) {
10966
+
10967
+ // xc[i] is the digit after the digit that may be rounded up.
10968
+ more = xc[i] >= 5;
10969
+ } else if (rm === 2) {
10970
+ more = xc[i] > 5 || xc[i] == 5 &&
10971
+ (more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1);
10972
+ } else if (rm === 3) {
10973
+ more = more || !!xc[0];
10974
+ } else {
10975
+ more = false;
10976
+ if (rm !== 0) throw Error(INVALID_RM);
10977
+ }
10978
+
10979
+ if (i < 1) {
10980
+ xc.length = 1;
10981
+
10982
+ if (more) {
10983
+
10984
+ // 1, 0.1, 0.01, 0.001, 0.0001 etc.
10985
+ x.e = -dp;
10986
+ xc[0] = 1;
10987
+ } else {
10988
+
10989
+ // Zero.
10990
+ xc[0] = x.e = 0;
10991
+ }
10992
+ } else {
10993
+
10994
+ // Remove any digits after the required decimal places.
10995
+ xc.length = i--;
10996
+
10997
+ // Round up?
10998
+ if (more) {
10999
+
11000
+ // Rounding up may mean the previous digit has to be rounded up.
11001
+ for (; ++xc[i] > 9;) {
11002
+ xc[i] = 0;
11003
+ if (!i--) {
11004
+ ++x.e;
11005
+ xc.unshift(1);
11006
+ }
11007
+ }
11008
+ }
11009
+
11010
+ // Remove trailing zeros.
11011
+ for (i = xc.length; !xc[--i];) xc.pop();
11012
+ }
11013
+ } else if (rm < 0 || rm > 3 || rm !== ~~rm) {
11014
+ throw Error(INVALID_RM);
11015
+ }
11016
+
11017
+ return x;
11018
+ }
11019
+
11020
+
11021
+ /*
11022
+ * Return a string representing the value of Big x in normal or exponential notation.
11023
+ * Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf.
11024
+ *
11025
+ * x {Big}
11026
+ * id? {number} Caller id.
11027
+ * 1 toExponential
11028
+ * 2 toFixed
11029
+ * 3 toPrecision
11030
+ * 4 valueOf
11031
+ * n? {number|undefined} Caller's argument.
11032
+ * k? {number|undefined}
11033
+ */
11034
+ function stringify(x, id, n, k) {
11035
+ var e, s,
11036
+ Big = x.constructor,
11037
+ z = !x.c[0];
11038
+
11039
+ if (n !== UNDEFINED) {
11040
+ if (n !== ~~n || n < (id == 3) || n > MAX_DP) {
11041
+ throw Error(id == 3 ? INVALID + 'precision' : INVALID_DP);
11042
+ }
11043
+
11044
+ x = new Big(x);
11045
+
11046
+ // The index of the digit that may be rounded up.
11047
+ n = k - x.e;
11048
+
11049
+ // Round?
11050
+ if (x.c.length > ++k) round(x, n, Big.RM);
11051
+
11052
+ // toFixed: recalculate k as x.e may have changed if value rounded up.
11053
+ if (id == 2) k = x.e + n + 1;
11054
+
11055
+ // Append zeros?
11056
+ for (; x.c.length < k;) x.c.push(0);
11057
+ }
11058
+
11059
+ e = x.e;
11060
+ s = x.c.join('');
11061
+ n = s.length;
11062
+
11063
+ // Exponential notation?
11064
+ if (id != 2 && (id == 1 || id == 3 && k <= e || e <= Big.NE || e >= Big.PE)) {
11065
+ s = s.charAt(0) + (n > 1 ? '.' + s.slice(1) : '') + (e < 0 ? 'e' : 'e+') + e;
11066
+
11067
+ // Normal notation.
11068
+ } else if (e < 0) {
11069
+ for (; ++e;) s = '0' + s;
11070
+ s = '0.' + s;
11071
+ } else if (e > 0) {
11072
+ if (++e > n) for (e -= n; e--;) s += '0';
11073
+ else if (e < n) s = s.slice(0, e) + '.' + s.slice(e);
11074
+ } else if (n > 1) {
11075
+ s = s.charAt(0) + '.' + s.slice(1);
11076
+ }
11077
+
11078
+ return x.s < 0 && (!z || id == 4) ? '-' + s : s;
11079
+ }
11080
+
11081
+
11082
+ // Prototype/instance methods
11083
+
11084
+
11085
+ /*
11086
+ * Return a new Big whose value is the absolute value of this Big.
11087
+ */
11088
+ P.abs = function () {
11089
+ var x = new this.constructor(this);
11090
+ x.s = 1;
11091
+ return x;
11092
+ };
11093
+
11094
+
11095
+ /*
11096
+ * Return 1 if the value of this Big is greater than the value of Big y,
11097
+ * -1 if the value of this Big is less than the value of Big y, or
11098
+ * 0 if they have the same value.
11099
+ */
11100
+ P.cmp = function (y) {
11101
+ var isneg,
11102
+ x = this,
11103
+ xc = x.c,
11104
+ yc = (y = new x.constructor(y)).c,
11105
+ i = x.s,
11106
+ j = y.s,
11107
+ k = x.e,
11108
+ l = y.e;
11109
+
11110
+ // Either zero?
11111
+ if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i;
11112
+
11113
+ // Signs differ?
11114
+ if (i != j) return i;
11115
+
11116
+ isneg = i < 0;
11117
+
11118
+ // Compare exponents.
11119
+ if (k != l) return k > l ^ isneg ? 1 : -1;
11120
+
11121
+ j = (k = xc.length) < (l = yc.length) ? k : l;
11122
+
11123
+ // Compare digit by digit.
11124
+ for (i = -1; ++i < j;) {
11125
+ if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1;
11126
+ }
11127
+
11128
+ // Compare lengths.
11129
+ return k == l ? 0 : k > l ^ isneg ? 1 : -1;
11130
+ };
11131
+
11132
+
11133
+ /*
11134
+ * Return a new Big whose value is the value of this Big divided by the value of Big y, rounded,
11135
+ * if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
11136
+ */
11137
+ P.div = function (y) {
11138
+ var x = this,
11139
+ Big = x.constructor,
11140
+ a = x.c, // dividend
11141
+ b = (y = new Big(y)).c, // divisor
11142
+ k = x.s == y.s ? 1 : -1,
11143
+ dp = Big.DP;
11144
+
11145
+ if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
11146
+
11147
+ // Divisor is zero?
11148
+ if (!b[0]) throw Error(DIV_BY_ZERO);
11149
+
11150
+ // Dividend is 0? Return +-0.
11151
+ if (!a[0]) return new Big(k * 0);
11152
+
11153
+ var bl, bt, n, cmp, ri,
11154
+ bz = b.slice(),
11155
+ ai = bl = b.length,
11156
+ al = a.length,
11157
+ r = a.slice(0, bl), // remainder
11158
+ rl = r.length,
11159
+ q = y, // quotient
11160
+ qc = q.c = [],
11161
+ qi = 0,
11162
+ d = dp + (q.e = x.e - y.e) + 1; // number of digits of the result
11163
+
11164
+ q.s = k;
11165
+ k = d < 0 ? 0 : d;
11166
+
11167
+ // Create version of divisor with leading zero.
11168
+ bz.unshift(0);
11169
+
11170
+ // Add zeros to make remainder as long as divisor.
11171
+ for (; rl++ < bl;) r.push(0);
11172
+
11173
+ do {
11174
+
11175
+ // n is how many times the divisor goes into current remainder.
11176
+ for (n = 0; n < 10; n++) {
11177
+
11178
+ // Compare divisor and remainder.
11179
+ if (bl != (rl = r.length)) {
11180
+ cmp = bl > rl ? 1 : -1;
11181
+ } else {
11182
+ for (ri = -1, cmp = 0; ++ri < bl;) {
11183
+ if (b[ri] != r[ri]) {
11184
+ cmp = b[ri] > r[ri] ? 1 : -1;
11185
+ break;
11186
+ }
11187
+ }
11188
+ }
11189
+
11190
+ // If divisor < remainder, subtract divisor from remainder.
11191
+ if (cmp < 0) {
11192
+
11193
+ // Remainder can't be more than 1 digit longer than divisor.
11194
+ // Equalise lengths using divisor with extra leading zero?
11195
+ for (bt = rl == bl ? b : bz; rl;) {
11196
+ if (r[--rl] < bt[rl]) {
11197
+ ri = rl;
11198
+ for (; ri && !r[--ri];) r[ri] = 9;
11199
+ --r[ri];
11200
+ r[rl] += 10;
11201
+ }
11202
+ r[rl] -= bt[rl];
11203
+ }
11204
+
11205
+ for (; !r[0];) r.shift();
11206
+ } else {
11207
+ break;
11208
+ }
11209
+ }
11210
+
11211
+ // Add the digit n to the result array.
11212
+ qc[qi++] = cmp ? n : ++n;
11213
+
11214
+ // Update the remainder.
11215
+ if (r[0] && cmp) r[rl] = a[ai] || 0;
11216
+ else r = [a[ai]];
11217
+
11218
+ } while ((ai++ < al || r[0] !== UNDEFINED) && k--);
11219
+
11220
+ // Leading zero? Do not remove if result is simply zero (qi == 1).
11221
+ if (!qc[0] && qi != 1) {
11222
+
11223
+ // There can't be more than one zero.
11224
+ qc.shift();
11225
+ q.e--;
11226
+ }
11227
+
11228
+ // Round?
11229
+ if (qi > d) round(q, dp, Big.RM, r[0] !== UNDEFINED);
11230
+
11231
+ return q;
11232
+ };
11233
+
11234
+
11235
+ /*
11236
+ * Return true if the value of this Big is equal to the value of Big y, otherwise return false.
11237
+ */
11238
+ P.eq = function (y) {
11239
+ return !this.cmp(y);
11240
+ };
11241
+
11242
+
11243
+ /*
11244
+ * Return true if the value of this Big is greater than the value of Big y, otherwise return
11245
+ * false.
11246
+ */
11247
+ P.gt = function (y) {
11248
+ return this.cmp(y) > 0;
11249
+ };
11250
+
11251
+
11252
+ /*
11253
+ * Return true if the value of this Big is greater than or equal to the value of Big y, otherwise
11254
+ * return false.
11255
+ */
11256
+ P.gte = function (y) {
11257
+ return this.cmp(y) > -1;
11258
+ };
11259
+
11260
+
11261
+ /*
11262
+ * Return true if the value of this Big is less than the value of Big y, otherwise return false.
11263
+ */
11264
+ P.lt = function (y) {
11265
+ return this.cmp(y) < 0;
11266
+ };
11267
+
11268
+
11269
+ /*
11270
+ * Return true if the value of this Big is less than or equal to the value of Big y, otherwise
11271
+ * return false.
11272
+ */
11273
+ P.lte = function (y) {
11274
+ return this.cmp(y) < 1;
11275
+ };
11276
+
11277
+
11278
+ /*
11279
+ * Return a new Big whose value is the value of this Big minus the value of Big y.
11280
+ */
11281
+ P.minus = P.sub = function (y) {
11282
+ var i, j, t, xlty,
11283
+ x = this,
11284
+ Big = x.constructor,
11285
+ a = x.s,
11286
+ b = (y = new Big(y)).s;
11287
+
11288
+ // Signs differ?
11289
+ if (a != b) {
11290
+ y.s = -b;
11291
+ return x.plus(y);
11292
+ }
11293
+
11294
+ var xc = x.c.slice(),
11295
+ xe = x.e,
11296
+ yc = y.c,
11297
+ ye = y.e;
11298
+
11299
+ // Either zero?
11300
+ if (!xc[0] || !yc[0]) {
11301
+
11302
+ // y is non-zero? x is non-zero? Or both are zero.
11303
+ return yc[0] ? (y.s = -b, y) : new Big(xc[0] ? x : 0);
11304
+ }
11305
+
11306
+ // Determine which is the bigger number. Prepend zeros to equalise exponents.
11307
+ if (a = xe - ye) {
11308
+
11309
+ if (xlty = a < 0) {
11310
+ a = -a;
11311
+ t = xc;
11312
+ } else {
11313
+ ye = xe;
11314
+ t = yc;
11315
+ }
11316
+
11317
+ t.reverse();
11318
+ for (b = a; b--;) t.push(0);
11319
+ t.reverse();
11320
+ } else {
11321
+
11322
+ // Exponents equal. Check digit by digit.
11323
+ j = ((xlty = xc.length < yc.length) ? xc : yc).length;
11324
+
11325
+ for (a = b = 0; b < j; b++) {
11326
+ if (xc[b] != yc[b]) {
11327
+ xlty = xc[b] < yc[b];
11328
+ break;
11329
+ }
11330
+ }
11331
+ }
11332
+
11333
+ // x < y? Point xc to the array of the bigger number.
11334
+ if (xlty) {
11335
+ t = xc;
11336
+ xc = yc;
11337
+ yc = t;
11338
+ y.s = -y.s;
11339
+ }
11340
+
11341
+ /*
11342
+ * Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only
11343
+ * needs to start at yc.length.
11344
+ */
11345
+ if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0;
11346
+
11347
+ // Subtract yc from xc.
11348
+ for (b = i; j > a;) {
11349
+ if (xc[--j] < yc[j]) {
11350
+ for (i = j; i && !xc[--i];) xc[i] = 9;
11351
+ --xc[i];
11352
+ xc[j] += 10;
11353
+ }
11354
+
11355
+ xc[j] -= yc[j];
11356
+ }
11357
+
11358
+ // Remove trailing zeros.
11359
+ for (; xc[--b] === 0;) xc.pop();
11360
+
11361
+ // Remove leading zeros and adjust exponent accordingly.
11362
+ for (; xc[0] === 0;) {
11363
+ xc.shift();
11364
+ --ye;
11365
+ }
11366
+
11367
+ if (!xc[0]) {
11368
+
11369
+ // n - n = +0
11370
+ y.s = 1;
11371
+
11372
+ // Result must be zero.
11373
+ xc = [ye = 0];
11374
+ }
11375
+
11376
+ y.c = xc;
11377
+ y.e = ye;
11378
+
11379
+ return y;
11380
+ };
11381
+
11382
+
11383
+ /*
11384
+ * Return a new Big whose value is the value of this Big modulo the value of Big y.
11385
+ */
11386
+ P.mod = function (y) {
11387
+ var ygtx,
11388
+ x = this,
11389
+ Big = x.constructor,
11390
+ a = x.s,
11391
+ b = (y = new Big(y)).s;
11392
+
11393
+ if (!y.c[0]) throw Error(DIV_BY_ZERO);
11394
+
11395
+ x.s = y.s = 1;
11396
+ ygtx = y.cmp(x) == 1;
11397
+ x.s = a;
11398
+ y.s = b;
11399
+
11400
+ if (ygtx) return new Big(x);
11401
+
11402
+ a = Big.DP;
11403
+ b = Big.RM;
11404
+ Big.DP = Big.RM = 0;
11405
+ x = x.div(y);
11406
+ Big.DP = a;
11407
+ Big.RM = b;
11408
+
11409
+ return this.minus(x.times(y));
11410
+ };
11411
+
11412
+
11413
+ /*
11414
+ * Return a new Big whose value is the value of this Big plus the value of Big y.
11415
+ */
11416
+ P.plus = P.add = function (y) {
11417
+ var t,
11418
+ x = this,
11419
+ Big = x.constructor,
11420
+ a = x.s,
11421
+ b = (y = new Big(y)).s;
11422
+
11423
+ // Signs differ?
11424
+ if (a != b) {
11425
+ y.s = -b;
11426
+ return x.minus(y);
11427
+ }
11428
+
11429
+ var xe = x.e,
11430
+ xc = x.c,
11431
+ ye = y.e,
11432
+ yc = y.c;
11433
+
11434
+ // Either zero? y is non-zero? x is non-zero? Or both are zero.
11435
+ if (!xc[0] || !yc[0]) return yc[0] ? y : new Big(xc[0] ? x : a * 0);
11436
+
11437
+ xc = xc.slice();
11438
+
11439
+ // Prepend zeros to equalise exponents.
11440
+ // Note: reverse faster than unshifts.
11441
+ if (a = xe - ye) {
11442
+ if (a > 0) {
11443
+ ye = xe;
11444
+ t = yc;
11445
+ } else {
11446
+ a = -a;
11447
+ t = xc;
11448
+ }
11449
+
11450
+ t.reverse();
11451
+ for (; a--;) t.push(0);
11452
+ t.reverse();
11453
+ }
11454
+
11455
+ // Point xc to the longer array.
11456
+ if (xc.length - yc.length < 0) {
11457
+ t = yc;
11458
+ yc = xc;
11459
+ xc = t;
11460
+ }
11461
+
11462
+ a = yc.length;
11463
+
11464
+ // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.
11465
+ for (b = 0; a; xc[a] %= 10) b = (xc[--a] = xc[a] + yc[a] + b) / 10 | 0;
11466
+
11467
+ // No need to check for zero, as +x + +y != 0 && -x + -y != 0
11468
+
11469
+ if (b) {
11470
+ xc.unshift(b);
11471
+ ++ye;
11472
+ }
11473
+
11474
+ // Remove trailing zeros.
11475
+ for (a = xc.length; xc[--a] === 0;) xc.pop();
11476
+
11477
+ y.c = xc;
11478
+ y.e = ye;
11479
+
11480
+ return y;
11481
+ };
11482
+
11483
+
11484
+ /*
11485
+ * Return a Big whose value is the value of this Big raised to the power n.
11486
+ * If n is negative, round to a maximum of Big.DP decimal places using rounding
11487
+ * mode Big.RM.
11488
+ *
11489
+ * n {number} Integer, -MAX_POWER to MAX_POWER inclusive.
11490
+ */
11491
+ P.pow = function (n) {
11492
+ var x = this,
11493
+ one = new x.constructor(1),
11494
+ y = one,
11495
+ isneg = n < 0;
11496
+
11497
+ if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) throw Error(INVALID + 'exponent');
11498
+ if (isneg) n = -n;
11499
+
11500
+ for (;;) {
11501
+ if (n & 1) y = y.times(x);
11502
+ n >>= 1;
11503
+ if (!n) break;
11504
+ x = x.times(x);
11505
+ }
11506
+
11507
+ return isneg ? one.div(y) : y;
11508
+ };
11509
+
11510
+
11511
+ /*
11512
+ * Return a new Big whose value is the value of this Big rounded using rounding mode rm
11513
+ * to a maximum of dp decimal places, or, if dp is negative, to an integer which is a
11514
+ * multiple of 10**-dp.
11515
+ * If dp is not specified, round to 0 decimal places.
11516
+ * If rm is not specified, use Big.RM.
11517
+ *
11518
+ * dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
11519
+ * rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP)
11520
+ */
11521
+ P.round = function (dp, rm) {
11522
+ var Big = this.constructor;
11523
+ if (dp === UNDEFINED) dp = 0;
11524
+ else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
11525
+ return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm);
11526
+ };
11527
+
11528
+
11529
+ /*
11530
+ * Return a new Big whose value is the square root of the value of this Big, rounded, if
11531
+ * necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
11532
+ */
11533
+ P.sqrt = function () {
11534
+ var r, c, t,
11535
+ x = this,
11536
+ Big = x.constructor,
11537
+ s = x.s,
11538
+ e = x.e,
11539
+ half = new Big(0.5);
11540
+
11541
+ // Zero?
11542
+ if (!x.c[0]) return new Big(x);
11543
+
11544
+ // Negative?
11545
+ if (s < 0) throw Error(NAME + 'No square root');
11546
+
11547
+ // Estimate.
11548
+ s = Math.sqrt(x + '');
11549
+
11550
+ // Math.sqrt underflow/overflow?
11551
+ // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
11552
+ if (s === 0 || s === 1 / 0) {
11553
+ c = x.c.join('');
11554
+ if (!(c.length + e & 1)) c += '0';
11555
+ s = Math.sqrt(c);
11556
+ e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
11557
+ r = new Big((s == 1 / 0 ? '1e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e);
11558
+ } else {
11559
+ r = new Big(s);
11560
+ }
11561
+
11562
+ e = r.e + (Big.DP += 4);
11563
+
11564
+ // Newton-Raphson iteration.
11565
+ do {
11566
+ t = r;
11567
+ r = half.times(t.plus(x.div(t)));
11568
+ } while (t.c.slice(0, e).join('') !== r.c.slice(0, e).join(''));
11569
+
11570
+ return round(r, Big.DP -= 4, Big.RM);
11571
+ };
11572
+
11573
+
11574
+ /*
11575
+ * Return a new Big whose value is the value of this Big times the value of Big y.
11576
+ */
11577
+ P.times = P.mul = function (y) {
11578
+ var c,
11579
+ x = this,
11580
+ Big = x.constructor,
11581
+ xc = x.c,
11582
+ yc = (y = new Big(y)).c,
11583
+ a = xc.length,
11584
+ b = yc.length,
11585
+ i = x.e,
11586
+ j = y.e;
11587
+
11588
+ // Determine sign of result.
11589
+ y.s = x.s == y.s ? 1 : -1;
11590
+
11591
+ // Return signed 0 if either 0.
11592
+ if (!xc[0] || !yc[0]) return new Big(y.s * 0);
11593
+
11594
+ // Initialise exponent of result as x.e + y.e.
11595
+ y.e = i + j;
11596
+
11597
+ // If array xc has fewer digits than yc, swap xc and yc, and lengths.
11598
+ if (a < b) {
11599
+ c = xc;
11600
+ xc = yc;
11601
+ yc = c;
11602
+ j = a;
11603
+ a = b;
11604
+ b = j;
11605
+ }
11606
+
11607
+ // Initialise coefficient array of result with zeros.
11608
+ for (c = new Array(j = a + b); j--;) c[j] = 0;
11609
+
11610
+ // Multiply.
11611
+
11612
+ // i is initially xc.length.
11613
+ for (i = b; i--;) {
11614
+ b = 0;
11615
+
11616
+ // a is yc.length.
11617
+ for (j = a + i; j > i;) {
11618
+
11619
+ // Current sum of products at this digit position, plus carry.
11620
+ b = c[j] + yc[i] * xc[j - i - 1] + b;
11621
+ c[j--] = b % 10;
11622
+
11623
+ // carry
11624
+ b = b / 10 | 0;
11625
+ }
11626
+
11627
+ c[j] = (c[j] + b) % 10;
11628
+ }
11629
+
11630
+ // Increment result exponent if there is a final carry, otherwise remove leading zero.
11631
+ if (b) ++y.e;
11632
+ else c.shift();
11633
+
11634
+ // Remove trailing zeros.
11635
+ for (i = c.length; !c[--i];) c.pop();
11636
+ y.c = c;
11637
+
11638
+ return y;
11639
+ };
11640
+
11641
+
11642
+ /*
11643
+ * Return a string representing the value of this Big in exponential notation to dp fixed decimal
11644
+ * places and rounded using Big.RM.
11645
+ *
11646
+ * dp? {number} Integer, 0 to MAX_DP inclusive.
11647
+ */
11648
+ P.toExponential = function (dp) {
11649
+ return stringify(this, 1, dp, dp);
11650
+ };
11651
+
11652
+
11653
+ /*
11654
+ * Return a string representing the value of this Big in normal notation to dp fixed decimal
11655
+ * places and rounded using Big.RM.
11656
+ *
11657
+ * dp? {number} Integer, 0 to MAX_DP inclusive.
11658
+ *
11659
+ * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
11660
+ * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
11661
+ */
11662
+ P.toFixed = function (dp) {
11663
+ return stringify(this, 2, dp, this.e + dp);
11664
+ };
11665
+
11666
+
11667
+ /*
11668
+ * Return a string representing the value of this Big rounded to sd significant digits using
11669
+ * Big.RM. Use exponential notation if sd is less than the number of digits necessary to represent
11670
+ * the integer part of the value in normal notation.
11671
+ *
11672
+ * sd {number} Integer, 1 to MAX_DP inclusive.
11673
+ */
11674
+ P.toPrecision = function (sd) {
11675
+ return stringify(this, 3, sd, sd - 1);
11676
+ };
11677
+
11678
+
11679
+ /*
11680
+ * Return a string representing the value of this Big.
11681
+ * Return exponential notation if this Big has a positive exponent equal to or greater than
11682
+ * Big.PE, or a negative exponent equal to or less than Big.NE.
11683
+ * Omit the sign for negative zero.
11684
+ */
11685
+ P.toString = function () {
11686
+ return stringify(this);
11687
+ };
11688
+
11689
+
11690
+ /*
11691
+ * Return a string representing the value of this Big.
11692
+ * Return exponential notation if this Big has a positive exponent equal to or greater than
11693
+ * Big.PE, or a negative exponent equal to or less than Big.NE.
11694
+ * Include the sign for negative zero.
11695
+ */
11696
+ P.valueOf = P.toJSON = function () {
11697
+ return stringify(this, 4);
11698
+ };
11699
+
11700
+
11701
+ // Export
11702
+
11703
+
11700
11704
  var Big = _Big_();
11701
11705
 
11702
11706
  var big = /*#__PURE__*/Object.freeze({