compostjs 0.0.11 → 0.0.12

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 (141) hide show
  1. package/dist/fable_modules/fable-library-js.4.28.0/Array.d.ts +123 -0
  2. package/dist/fable_modules/fable-library-js.4.28.0/Array.js +1242 -0
  3. package/dist/fable_modules/fable-library-js.4.28.0/Async.d.ts +26 -0
  4. package/dist/fable_modules/fable-library-js.4.28.0/Async.js +145 -0
  5. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.d.ts +59 -0
  6. package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.js +183 -0
  7. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.d.ts +115 -0
  8. package/dist/fable_modules/fable-library-js.4.28.0/BigInt.js +283 -0
  9. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.d.ts +27 -0
  10. package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.js +138 -0
  11. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.d.ts +3 -0
  12. package/dist/fable_modules/fable-library-js.4.28.0/Boolean.js +21 -0
  13. package/dist/fable_modules/fable-library-js.4.28.0/CHANGELOG.md +100 -0
  14. package/dist/fable_modules/fable-library-js.4.28.0/Char.d.ts +65 -0
  15. package/dist/fable_modules/fable-library-js.4.28.0/Char.js +169 -0
  16. package/dist/fable_modules/fable-library-js.4.28.0/Choice.d.ts +121 -0
  17. package/dist/fable_modules/fable-library-js.4.28.0/Choice.js +184 -0
  18. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.d.ts +7 -0
  19. package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.js +182 -0
  20. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.d.ts +9 -0
  21. package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.js +21 -0
  22. package/dist/fable_modules/fable-library-js.4.28.0/Date.d.ts +70 -0
  23. package/dist/fable_modules/fable-library-js.4.28.0/Date.js +748 -0
  24. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.d.ts +63 -0
  25. package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.js +268 -0
  26. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.d.ts +18 -0
  27. package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.js +124 -0
  28. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.d.ts +45 -0
  29. package/dist/fable_modules/fable-library-js.4.28.0/Decimal.js +212 -0
  30. package/dist/fable_modules/fable-library-js.4.28.0/Double.d.ts +11 -0
  31. package/dist/fable_modules/fable-library-js.4.28.0/Double.js +46 -0
  32. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.d.ts +12 -0
  33. package/dist/fable_modules/fable-library-js.4.28.0/Encoding.js +173 -0
  34. package/dist/fable_modules/fable-library-js.4.28.0/Event.d.ts +31 -0
  35. package/dist/fable_modules/fable-library-js.4.28.0/Event.js +93 -0
  36. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.d.ts +7 -0
  37. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.js +27 -0
  38. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.d.ts +12 -0
  39. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.js +27 -0
  40. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.d.ts +17 -0
  41. package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.js +69 -0
  42. package/dist/fable_modules/fable-library-js.4.28.0/Global.d.ts +24 -0
  43. package/dist/fable_modules/fable-library-js.4.28.0/Global.js +8 -0
  44. package/dist/fable_modules/fable-library-js.4.28.0/Guid.d.ts +10 -0
  45. package/dist/fable_modules/fable-library-js.4.28.0/Guid.js +142 -0
  46. package/dist/fable_modules/fable-library-js.4.28.0/Int32.d.ts +28 -0
  47. package/dist/fable_modules/fable-library-js.4.28.0/Int32.js +135 -0
  48. package/dist/fable_modules/fable-library-js.4.28.0/List.d.ts +143 -0
  49. package/dist/fable_modules/fable-library-js.4.28.0/List.js +1273 -0
  50. package/dist/fable_modules/fable-library-js.4.28.0/Long.d.ts +3 -0
  51. package/dist/fable_modules/fable-library-js.4.28.0/Long.js +46 -0
  52. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.d.ts +25 -0
  53. package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.js +93 -0
  54. package/dist/fable_modules/fable-library-js.4.28.0/Map.d.ts +178 -0
  55. package/dist/fable_modules/fable-library-js.4.28.0/Map.js +1396 -0
  56. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.d.ts +12 -0
  57. package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.js +127 -0
  58. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.d.ts +52 -0
  59. package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.js +327 -0
  60. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.d.ts +39 -0
  61. package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.js +233 -0
  62. package/dist/fable_modules/fable-library-js.4.28.0/Native.d.ts +2 -0
  63. package/dist/fable_modules/fable-library-js.4.28.0/Native.js +8 -0
  64. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.d.ts +19 -0
  65. package/dist/fable_modules/fable-library-js.4.28.0/Numeric.js +71 -0
  66. package/dist/fable_modules/fable-library-js.4.28.0/Observable.d.ts +32 -0
  67. package/dist/fable_modules/fable-library-js.4.28.0/Observable.js +113 -0
  68. package/dist/fable_modules/fable-library-js.4.28.0/Option.d.ts +28 -0
  69. package/dist/fable_modules/fable-library-js.4.28.0/Option.js +96 -0
  70. package/dist/fable_modules/fable-library-js.4.28.0/README.md +3 -0
  71. package/dist/fable_modules/fable-library-js.4.28.0/Random.d.ts +37 -0
  72. package/dist/fable_modules/fable-library-js.4.28.0/Random.js +170 -0
  73. package/dist/fable_modules/fable-library-js.4.28.0/Range.d.ts +12 -0
  74. package/dist/fable_modules/fable-library-js.4.28.0/Range.js +45 -0
  75. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.d.ts +119 -0
  76. package/dist/fable_modules/fable-library-js.4.28.0/Reflection.js +461 -0
  77. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.d.ts +10 -0
  78. package/dist/fable_modules/fable-library-js.4.28.0/RegExp.js +131 -0
  79. package/dist/fable_modules/fable-library-js.4.28.0/Result.d.ts +37 -0
  80. package/dist/fable_modules/fable-library-js.4.28.0/Result.js +165 -0
  81. package/dist/fable_modules/fable-library-js.4.28.0/Seq.d.ts +165 -0
  82. package/dist/fable_modules/fable-library-js.4.28.0/Seq.js +1378 -0
  83. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.d.ts +18 -0
  84. package/dist/fable_modules/fable-library-js.4.28.0/Seq2.js +111 -0
  85. package/dist/fable_modules/fable-library-js.4.28.0/Set.d.ts +190 -0
  86. package/dist/fable_modules/fable-library-js.4.28.0/Set.js +1789 -0
  87. package/dist/fable_modules/fable-library-js.4.28.0/String.d.ts +58 -0
  88. package/dist/fable_modules/fable-library-js.4.28.0/String.js +554 -0
  89. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.d.ts +79 -0
  90. package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.js +317 -0
  91. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.d.ts +38 -0
  92. package/dist/fable_modules/fable-library-js.4.28.0/System.Text.js +162 -0
  93. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.d.ts +5 -0
  94. package/dist/fable_modules/fable-library-js.4.28.0/SystemException.js +5 -0
  95. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.d.ts +15 -0
  96. package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.js +122 -0
  97. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.d.ts +34 -0
  98. package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.js +177 -0
  99. package/dist/fable_modules/fable-library-js.4.28.0/Timer.d.ts +19 -0
  100. package/dist/fable_modules/fable-library-js.4.28.0/Timer.js +67 -0
  101. package/dist/fable_modules/fable-library-js.4.28.0/Types.d.ts +58 -0
  102. package/dist/fable_modules/fable-library-js.4.28.0/Types.js +208 -0
  103. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.d.ts +2 -0
  104. package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.js +4 -0
  105. package/dist/fable_modules/fable-library-js.4.28.0/Uri.d.ts +31 -0
  106. package/dist/fable_modules/fable-library-js.4.28.0/Uri.js +159 -0
  107. package/dist/fable_modules/fable-library-js.4.28.0/Util.d.ts +210 -0
  108. package/dist/fable_modules/fable-library-js.4.28.0/Util.js +769 -0
  109. package/dist/fable_modules/fable-library-js.4.28.0/big.d.ts +338 -0
  110. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.d.ts +5 -0
  111. package/dist/fable_modules/fable-library-js.4.28.0/lib/big.js +825 -0
  112. package/dist/fable_modules/fable-library-js.4.28.0/package.json +24 -0
  113. package/dist/fable_modules/project_cracked.json +1 -0
  114. package/package.json +4 -3
  115. package/.claude/settings.local.json +0 -11
  116. package/copy-latest.sh +0 -1
  117. package/dist/fable-library.2.10.1/Array.js +0 -1336
  118. package/dist/fable-library.2.10.1/Async.js +0 -121
  119. package/dist/fable-library.2.10.1/AsyncBuilder.js +0 -200
  120. package/dist/fable-library.2.10.1/Date.js +0 -501
  121. package/dist/fable-library.2.10.1/Decimal.js +0 -208
  122. package/dist/fable-library.2.10.1/Event.js +0 -193
  123. package/dist/fable-library.2.10.1/Int32.js +0 -157
  124. package/dist/fable-library.2.10.1/List.js +0 -1234
  125. package/dist/fable-library.2.10.1/Long.js +0 -155
  126. package/dist/fable-library.2.10.1/Map.js +0 -1292
  127. package/dist/fable-library.2.10.1/MutableMap.js +0 -360
  128. package/dist/fable-library.2.10.1/MutableSet.js +0 -279
  129. package/dist/fable-library.2.10.1/Observable.js +0 -131
  130. package/dist/fable-library.2.10.1/Option.js +0 -118
  131. package/dist/fable-library.2.10.1/Reflection.js +0 -345
  132. package/dist/fable-library.2.10.1/RegExp.js +0 -118
  133. package/dist/fable-library.2.10.1/Seq.js +0 -917
  134. package/dist/fable-library.2.10.1/Set.js +0 -1692
  135. package/dist/fable-library.2.10.1/String.js +0 -679
  136. package/dist/fable-library.2.10.1/Types.js +0 -308
  137. package/dist/fable-library.2.10.1/Util.js +0 -761
  138. package/dist/helpers.js +0 -31
  139. package/dist/lib/big.js +0 -905
  140. package/dist/lib/long.js +0 -1375
  141. package/index.html +0 -49
package/dist/lib/big.js DELETED
@@ -1,905 +0,0 @@
1
- // https://github.com/MikeMcl/big.js/blob/01b3ce3a6b0ba7b42442ea48ec4ffc88d1669ec4/big.mjs
2
-
3
- /* tslint:disable */
4
- import { combineHashCodes } from "../fable-library.2.10.1/Util"; // The shared prototype object.
5
-
6
- var P = {
7
- GetHashCode() {
8
- return combineHashCodes([this.s, this.e].concat(this.c));
9
- },
10
-
11
- Equals(x) {
12
- return !this.cmp(x);
13
- },
14
-
15
- CompareTo(x) {
16
- return this.cmp(x);
17
- }
18
-
19
- };
20
- /*
21
- * big.js v5.2.2
22
- * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
23
- * Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com>
24
- * https://github.com/MikeMcl/big.js/LICENCE
25
- */
26
-
27
- /************************************** EDITABLE DEFAULTS *****************************************/
28
- // The default values below must be integers within the stated ranges.
29
-
30
- /*
31
- * The maximum number of decimal places (DP) of the results of operations involving division:
32
- * div and sqrt, and pow with negative exponents.
33
- */
34
-
35
- var DP = 28,
36
- // 0 to MAX_DP
37
-
38
- /*
39
- * The rounding mode (RM) used when rounding to the above decimal places.
40
- *
41
- * 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN)
42
- * 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP)
43
- * 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN)
44
- * 3 Away from zero. (ROUND_UP)
45
- */
46
- RM = 1,
47
- // 0, 1, 2 or 3
48
- // The maximum value of DP and Big.DP.
49
- MAX_DP = 1E6,
50
- // 0 to 1000000
51
- // The maximum magnitude of the exponent argument to the pow method.
52
- MAX_POWER = 1E6,
53
- // 1 to 1000000
54
-
55
- /*
56
- * The negative exponent (NE) at and beneath which toString returns exponential notation.
57
- * (JavaScript numbers: -7)
58
- * -1000000 is the minimum recommended exponent value of a Big.
59
- */
60
- NE = -29,
61
- // 0 to -1000000
62
-
63
- /*
64
- * The positive exponent (PE) at and above which toString returns exponential notation.
65
- * (JavaScript numbers: 21)
66
- * 1000000 is the maximum recommended exponent value of a Big.
67
- * (This limit is not enforced or checked.)
68
- */
69
- PE = 29,
70
- // 0 to 1000000
71
-
72
- /**************************************************************************************************/
73
- // Error messages.
74
- NAME = "[big.js] ",
75
- INVALID = NAME + "Invalid ",
76
- INVALID_DP = INVALID + "decimal places",
77
- INVALID_RM = INVALID + "rounding mode",
78
- DIV_BY_ZERO = NAME + "Division by zero",
79
- UNDEFINED = void 0,
80
- NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
81
- /*
82
- * Create and return a Big constructor.
83
- *
84
- */
85
-
86
- function _Big_() {
87
- /*
88
- * The Big constructor and exported function.
89
- * Create and return a new instance of a Big number object.
90
- *
91
- * n {number|string|Big} A numeric value.
92
- */
93
- function Big(n) {
94
- var x = this; // Enable constructor usage without new.
95
-
96
- if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n); // Duplicate.
97
-
98
- if (n instanceof Big) {
99
- x.s = n.s;
100
- x.e = n.e;
101
- x.c = n.c.slice();
102
- normalize(x);
103
- } else {
104
- parse(x, n);
105
- }
106
- /*
107
- * Retain a reference to this Big constructor, and shadow Big.prototype.constructor which
108
- * points to Object.
109
- */
110
-
111
-
112
- x.constructor = Big;
113
- }
114
-
115
- Big.prototype = P;
116
- Big.DP = DP;
117
- Big.RM = RM;
118
- Big.NE = NE;
119
- Big.PE = PE;
120
- Big.version = "5.2.2";
121
- return Big;
122
- }
123
-
124
- function normalize(x) {
125
- x = round(x, DP, 0);
126
-
127
- if (x.c.length > 1 && !x.c[0]) {
128
- let i = x.c.findIndex(x => x);
129
- x.c = x.c.slice(i);
130
- x.e = x.e - i;
131
- }
132
- }
133
- /*
134
- * Parse the number or string value passed to a Big constructor.
135
- *
136
- * x {Big} A Big number instance.
137
- * n {number|string} A numeric value.
138
- */
139
-
140
-
141
- function parse(x, n) {
142
- var e, i, nl; // Minus zero?
143
-
144
- if (n === 0 && 1 / n < 0) n = "-0";else if (!NUMERIC.test(n += "")) throw Error(INVALID + "number"); // Determine sign.
145
-
146
- x.s = n.charAt(0) == "-" ? (n = n.slice(1), -1) : 1; // Decimal point?
147
-
148
- if ((e = n.indexOf(".")) > -1) n = n.replace(".", ""); // Exponential form?
149
-
150
- if ((i = n.search(/e/i)) > 0) {
151
- // Determine exponent.
152
- if (e < 0) e = i;
153
- e += +n.slice(i + 1);
154
- n = n.substring(0, i);
155
- } else if (e < 0) {
156
- // Integer.
157
- e = n.length;
158
- }
159
-
160
- nl = n.length; // Determine leading zeros before decimal point.
161
-
162
- for (i = 0; i < e && i < nl && n.charAt(i) == "0";) ++i; // older version (ignores decimal point).
163
- // // Determine leading zeros.
164
- // for (i = 0; i < nl && n.charAt(i) == '0';) ++i;
165
-
166
-
167
- if (i == nl) {
168
- // Zero.
169
- x.c = [x.e = 0];
170
- } else {
171
- x.e = e - i - 1;
172
- x.c = []; // Convert string to array of digits without leading zeros
173
-
174
- for (e = 0; i < nl;) x.c[e++] = +n.charAt(i++); // older version (doesn't keep trailing zeroes).
175
- // // Determine trailing zeros.
176
- // for (; nl > 0 && n.charAt(--nl) == '0';);
177
- // // Convert string to array of digits without leading/trailing zeros.
178
- // for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++);
179
-
180
- }
181
-
182
- x = round(x, Big.DP, Big.RM);
183
- return x;
184
- }
185
- /*
186
- * Round Big x to a maximum of dp decimal places using rounding mode rm.
187
- * Called by stringify, P.div, P.round and P.sqrt.
188
- *
189
- * x {Big} The Big to round.
190
- * dp {number} Integer, 0 to MAX_DP inclusive.
191
- * rm {number} 0, 1, 2 or 3 (DOWN, HALF_UP, HALF_EVEN, UP)
192
- * [more] {boolean} Whether the result of division was truncated.
193
- */
194
-
195
-
196
- function round(x, dp, rm, more) {
197
- var xc = x.c,
198
- i = x.e + dp + 1;
199
-
200
- if (i < xc.length) {
201
- if (rm === 1) {
202
- // xc[i] is the digit after the digit that may be rounded up.
203
- more = xc[i] >= 5;
204
- } else if (rm === 2) {
205
- more = xc[i] > 5 || xc[i] == 5 && (more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1);
206
- } else if (rm === 3) {
207
- more = more || !!xc[0];
208
- } else {
209
- more = false;
210
- if (rm !== 0) throw Error(INVALID_RM);
211
- }
212
-
213
- if (i < 1) {
214
- xc.length = 1;
215
-
216
- if (more) {
217
- // 1, 0.1, 0.01, 0.001, 0.0001 etc.
218
- x.e = -dp;
219
- xc[0] = 1;
220
- } else {
221
- // Zero.
222
- xc[0] = x.e = 0;
223
- }
224
- } else {
225
- // Remove any digits after the required decimal places.
226
- xc.length = i--; // Round up?
227
-
228
- if (more) {
229
- // Rounding up may mean the previous digit has to be rounded up.
230
- for (; ++xc[i] > 9;) {
231
- xc[i] = 0;
232
-
233
- if (!i--) {
234
- ++x.e;
235
- xc.unshift(1);
236
- }
237
- }
238
- } // Remove trailing zeros.
239
-
240
-
241
- for (i = xc.length; !xc[--i];) xc.pop();
242
- }
243
- } else if (rm < 0 || rm > 3 || rm !== ~~rm) {
244
- throw Error(INVALID_RM);
245
- }
246
-
247
- return x;
248
- }
249
- /*
250
- * Return a string representing the value of Big x in normal or exponential notation.
251
- * Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf.
252
- *
253
- * x {Big}
254
- * id? {number} Caller id.
255
- * 1 toExponential
256
- * 2 toFixed
257
- * 3 toPrecision
258
- * 4 valueOf
259
- * n? {number|undefined} Caller's argument.
260
- * k? {number|undefined}
261
- */
262
-
263
-
264
- function stringify(x, id, n, k) {
265
- var e,
266
- s,
267
- Big = x.constructor,
268
- z = !x.c[0];
269
-
270
- if (n !== UNDEFINED) {
271
- if (n !== ~~n || n < (id == 3) || n > MAX_DP) {
272
- throw Error(id == 3 ? INVALID + "precision" : INVALID_DP);
273
- }
274
-
275
- x = new Big(x); // The index of the digit that may be rounded up.
276
-
277
- n = k - x.e; // Round?
278
-
279
- if (x.c.length > ++k) round(x, n, Big.RM); // toFixed: recalculate k as x.e may have changed if value rounded up.
280
-
281
- if (id == 2) k = x.e + n + 1; // Append zeros?
282
-
283
- for (; x.c.length < k;) x.c.push(0);
284
- }
285
-
286
- e = x.e;
287
- s = x.c.join("");
288
- n = s.length; // Exponential notation?
289
-
290
- if (id != 2 && (id == 1 || id == 3 && k <= e || e <= Big.NE || e >= Big.PE)) {
291
- s = s.charAt(0) + (n > 1 ? "." + s.slice(1) : "") + (e < 0 ? "e" : "e+") + e; // Normal notation.
292
- } else if (e < 0) {
293
- for (; ++e;) s = "0" + s;
294
-
295
- s = "0." + s;
296
- } else if (e > 0) {
297
- if (++e > n) for (e -= n; e--;) s += "0";else if (e < n) s = s.slice(0, e) + "." + s.slice(e);
298
- } else if (n > 1) {
299
- s = s.charAt(0) + "." + s.slice(1);
300
- }
301
-
302
- return x.s < 0 && (!z || id == 4) ? "-" + s : s;
303
- } // Prototype/instance methods
304
-
305
- /*
306
- * Return a new Big whose value is the absolute value of this Big.
307
- */
308
-
309
-
310
- P.abs = function () {
311
- var x = new this.constructor(this);
312
- x.s = 1;
313
- return x;
314
- };
315
- /*
316
- * Return 1 if the value of this Big is greater than the value of Big y,
317
- * -1 if the value of this Big is less than the value of Big y, or
318
- * 0 if they have the same value.
319
- */
320
-
321
-
322
- P.cmp = function (y) {
323
- var isneg,
324
- Big = this.constructor,
325
- x = new Big(this),
326
- y = new Big(y),
327
- xc = x.c,
328
- yc = y.c,
329
- i = x.s,
330
- j = y.s,
331
- k = x.e,
332
- l = y.e; // Either zero?
333
-
334
- if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i; // Signs differ?
335
-
336
- if (i != j) return i;
337
- isneg = i < 0; // Compare exponents.
338
-
339
- if (k != l) return k > l ^ isneg ? 1 : -1; // Compare digit by digit.
340
-
341
- j = Math.max(xc.length, yc.length);
342
-
343
- for (i = 0; i < j; i++) {
344
- k = i < xc.length ? xc[i] : 0;
345
- l = i < yc.length ? yc[i] : 0;
346
- if (k != l) return k > l ^ isneg ? 1 : -1;
347
- }
348
-
349
- return 0; // old version (doesn't compare well trailing zeroes, e.g. 1.0 with 1.00)
350
- // j = (k = xc.length) < (l = yc.length) ? k : l;
351
- // // Compare digit by digit.
352
- // for (i = -1; ++i < j;) {
353
- // if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1;
354
- // }
355
- // // Compare lengths.
356
- // return k == l ? 0 : k > l ^ isneg ? 1 : -1;
357
- };
358
- /*
359
- * Return a new Big whose value is the value of this Big divided by the value of Big y, rounded,
360
- * if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
361
- */
362
-
363
-
364
- P.div = function (y) {
365
- var Big = this.constructor,
366
- x = new Big(this),
367
- y = new Big(y),
368
- a = x.c,
369
- // dividend
370
- b = y.c,
371
- // divisor
372
- k = x.s == y.s ? 1 : -1,
373
- dp = Big.DP;
374
- if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP); // Divisor is zero?
375
-
376
- if (!b[0]) throw Error(DIV_BY_ZERO); // Dividend is 0? Return +-0.
377
-
378
- if (!a[0]) return new Big(k * 0);
379
- var bl,
380
- bt,
381
- n,
382
- cmp,
383
- ri,
384
- bz = b.slice(),
385
- ai = bl = b.length,
386
- al = a.length,
387
- r = a.slice(0, bl),
388
- // remainder
389
- rl = r.length,
390
- q = y,
391
- // quotient
392
- qc = q.c = [],
393
- qi = 0,
394
- d = dp + (q.e = x.e - y.e) + 1; // number of digits of the result
395
-
396
- q.s = k;
397
- k = d < 0 ? 0 : d; // Create version of divisor with leading zero.
398
-
399
- bz.unshift(0); // Add zeros to make remainder as long as divisor.
400
-
401
- for (; rl++ < bl;) r.push(0);
402
-
403
- do {
404
- // n is how many times the divisor goes into current remainder.
405
- for (n = 0; n < 10; n++) {
406
- // Compare divisor and remainder.
407
- if (bl != (rl = r.length)) {
408
- cmp = bl > rl ? 1 : -1;
409
- } else {
410
- for (ri = -1, cmp = 0; ++ri < bl;) {
411
- if (b[ri] != r[ri]) {
412
- cmp = b[ri] > r[ri] ? 1 : -1;
413
- break;
414
- }
415
- }
416
- } // If divisor < remainder, subtract divisor from remainder.
417
-
418
-
419
- if (cmp < 0) {
420
- // Remainder can't be more than 1 digit longer than divisor.
421
- // Equalise lengths using divisor with extra leading zero?
422
- for (bt = rl == bl ? b : bz; rl;) {
423
- if (r[--rl] < bt[rl]) {
424
- ri = rl;
425
-
426
- for (; ri && !r[--ri];) r[ri] = 9;
427
-
428
- --r[ri];
429
- r[rl] += 10;
430
- }
431
-
432
- r[rl] -= bt[rl];
433
- }
434
-
435
- for (; !r[0];) r.shift();
436
- } else {
437
- break;
438
- }
439
- } // Add the digit n to the result array.
440
-
441
-
442
- qc[qi++] = cmp ? n : ++n; // Update the remainder.
443
-
444
- if (r[0] && cmp) r[rl] = a[ai] || 0;else r = [a[ai]];
445
- } while ((ai++ < al || r[0] !== UNDEFINED) && k--); // Leading zero? Do not remove if result is simply zero (qi == 1).
446
-
447
-
448
- if (!qc[0] && qi != 1) {
449
- // There can't be more than one zero.
450
- qc.shift();
451
- q.e--;
452
- } // Round?
453
-
454
-
455
- if (qi > d) round(q, dp, Big.RM, r[0] !== UNDEFINED);
456
- return q;
457
- };
458
- /*
459
- * Return true if the value of this Big is equal to the value of Big y, otherwise return false.
460
- */
461
-
462
-
463
- P.eq = function (y) {
464
- return !this.cmp(y);
465
- };
466
- /*
467
- * Return true if the value of this Big is greater than the value of Big y, otherwise return
468
- * false.
469
- */
470
-
471
-
472
- P.gt = function (y) {
473
- return this.cmp(y) > 0;
474
- };
475
- /*
476
- * Return true if the value of this Big is greater than or equal to the value of Big y, otherwise
477
- * return false.
478
- */
479
-
480
-
481
- P.gte = function (y) {
482
- return this.cmp(y) > -1;
483
- };
484
- /*
485
- * Return true if the value of this Big is less than the value of Big y, otherwise return false.
486
- */
487
-
488
-
489
- P.lt = function (y) {
490
- return this.cmp(y) < 0;
491
- };
492
- /*
493
- * Return true if the value of this Big is less than or equal to the value of Big y, otherwise
494
- * return false.
495
- */
496
-
497
-
498
- P.lte = function (y) {
499
- return this.cmp(y) < 1;
500
- };
501
- /*
502
- * Return a new Big whose value is the value of this Big minus the value of Big y.
503
- */
504
-
505
-
506
- P.minus = P.sub = function (y) {
507
- var i,
508
- j,
509
- t,
510
- xlty,
511
- Big = this.constructor,
512
- x = new Big(this),
513
- y = new Big(y),
514
- a = x.s,
515
- b = y.s; // Signs differ?
516
-
517
- if (a != b) {
518
- y.s = -b;
519
- return x.plus(y);
520
- }
521
-
522
- var xc = x.c.slice(),
523
- xe = x.e,
524
- yc = y.c,
525
- ye = y.e; // Either zero?
526
-
527
- if (!xc[0] || !yc[0]) {
528
- // y is non-zero? x is non-zero? Or both are zero.
529
- return yc[0] ? (y.s = -b, y) : new Big(xc[0] ? x : 0);
530
- } // Determine which is the bigger number. Prepend zeros to equalise exponents.
531
-
532
-
533
- if (a = xe - ye) {
534
- if (xlty = a < 0) {
535
- a = -a;
536
- t = xc;
537
- } else {
538
- ye = xe;
539
- t = yc;
540
- }
541
-
542
- t.reverse();
543
-
544
- for (b = a; b--;) t.push(0);
545
-
546
- t.reverse();
547
- } else {
548
- // Exponents equal. Check digit by digit.
549
- j = ((xlty = xc.length < yc.length) ? xc : yc).length;
550
-
551
- for (a = b = 0; b < j; b++) {
552
- if (xc[b] != yc[b]) {
553
- xlty = xc[b] < yc[b];
554
- break;
555
- }
556
- }
557
- } // x < y? Point xc to the array of the bigger number.
558
-
559
-
560
- if (xlty) {
561
- t = xc;
562
- xc = yc;
563
- yc = t;
564
- y.s = -y.s;
565
- }
566
- /*
567
- * Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only
568
- * needs to start at yc.length.
569
- */
570
-
571
-
572
- if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0; // Subtract yc from xc.
573
-
574
- for (b = i; j > a;) {
575
- if (xc[--j] < yc[j]) {
576
- for (i = j; i && !xc[--i];) xc[i] = 9;
577
-
578
- --xc[i];
579
- xc[j] += 10;
580
- }
581
-
582
- xc[j] -= yc[j];
583
- } // Remove trailing zeros.
584
-
585
-
586
- for (; xc[--b] === 0;) xc.pop(); // Remove leading zeros and adjust exponent accordingly.
587
-
588
-
589
- for (; xc[0] === 0;) {
590
- xc.shift();
591
- --ye;
592
- }
593
-
594
- if (!xc[0]) {
595
- // n - n = +0
596
- y.s = 1; // Result must be zero.
597
-
598
- xc = [ye = 0];
599
- }
600
-
601
- y.c = xc;
602
- y.e = ye;
603
- return y;
604
- };
605
- /*
606
- * Return a new Big whose value is the value of this Big modulo the value of Big y.
607
- */
608
-
609
-
610
- P.mod = function (y) {
611
- var ygtx,
612
- Big = this.constructor,
613
- x = new Big(this),
614
- y = new Big(y),
615
- a = x.s,
616
- b = y.s;
617
- if (!y.c[0]) throw Error(DIV_BY_ZERO);
618
- x.s = y.s = 1;
619
- ygtx = y.cmp(x) == 1;
620
- x.s = a;
621
- y.s = b;
622
- if (ygtx) return new Big(x);
623
- a = Big.DP;
624
- b = Big.RM;
625
- Big.DP = Big.RM = 0;
626
- x = x.div(y);
627
- Big.DP = a;
628
- Big.RM = b;
629
- return this.minus(x.times(y));
630
- };
631
- /*
632
- * Return a new Big whose value is the value of this Big plus the value of Big y.
633
- */
634
-
635
-
636
- P.plus = P.add = function (y) {
637
- var t,
638
- Big = this.constructor,
639
- x = new Big(this),
640
- y = new Big(y),
641
- a = x.s,
642
- b = y.s; // Signs differ?
643
-
644
- if (a != b) {
645
- y.s = -b;
646
- return x.minus(y);
647
- }
648
-
649
- var xe = x.e,
650
- xc = x.c,
651
- ye = y.e,
652
- yc = y.c; // Either zero? y is non-zero? x is non-zero? Or both are zero.
653
-
654
- if (!xc[0] || !yc[0]) return yc[0] ? y : new Big(xc[0] ? x : a * 0);
655
- xc = xc.slice(); // Prepend zeros to equalise exponents.
656
- // Note: reverse faster than unshifts.
657
-
658
- if (a = xe - ye) {
659
- if (a > 0) {
660
- ye = xe;
661
- t = yc;
662
- } else {
663
- a = -a;
664
- t = xc;
665
- }
666
-
667
- t.reverse();
668
-
669
- for (; a--;) t.push(0);
670
-
671
- t.reverse();
672
- } // Point xc to the longer array.
673
-
674
-
675
- if (xc.length - yc.length < 0) {
676
- t = yc;
677
- yc = xc;
678
- xc = t;
679
- }
680
-
681
- a = yc.length; // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.
682
-
683
- for (b = 0; a; xc[a] %= 10) b = (xc[--a] = xc[a] + yc[a] + b) / 10 | 0; // No need to check for zero, as +x + +y != 0 && -x + -y != 0
684
-
685
-
686
- if (b) {
687
- xc.unshift(b);
688
- ++ye;
689
- } // Remove trailing zeros.
690
-
691
-
692
- for (a = xc.length; xc[--a] === 0;) xc.pop();
693
-
694
- y.c = xc;
695
- y.e = ye;
696
- return y;
697
- };
698
- /*
699
- * Return a Big whose value is the value of this Big raised to the power n.
700
- * If n is negative, round to a maximum of Big.DP decimal places using rounding
701
- * mode Big.RM.
702
- *
703
- * n {number} Integer, -MAX_POWER to MAX_POWER inclusive.
704
- */
705
-
706
-
707
- P.pow = function (n) {
708
- var Big = this.constructor,
709
- x = new Big(this),
710
- y = new Big(1),
711
- one = new Big(1),
712
- isneg = n < 0;
713
- if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) throw Error(INVALID + "exponent");
714
- if (isneg) n = -n;
715
-
716
- for (;;) {
717
- if (n & 1) y = y.times(x);
718
- n >>= 1;
719
- if (!n) break;
720
- x = x.times(x);
721
- }
722
-
723
- return isneg ? one.div(y) : y;
724
- };
725
- /*
726
- * Return a new Big whose value is the value of this Big rounded using rounding mode rm
727
- * to a maximum of dp decimal places, or, if dp is negative, to an integer which is a
728
- * multiple of 10**-dp.
729
- * If dp is not specified, round to 0 decimal places.
730
- * If rm is not specified, use Big.RM.
731
- *
732
- * dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
733
- * rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP)
734
- */
735
-
736
-
737
- P.round = function (dp, rm) {
738
- var Big = this.constructor;
739
- if (dp === UNDEFINED) dp = 0;else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
740
- return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm);
741
- };
742
- /*
743
- * Return a new Big whose value is the square root of the value of this Big, rounded, if
744
- * necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
745
- */
746
-
747
-
748
- P.sqrt = function () {
749
- var r,
750
- c,
751
- t,
752
- Big = this.constructor,
753
- x = new Big(this),
754
- s = x.s,
755
- e = x.e,
756
- half = new Big(0.5); // Zero?
757
-
758
- if (!x.c[0]) return new Big(x); // Negative?
759
-
760
- if (s < 0) throw Error(NAME + "No square root"); // Estimate.
761
-
762
- s = Math.sqrt(x + ""); // Math.sqrt underflow/overflow?
763
- // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
764
-
765
- if (s === 0 || s === 1 / 0) {
766
- c = x.c.join("");
767
- if (!(c.length + e & 1)) c += "0";
768
- s = Math.sqrt(c);
769
- e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
770
- r = new Big((s == 1 / 0 ? "1e" : (s = s.toExponential()).slice(0, s.indexOf("e") + 1)) + e);
771
- } else {
772
- r = new Big(s);
773
- }
774
-
775
- e = r.e + (Big.DP += 4); // Newton-Raphson iteration.
776
-
777
- do {
778
- t = r;
779
- r = half.times(t.plus(x.div(t)));
780
- } while (t.c.slice(0, e).join("") !== r.c.slice(0, e).join(""));
781
-
782
- return round(r, Big.DP -= 4, Big.RM);
783
- };
784
- /*
785
- * Return a new Big whose value is the value of this Big times the value of Big y.
786
- */
787
-
788
-
789
- P.times = P.mul = function (y) {
790
- var c,
791
- Big = this.constructor,
792
- x = new Big(this),
793
- y = new Big(y),
794
- xc = x.c,
795
- yc = y.c,
796
- a = xc.length,
797
- b = yc.length,
798
- i = x.e,
799
- j = y.e; // Determine sign of result.
800
-
801
- y.s = x.s == y.s ? 1 : -1; // Return signed 0 if either 0.
802
-
803
- if (!xc[0] || !yc[0]) return new Big(y.s * 0); // Initialise exponent of result as x.e + y.e.
804
-
805
- y.e = i + j; // If array xc has fewer digits than yc, swap xc and yc, and lengths.
806
-
807
- if (a < b) {
808
- c = xc;
809
- xc = yc;
810
- yc = c;
811
- j = a;
812
- a = b;
813
- b = j;
814
- } // Initialise coefficient array of result with zeros.
815
-
816
-
817
- for (c = new Array(j = a + b); j--;) c[j] = 0; // Multiply.
818
- // i is initially xc.length.
819
-
820
-
821
- for (i = b; i--;) {
822
- b = 0; // a is yc.length.
823
-
824
- for (j = a + i; j > i;) {
825
- // Current sum of products at this digit position, plus carry.
826
- b = c[j] + yc[i] * xc[j - i - 1] + b;
827
- c[j--] = b % 10; // carry
828
-
829
- b = b / 10 | 0;
830
- }
831
-
832
- c[j] = (c[j] + b) % 10;
833
- } // Increment result exponent if there is a final carry, otherwise remove leading zero.
834
-
835
-
836
- if (b) ++y.e;else c.shift(); // Remove trailing zeros.
837
-
838
- for (i = c.length; !c[--i];) c.pop();
839
-
840
- y.c = c;
841
- return y;
842
- };
843
- /*
844
- * Return a string representing the value of this Big in exponential notation to dp fixed decimal
845
- * places and rounded using Big.RM.
846
- *
847
- * dp? {number} Integer, 0 to MAX_DP inclusive.
848
- */
849
-
850
-
851
- P.toExponential = function (dp) {
852
- return stringify(this, 1, dp, dp);
853
- };
854
- /*
855
- * Return a string representing the value of this Big in normal notation to dp fixed decimal
856
- * places and rounded using Big.RM.
857
- *
858
- * dp? {number} Integer, 0 to MAX_DP inclusive.
859
- *
860
- * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
861
- * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
862
- */
863
-
864
-
865
- P.toFixed = function (dp) {
866
- return stringify(this, 2, dp, this.e + dp);
867
- };
868
- /*
869
- * Return a string representing the value of this Big rounded to sd significant digits using
870
- * Big.RM. Use exponential notation if sd is less than the number of digits necessary to represent
871
- * the integer part of the value in normal notation.
872
- *
873
- * sd {number} Integer, 1 to MAX_DP inclusive.
874
- */
875
-
876
-
877
- P.toPrecision = function (sd) {
878
- return stringify(this, 3, sd, sd - 1);
879
- };
880
- /*
881
- * Return a string representing the value of this Big.
882
- * Return exponential notation if this Big has a positive exponent equal to or greater than
883
- * Big.PE, or a negative exponent equal to or less than Big.NE.
884
- * Omit the sign for negative zero.
885
- */
886
-
887
-
888
- P.toString = function () {
889
- return stringify(this);
890
- };
891
- /*
892
- * Return a string representing the value of this Big.
893
- * Return exponential notation if this Big has a positive exponent equal to or greater than
894
- * Big.PE, or a negative exponent equal to or less than Big.NE.
895
- * Include the sign for negative zero.
896
- */
897
-
898
-
899
- P.valueOf = P.toJSON = function () {
900
- return stringify(this, 4);
901
- }; // Export
902
-
903
-
904
- export var Big = _Big_();
905
- export default Big;