@wzyjs/utils 0.3.28 → 0.3.30
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.
- package/dist/{web/antd.d.ts → common/antd/index.d.ts} +1 -0
- package/dist/common/base/array.d.ts +0 -2
- package/dist/common/base/index.d.ts +0 -1
- package/dist/common/base/object.d.ts +1 -7
- package/dist/common/base/other.d.ts +1 -3
- package/dist/common/base/promise.d.ts +1 -1
- package/dist/common/base/string.d.ts +10 -10
- package/dist/common/dayjs/index.d.ts +0 -2
- package/dist/common/index.d.ts +2 -2
- package/dist/node.cjs.js +4511 -32993
- package/dist/node.d.ts +1 -0
- package/dist/node.esm.js +4426 -32864
- package/dist/web/download.d.ts +1 -1
- package/dist/web/element.d.ts +1 -5
- package/dist/web.cjs.js +839 -2755
- package/dist/web.d.ts +2 -2
- package/dist/web.esm.js +839 -2755
- package/package.json +3 -2
- package/dist/common/base/number.d.ts +0 -5
- package/dist/common/image/index.d.ts +0 -1
- package/dist/web/location.d.ts +0 -8
- package/dist/web/style.d.ts +0 -10
package/dist/web.cjs.js
CHANGED
|
@@ -8281,7 +8281,7 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
8281
8281
|
var tag = baseGetTag(value);
|
|
8282
8282
|
return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject2(value);
|
|
8283
8283
|
}
|
|
8284
|
-
function
|
|
8284
|
+
function isFinite(value) {
|
|
8285
8285
|
return typeof value == "number" && nativeIsFinite(value);
|
|
8286
8286
|
}
|
|
8287
8287
|
function isFunction3(value) {
|
|
@@ -9150,7 +9150,7 @@ __p += '`;
|
|
|
9150
9150
|
return augend + addend;
|
|
9151
9151
|
}, 0);
|
|
9152
9152
|
var ceil = createRound("ceil");
|
|
9153
|
-
var
|
|
9153
|
+
var divide2 = createMathOperation(function(dividend, divisor) {
|
|
9154
9154
|
return dividend / divisor;
|
|
9155
9155
|
}, 1);
|
|
9156
9156
|
var floor = createRound("floor");
|
|
@@ -9352,7 +9352,7 @@ __p += '`;
|
|
|
9352
9352
|
lodash.conformsTo = conformsTo;
|
|
9353
9353
|
lodash.deburr = deburr;
|
|
9354
9354
|
lodash.defaultTo = defaultTo;
|
|
9355
|
-
lodash.divide =
|
|
9355
|
+
lodash.divide = divide2;
|
|
9356
9356
|
lodash.endsWith = endsWith2;
|
|
9357
9357
|
lodash.eq = eq;
|
|
9358
9358
|
lodash.escape = escape2;
|
|
@@ -9395,7 +9395,7 @@ __p += '`;
|
|
|
9395
9395
|
lodash.isEqual = isEqual;
|
|
9396
9396
|
lodash.isEqualWith = isEqualWith;
|
|
9397
9397
|
lodash.isError = isError;
|
|
9398
|
-
lodash.isFinite =
|
|
9398
|
+
lodash.isFinite = isFinite;
|
|
9399
9399
|
lodash.isFunction = isFunction3;
|
|
9400
9400
|
lodash.isInteger = isInteger;
|
|
9401
9401
|
lodash.isLength = isLength;
|
|
@@ -10319,51 +10319,520 @@ var require_zh_cn = __commonJS((exports2, module2) => {
|
|
|
10319
10319
|
});
|
|
10320
10320
|
});
|
|
10321
10321
|
|
|
10322
|
+
// ../../node_modules/papaparse/papaparse.min.js
|
|
10323
|
+
var require_papaparse_min = __commonJS((exports2, module2) => {
|
|
10324
|
+
((e, t) => {
|
|
10325
|
+
typeof define == "function" && define.amd ? define([], t) : typeof module2 == "object" && typeof exports2 != "undefined" ? module2.exports = t() : e.Papa = t();
|
|
10326
|
+
})(exports2, function r() {
|
|
10327
|
+
var n = typeof self != "undefined" ? self : typeof window != "undefined" ? window : n !== undefined ? n : {};
|
|
10328
|
+
var d, s = !n.document && !!n.postMessage, a = n.IS_PAPA_WORKER || false, o = {}, h = 0, v = {};
|
|
10329
|
+
function u(e) {
|
|
10330
|
+
this._handle = null, this._finished = false, this._completed = false, this._halted = false, this._input = null, this._baseIndex = 0, this._partialLine = "", this._rowCount = 0, this._start = 0, this._nextChunk = null, this.isFirstChunk = true, this._completeResults = { data: [], errors: [], meta: {} }, function(e2) {
|
|
10331
|
+
var t = b(e2);
|
|
10332
|
+
t.chunkSize = parseInt(t.chunkSize), e2.step || e2.chunk || (t.chunkSize = null);
|
|
10333
|
+
this._handle = new i(t), (this._handle.streamer = this)._config = t;
|
|
10334
|
+
}.call(this, e), this.parseChunk = function(t, e2) {
|
|
10335
|
+
var i2 = parseInt(this._config.skipFirstNLines) || 0;
|
|
10336
|
+
if (this.isFirstChunk && 0 < i2) {
|
|
10337
|
+
let e3 = this._config.newline;
|
|
10338
|
+
e3 || (r2 = this._config.quoteChar || '"', e3 = this._handle.guessLineEndings(t, r2)), t = [...t.split(e3).slice(i2)].join(e3);
|
|
10339
|
+
}
|
|
10340
|
+
this.isFirstChunk && U(this._config.beforeFirstChunk) && (r2 = this._config.beforeFirstChunk(t)) !== undefined && (t = r2), this.isFirstChunk = false, this._halted = false;
|
|
10341
|
+
var i2 = this._partialLine + t, r2 = (this._partialLine = "", this._handle.parse(i2, this._baseIndex, !this._finished));
|
|
10342
|
+
if (!this._handle.paused() && !this._handle.aborted()) {
|
|
10343
|
+
t = r2.meta.cursor, i2 = (this._finished || (this._partialLine = i2.substring(t - this._baseIndex), this._baseIndex = t), r2 && r2.data && (this._rowCount += r2.data.length), this._finished || this._config.preview && this._rowCount >= this._config.preview);
|
|
10344
|
+
if (a)
|
|
10345
|
+
n.postMessage({ results: r2, workerId: v.WORKER_ID, finished: i2 });
|
|
10346
|
+
else if (U(this._config.chunk) && !e2) {
|
|
10347
|
+
if (this._config.chunk(r2, this._handle), this._handle.paused() || this._handle.aborted())
|
|
10348
|
+
return void (this._halted = true);
|
|
10349
|
+
this._completeResults = r2 = undefined;
|
|
10350
|
+
}
|
|
10351
|
+
return this._config.step || this._config.chunk || (this._completeResults.data = this._completeResults.data.concat(r2.data), this._completeResults.errors = this._completeResults.errors.concat(r2.errors), this._completeResults.meta = r2.meta), this._completed || !i2 || !U(this._config.complete) || r2 && r2.meta.aborted || (this._config.complete(this._completeResults, this._input), this._completed = true), i2 || r2 && r2.meta.paused || this._nextChunk(), r2;
|
|
10352
|
+
}
|
|
10353
|
+
this._halted = true;
|
|
10354
|
+
}, this._sendError = function(e2) {
|
|
10355
|
+
U(this._config.error) ? this._config.error(e2) : a && this._config.error && n.postMessage({ workerId: v.WORKER_ID, error: e2, finished: false });
|
|
10356
|
+
};
|
|
10357
|
+
}
|
|
10358
|
+
function f(e) {
|
|
10359
|
+
var r2;
|
|
10360
|
+
(e = e || {}).chunkSize || (e.chunkSize = v.RemoteChunkSize), u.call(this, e), this._nextChunk = s ? function() {
|
|
10361
|
+
this._readChunk(), this._chunkLoaded();
|
|
10362
|
+
} : function() {
|
|
10363
|
+
this._readChunk();
|
|
10364
|
+
}, this.stream = function(e2) {
|
|
10365
|
+
this._input = e2, this._nextChunk();
|
|
10366
|
+
}, this._readChunk = function() {
|
|
10367
|
+
if (this._finished)
|
|
10368
|
+
this._chunkLoaded();
|
|
10369
|
+
else {
|
|
10370
|
+
if (r2 = new XMLHttpRequest, this._config.withCredentials && (r2.withCredentials = this._config.withCredentials), s || (r2.onload = y(this._chunkLoaded, this), r2.onerror = y(this._chunkError, this)), r2.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !s), this._config.downloadRequestHeaders) {
|
|
10371
|
+
var e2, t = this._config.downloadRequestHeaders;
|
|
10372
|
+
for (e2 in t)
|
|
10373
|
+
r2.setRequestHeader(e2, t[e2]);
|
|
10374
|
+
}
|
|
10375
|
+
var i2;
|
|
10376
|
+
this._config.chunkSize && (i2 = this._start + this._config.chunkSize - 1, r2.setRequestHeader("Range", "bytes=" + this._start + "-" + i2));
|
|
10377
|
+
try {
|
|
10378
|
+
r2.send(this._config.downloadRequestBody);
|
|
10379
|
+
} catch (e3) {
|
|
10380
|
+
this._chunkError(e3.message);
|
|
10381
|
+
}
|
|
10382
|
+
s && r2.status === 0 && this._chunkError();
|
|
10383
|
+
}
|
|
10384
|
+
}, this._chunkLoaded = function() {
|
|
10385
|
+
r2.readyState === 4 && (r2.status < 200 || 400 <= r2.status ? this._chunkError() : (this._start += this._config.chunkSize || r2.responseText.length, this._finished = !this._config.chunkSize || this._start >= ((e2) => (e2 = e2.getResponseHeader("Content-Range")) !== null ? parseInt(e2.substring(e2.lastIndexOf("/") + 1)) : -1)(r2), this.parseChunk(r2.responseText)));
|
|
10386
|
+
}, this._chunkError = function(e2) {
|
|
10387
|
+
e2 = r2.statusText || e2;
|
|
10388
|
+
this._sendError(new Error(e2));
|
|
10389
|
+
};
|
|
10390
|
+
}
|
|
10391
|
+
function l(e) {
|
|
10392
|
+
(e = e || {}).chunkSize || (e.chunkSize = v.LocalChunkSize), u.call(this, e);
|
|
10393
|
+
var i2, r2, n2 = typeof FileReader != "undefined";
|
|
10394
|
+
this.stream = function(e2) {
|
|
10395
|
+
this._input = e2, r2 = e2.slice || e2.webkitSlice || e2.mozSlice, n2 ? ((i2 = new FileReader).onload = y(this._chunkLoaded, this), i2.onerror = y(this._chunkError, this)) : i2 = new FileReaderSync, this._nextChunk();
|
|
10396
|
+
}, this._nextChunk = function() {
|
|
10397
|
+
this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk();
|
|
10398
|
+
}, this._readChunk = function() {
|
|
10399
|
+
var e2 = this._input, t = (this._config.chunkSize && (t = Math.min(this._start + this._config.chunkSize, this._input.size), e2 = r2.call(e2, this._start, t)), i2.readAsText(e2, this._config.encoding));
|
|
10400
|
+
n2 || this._chunkLoaded({ target: { result: t } });
|
|
10401
|
+
}, this._chunkLoaded = function(e2) {
|
|
10402
|
+
this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(e2.target.result);
|
|
10403
|
+
}, this._chunkError = function() {
|
|
10404
|
+
this._sendError(i2.error);
|
|
10405
|
+
};
|
|
10406
|
+
}
|
|
10407
|
+
function c(e) {
|
|
10408
|
+
var i2;
|
|
10409
|
+
u.call(this, e = e || {}), this.stream = function(e2) {
|
|
10410
|
+
return i2 = e2, this._nextChunk();
|
|
10411
|
+
}, this._nextChunk = function() {
|
|
10412
|
+
var e2, t;
|
|
10413
|
+
if (!this._finished)
|
|
10414
|
+
return e2 = this._config.chunkSize, i2 = e2 ? (t = i2.substring(0, e2), i2.substring(e2)) : (t = i2, ""), this._finished = !i2, this.parseChunk(t);
|
|
10415
|
+
};
|
|
10416
|
+
}
|
|
10417
|
+
function p(e) {
|
|
10418
|
+
u.call(this, e = e || {});
|
|
10419
|
+
var t = [], i2 = true, r2 = false;
|
|
10420
|
+
this.pause = function() {
|
|
10421
|
+
u.prototype.pause.apply(this, arguments), this._input.pause();
|
|
10422
|
+
}, this.resume = function() {
|
|
10423
|
+
u.prototype.resume.apply(this, arguments), this._input.resume();
|
|
10424
|
+
}, this.stream = function(e2) {
|
|
10425
|
+
this._input = e2, this._input.on("data", this._streamData), this._input.on("end", this._streamEnd), this._input.on("error", this._streamError);
|
|
10426
|
+
}, this._checkIsFinished = function() {
|
|
10427
|
+
r2 && t.length === 1 && (this._finished = true);
|
|
10428
|
+
}, this._nextChunk = function() {
|
|
10429
|
+
this._checkIsFinished(), t.length ? this.parseChunk(t.shift()) : i2 = true;
|
|
10430
|
+
}, this._streamData = y(function(e2) {
|
|
10431
|
+
try {
|
|
10432
|
+
t.push(typeof e2 == "string" ? e2 : e2.toString(this._config.encoding)), i2 && (i2 = false, this._checkIsFinished(), this.parseChunk(t.shift()));
|
|
10433
|
+
} catch (e3) {
|
|
10434
|
+
this._streamError(e3);
|
|
10435
|
+
}
|
|
10436
|
+
}, this), this._streamError = y(function(e2) {
|
|
10437
|
+
this._streamCleanUp(), this._sendError(e2);
|
|
10438
|
+
}, this), this._streamEnd = y(function() {
|
|
10439
|
+
this._streamCleanUp(), r2 = true, this._streamData("");
|
|
10440
|
+
}, this), this._streamCleanUp = y(function() {
|
|
10441
|
+
this._input.removeListener("data", this._streamData), this._input.removeListener("end", this._streamEnd), this._input.removeListener("error", this._streamError);
|
|
10442
|
+
}, this);
|
|
10443
|
+
}
|
|
10444
|
+
function i(m2) {
|
|
10445
|
+
var n2, s2, a2, t, o2 = Math.pow(2, 53), h2 = -o2, u2 = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/, d2 = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/, i2 = this, r2 = 0, f2 = 0, l2 = false, e = false, c2 = [], p2 = { data: [], errors: [], meta: {} };
|
|
10446
|
+
function y2(e2) {
|
|
10447
|
+
return m2.skipEmptyLines === "greedy" ? e2.join("").trim() === "" : e2.length === 1 && e2[0].length === 0;
|
|
10448
|
+
}
|
|
10449
|
+
function g2() {
|
|
10450
|
+
if (p2 && a2 && (k("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + v.DefaultDelimiter + "'"), a2 = false), m2.skipEmptyLines && (p2.data = p2.data.filter(function(e3) {
|
|
10451
|
+
return !y2(e3);
|
|
10452
|
+
})), _2()) {
|
|
10453
|
+
let t3 = function(e3, t4) {
|
|
10454
|
+
U(m2.transformHeader) && (e3 = m2.transformHeader(e3, t4)), c2.push(e3);
|
|
10455
|
+
};
|
|
10456
|
+
var t2 = t3;
|
|
10457
|
+
if (p2)
|
|
10458
|
+
if (Array.isArray(p2.data[0])) {
|
|
10459
|
+
for (var e2 = 0;_2() && e2 < p2.data.length; e2++)
|
|
10460
|
+
p2.data[e2].forEach(t3);
|
|
10461
|
+
p2.data.splice(0, 1);
|
|
10462
|
+
} else
|
|
10463
|
+
p2.data.forEach(t3);
|
|
10464
|
+
}
|
|
10465
|
+
function i3(e3, t3) {
|
|
10466
|
+
for (var i4 = m2.header ? {} : [], r4 = 0;r4 < e3.length; r4++) {
|
|
10467
|
+
var n3 = r4, s3 = e3[r4], s3 = ((e4, t4) => ((e5) => (m2.dynamicTypingFunction && m2.dynamicTyping[e5] === undefined && (m2.dynamicTyping[e5] = m2.dynamicTypingFunction(e5)), (m2.dynamicTyping[e5] || m2.dynamicTyping) === true))(e4) ? t4 === "true" || t4 === "TRUE" || t4 !== "false" && t4 !== "FALSE" && (((e5) => {
|
|
10468
|
+
if (u2.test(e5)) {
|
|
10469
|
+
e5 = parseFloat(e5);
|
|
10470
|
+
if (h2 < e5 && e5 < o2)
|
|
10471
|
+
return 1;
|
|
10472
|
+
}
|
|
10473
|
+
})(t4) ? parseFloat(t4) : d2.test(t4) ? new Date(t4) : t4 === "" ? null : t4) : t4)(n3 = m2.header ? r4 >= c2.length ? "__parsed_extra" : c2[r4] : n3, s3 = m2.transform ? m2.transform(s3, n3) : s3);
|
|
10474
|
+
n3 === "__parsed_extra" ? (i4[n3] = i4[n3] || [], i4[n3].push(s3)) : i4[n3] = s3;
|
|
10475
|
+
}
|
|
10476
|
+
return m2.header && (r4 > c2.length ? k("FieldMismatch", "TooManyFields", "Too many fields: expected " + c2.length + " fields but parsed " + r4, f2 + t3) : r4 < c2.length && k("FieldMismatch", "TooFewFields", "Too few fields: expected " + c2.length + " fields but parsed " + r4, f2 + t3)), i4;
|
|
10477
|
+
}
|
|
10478
|
+
var r3;
|
|
10479
|
+
p2 && (m2.header || m2.dynamicTyping || m2.transform) && (r3 = 1, !p2.data.length || Array.isArray(p2.data[0]) ? (p2.data = p2.data.map(i3), r3 = p2.data.length) : p2.data = i3(p2.data, 0), m2.header && p2.meta && (p2.meta.fields = c2), f2 += r3);
|
|
10480
|
+
}
|
|
10481
|
+
function _2() {
|
|
10482
|
+
return m2.header && c2.length === 0;
|
|
10483
|
+
}
|
|
10484
|
+
function k(e2, t2, i3, r3) {
|
|
10485
|
+
e2 = { type: e2, code: t2, message: i3 };
|
|
10486
|
+
r3 !== undefined && (e2.row = r3), p2.errors.push(e2);
|
|
10487
|
+
}
|
|
10488
|
+
U(m2.step) && (t = m2.step, m2.step = function(e2) {
|
|
10489
|
+
p2 = e2, _2() ? g2() : (g2(), p2.data.length !== 0 && (r2 += e2.data.length, m2.preview && r2 > m2.preview ? s2.abort() : (p2.data = p2.data[0], t(p2, i2))));
|
|
10490
|
+
}), this.parse = function(e2, t2, i3) {
|
|
10491
|
+
var r3 = m2.quoteChar || '"', r3 = (m2.newline || (m2.newline = this.guessLineEndings(e2, r3)), a2 = false, m2.delimiter ? U(m2.delimiter) && (m2.delimiter = m2.delimiter(e2), p2.meta.delimiter = m2.delimiter) : ((r3 = ((e3, t3, i4, r4, n3) => {
|
|
10492
|
+
var s3, a3, o3, h3;
|
|
10493
|
+
n3 = n3 || [",", "\t", "|", ";", v.RECORD_SEP, v.UNIT_SEP];
|
|
10494
|
+
for (var u3 = 0;u3 < n3.length; u3++) {
|
|
10495
|
+
for (var d3, f3 = n3[u3], l3 = 0, c3 = 0, p3 = 0, g3 = (o3 = undefined, new E({ comments: r4, delimiter: f3, newline: t3, preview: 10 }).parse(e3)), _3 = 0;_3 < g3.data.length; _3++)
|
|
10496
|
+
i4 && y2(g3.data[_3]) ? p3++ : (d3 = g3.data[_3].length, c3 += d3, o3 === undefined ? o3 = d3 : 0 < d3 && (l3 += Math.abs(d3 - o3), o3 = d3));
|
|
10497
|
+
0 < g3.data.length && (c3 /= g3.data.length - p3), (a3 === undefined || l3 <= a3) && (h3 === undefined || h3 < c3) && 1.99 < c3 && (a3 = l3, s3 = f3, h3 = c3);
|
|
10498
|
+
}
|
|
10499
|
+
return { successful: !!(m2.delimiter = s3), bestDelimiter: s3 };
|
|
10500
|
+
})(e2, m2.newline, m2.skipEmptyLines, m2.comments, m2.delimitersToGuess)).successful ? m2.delimiter = r3.bestDelimiter : (a2 = true, m2.delimiter = v.DefaultDelimiter), p2.meta.delimiter = m2.delimiter), b(m2));
|
|
10501
|
+
return m2.preview && m2.header && r3.preview++, n2 = e2, s2 = new E(r3), p2 = s2.parse(n2, t2, i3), g2(), l2 ? { meta: { paused: true } } : p2 || { meta: { paused: false } };
|
|
10502
|
+
}, this.paused = function() {
|
|
10503
|
+
return l2;
|
|
10504
|
+
}, this.pause = function() {
|
|
10505
|
+
l2 = true, s2.abort(), n2 = U(m2.chunk) ? "" : n2.substring(s2.getCharIndex());
|
|
10506
|
+
}, this.resume = function() {
|
|
10507
|
+
i2.streamer._halted ? (l2 = false, i2.streamer.parseChunk(n2, true)) : setTimeout(i2.resume, 3);
|
|
10508
|
+
}, this.aborted = function() {
|
|
10509
|
+
return e;
|
|
10510
|
+
}, this.abort = function() {
|
|
10511
|
+
e = true, s2.abort(), p2.meta.aborted = true, U(m2.complete) && m2.complete(p2), n2 = "";
|
|
10512
|
+
}, this.guessLineEndings = function(e2, t2) {
|
|
10513
|
+
e2 = e2.substring(0, 1048576);
|
|
10514
|
+
var t2 = new RegExp(P(t2) + "([^]*?)" + P(t2), "gm"), i3 = (e2 = e2.replace(t2, "")).split("\r"), t2 = e2.split(`
|
|
10515
|
+
`), e2 = 1 < t2.length && t2[0].length < i3[0].length;
|
|
10516
|
+
if (i3.length === 1 || e2)
|
|
10517
|
+
return `
|
|
10518
|
+
`;
|
|
10519
|
+
for (var r3 = 0, n3 = 0;n3 < i3.length; n3++)
|
|
10520
|
+
i3[n3][0] === `
|
|
10521
|
+
` && r3++;
|
|
10522
|
+
return r3 >= i3.length / 2 ? `\r
|
|
10523
|
+
` : "\r";
|
|
10524
|
+
};
|
|
10525
|
+
}
|
|
10526
|
+
function P(e) {
|
|
10527
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10528
|
+
}
|
|
10529
|
+
function E(C) {
|
|
10530
|
+
var S = (C = C || {}).delimiter, O = C.newline, x = C.comments, I = C.step, A = C.preview, T = C.fastMode, D = null, L = false, F = C.quoteChar == null ? '"' : C.quoteChar, j = F;
|
|
10531
|
+
if (C.escapeChar !== undefined && (j = C.escapeChar), (typeof S != "string" || -1 < v.BAD_DELIMITERS.indexOf(S)) && (S = ","), x === S)
|
|
10532
|
+
throw new Error("Comment character same as delimiter");
|
|
10533
|
+
x === true ? x = "#" : (typeof x != "string" || -1 < v.BAD_DELIMITERS.indexOf(x)) && (x = false), O !== `
|
|
10534
|
+
` && O !== "\r" && O !== `\r
|
|
10535
|
+
` && (O = `
|
|
10536
|
+
`);
|
|
10537
|
+
var z = 0, M = false;
|
|
10538
|
+
this.parse = function(i2, t, r2) {
|
|
10539
|
+
if (typeof i2 != "string")
|
|
10540
|
+
throw new Error("Input must be a string");
|
|
10541
|
+
var n2 = i2.length, e = S.length, s2 = O.length, a2 = x.length, o2 = U(I), h2 = [], u2 = [], d2 = [], f2 = z = 0;
|
|
10542
|
+
if (!i2)
|
|
10543
|
+
return w();
|
|
10544
|
+
if (T || T !== false && i2.indexOf(F) === -1) {
|
|
10545
|
+
for (var l2 = i2.split(O), c2 = 0;c2 < l2.length; c2++) {
|
|
10546
|
+
if (d2 = l2[c2], z += d2.length, c2 !== l2.length - 1)
|
|
10547
|
+
z += O.length;
|
|
10548
|
+
else if (r2)
|
|
10549
|
+
return w();
|
|
10550
|
+
if (!x || d2.substring(0, a2) !== x) {
|
|
10551
|
+
if (o2) {
|
|
10552
|
+
if (h2 = [], k(d2.split(S)), R(), M)
|
|
10553
|
+
return w();
|
|
10554
|
+
} else
|
|
10555
|
+
k(d2.split(S));
|
|
10556
|
+
if (A && A <= c2)
|
|
10557
|
+
return h2 = h2.slice(0, A), w(true);
|
|
10558
|
+
}
|
|
10559
|
+
}
|
|
10560
|
+
return w();
|
|
10561
|
+
}
|
|
10562
|
+
for (var p2 = i2.indexOf(S, z), g2 = i2.indexOf(O, z), _2 = new RegExp(P(j) + P(F), "g"), m2 = i2.indexOf(F, z);; )
|
|
10563
|
+
if (i2[z] === F)
|
|
10564
|
+
for (m2 = z, z++;; ) {
|
|
10565
|
+
if ((m2 = i2.indexOf(F, m2 + 1)) === -1)
|
|
10566
|
+
return r2 || u2.push({ type: "Quotes", code: "MissingQuotes", message: "Quoted field unterminated", row: h2.length, index: z }), E2();
|
|
10567
|
+
if (m2 === n2 - 1)
|
|
10568
|
+
return E2(i2.substring(z, m2).replace(_2, F));
|
|
10569
|
+
if (F === j && i2[m2 + 1] === j)
|
|
10570
|
+
m2++;
|
|
10571
|
+
else if (F === j || m2 === 0 || i2[m2 - 1] !== j) {
|
|
10572
|
+
p2 !== -1 && p2 < m2 + 1 && (p2 = i2.indexOf(S, m2 + 1));
|
|
10573
|
+
var y2 = v2((g2 = g2 !== -1 && g2 < m2 + 1 ? i2.indexOf(O, m2 + 1) : g2) === -1 ? p2 : Math.min(p2, g2));
|
|
10574
|
+
if (i2.substr(m2 + 1 + y2, e) === S) {
|
|
10575
|
+
d2.push(i2.substring(z, m2).replace(_2, F)), i2[z = m2 + 1 + y2 + e] !== F && (m2 = i2.indexOf(F, z)), p2 = i2.indexOf(S, z), g2 = i2.indexOf(O, z);
|
|
10576
|
+
break;
|
|
10577
|
+
}
|
|
10578
|
+
y2 = v2(g2);
|
|
10579
|
+
if (i2.substring(m2 + 1 + y2, m2 + 1 + y2 + s2) === O) {
|
|
10580
|
+
if (d2.push(i2.substring(z, m2).replace(_2, F)), b2(m2 + 1 + y2 + s2), p2 = i2.indexOf(S, z), m2 = i2.indexOf(F, z), o2 && (R(), M))
|
|
10581
|
+
return w();
|
|
10582
|
+
if (A && h2.length >= A)
|
|
10583
|
+
return w(true);
|
|
10584
|
+
break;
|
|
10585
|
+
}
|
|
10586
|
+
u2.push({ type: "Quotes", code: "InvalidQuotes", message: "Trailing quote on quoted field is malformed", row: h2.length, index: z }), m2++;
|
|
10587
|
+
}
|
|
10588
|
+
}
|
|
10589
|
+
else if (x && d2.length === 0 && i2.substring(z, z + a2) === x) {
|
|
10590
|
+
if (g2 === -1)
|
|
10591
|
+
return w();
|
|
10592
|
+
z = g2 + s2, g2 = i2.indexOf(O, z), p2 = i2.indexOf(S, z);
|
|
10593
|
+
} else if (p2 !== -1 && (p2 < g2 || g2 === -1))
|
|
10594
|
+
d2.push(i2.substring(z, p2)), z = p2 + e, p2 = i2.indexOf(S, z);
|
|
10595
|
+
else {
|
|
10596
|
+
if (g2 === -1)
|
|
10597
|
+
break;
|
|
10598
|
+
if (d2.push(i2.substring(z, g2)), b2(g2 + s2), o2 && (R(), M))
|
|
10599
|
+
return w();
|
|
10600
|
+
if (A && h2.length >= A)
|
|
10601
|
+
return w(true);
|
|
10602
|
+
}
|
|
10603
|
+
return E2();
|
|
10604
|
+
function k(e2) {
|
|
10605
|
+
h2.push(e2), f2 = z;
|
|
10606
|
+
}
|
|
10607
|
+
function v2(e2) {
|
|
10608
|
+
var t2 = 0;
|
|
10609
|
+
return t2 = e2 !== -1 && (e2 = i2.substring(m2 + 1, e2)) && e2.trim() === "" ? e2.length : t2;
|
|
10610
|
+
}
|
|
10611
|
+
function E2(e2) {
|
|
10612
|
+
return r2 || (e2 === undefined && (e2 = i2.substring(z)), d2.push(e2), z = n2, k(d2), o2 && R()), w();
|
|
10613
|
+
}
|
|
10614
|
+
function b2(e2) {
|
|
10615
|
+
z = e2, k(d2), d2 = [], g2 = i2.indexOf(O, z);
|
|
10616
|
+
}
|
|
10617
|
+
function w(e2) {
|
|
10618
|
+
if (C.header && !t && h2.length && !L) {
|
|
10619
|
+
var s3 = h2[0], a3 = Object.create(null), o3 = new Set(s3);
|
|
10620
|
+
let n3 = false;
|
|
10621
|
+
for (let r3 = 0;r3 < s3.length; r3++) {
|
|
10622
|
+
let i3 = s3[r3];
|
|
10623
|
+
if (a3[i3 = U(C.transformHeader) ? C.transformHeader(i3, r3) : i3]) {
|
|
10624
|
+
let e3, t2 = a3[i3];
|
|
10625
|
+
for (;e3 = i3 + "_" + t2, t2++, o3.has(e3); )
|
|
10626
|
+
;
|
|
10627
|
+
o3.add(e3), s3[r3] = e3, a3[i3]++, n3 = true, (D = D === null ? {} : D)[e3] = i3;
|
|
10628
|
+
} else
|
|
10629
|
+
a3[i3] = 1, s3[r3] = i3;
|
|
10630
|
+
o3.add(i3);
|
|
10631
|
+
}
|
|
10632
|
+
n3 && console.warn("Duplicate headers found and renamed."), L = true;
|
|
10633
|
+
}
|
|
10634
|
+
return { data: h2, errors: u2, meta: { delimiter: S, linebreak: O, aborted: M, truncated: !!e2, cursor: f2 + (t || 0), renamedHeaders: D } };
|
|
10635
|
+
}
|
|
10636
|
+
function R() {
|
|
10637
|
+
I(w()), h2 = [], u2 = [];
|
|
10638
|
+
}
|
|
10639
|
+
}, this.abort = function() {
|
|
10640
|
+
M = true;
|
|
10641
|
+
}, this.getCharIndex = function() {
|
|
10642
|
+
return z;
|
|
10643
|
+
};
|
|
10644
|
+
}
|
|
10645
|
+
function g(e) {
|
|
10646
|
+
var t = e.data, i2 = o[t.workerId], r2 = false;
|
|
10647
|
+
if (t.error)
|
|
10648
|
+
i2.userError(t.error, t.file);
|
|
10649
|
+
else if (t.results && t.results.data) {
|
|
10650
|
+
var n2 = { abort: function() {
|
|
10651
|
+
r2 = true, _(t.workerId, { data: [], errors: [], meta: { aborted: true } });
|
|
10652
|
+
}, pause: m, resume: m };
|
|
10653
|
+
if (U(i2.userStep)) {
|
|
10654
|
+
for (var s2 = 0;s2 < t.results.data.length && (i2.userStep({ data: t.results.data[s2], errors: t.results.errors, meta: t.results.meta }, n2), !r2); s2++)
|
|
10655
|
+
;
|
|
10656
|
+
delete t.results;
|
|
10657
|
+
} else
|
|
10658
|
+
U(i2.userChunk) && (i2.userChunk(t.results, n2, t.file), delete t.results);
|
|
10659
|
+
}
|
|
10660
|
+
t.finished && !r2 && _(t.workerId, t.results);
|
|
10661
|
+
}
|
|
10662
|
+
function _(e, t) {
|
|
10663
|
+
var i2 = o[e];
|
|
10664
|
+
U(i2.userComplete) && i2.userComplete(t), i2.terminate(), delete o[e];
|
|
10665
|
+
}
|
|
10666
|
+
function m() {
|
|
10667
|
+
throw new Error("Not implemented.");
|
|
10668
|
+
}
|
|
10669
|
+
function b(e) {
|
|
10670
|
+
if (typeof e != "object" || e === null)
|
|
10671
|
+
return e;
|
|
10672
|
+
var t, i2 = Array.isArray(e) ? [] : {};
|
|
10673
|
+
for (t in e)
|
|
10674
|
+
i2[t] = b(e[t]);
|
|
10675
|
+
return i2;
|
|
10676
|
+
}
|
|
10677
|
+
function y(e, t) {
|
|
10678
|
+
return function() {
|
|
10679
|
+
e.apply(t, arguments);
|
|
10680
|
+
};
|
|
10681
|
+
}
|
|
10682
|
+
function U(e) {
|
|
10683
|
+
return typeof e == "function";
|
|
10684
|
+
}
|
|
10685
|
+
return v.parse = function(e, t) {
|
|
10686
|
+
var i2 = (t = t || {}).dynamicTyping || false;
|
|
10687
|
+
U(i2) && (t.dynamicTypingFunction = i2, i2 = {});
|
|
10688
|
+
if (t.dynamicTyping = i2, t.transform = !!U(t.transform) && t.transform, !t.worker || !v.WORKERS_SUPPORTED)
|
|
10689
|
+
return i2 = null, v.NODE_STREAM_INPUT, typeof e == "string" ? (e = ((e2) => e2.charCodeAt(0) !== 65279 ? e2 : e2.slice(1))(e), i2 = new (t.download ? f : c)(t)) : e.readable === true && U(e.read) && U(e.on) ? i2 = new p(t) : (n.File && e instanceof File || e instanceof Object) && (i2 = new l(t)), i2.stream(e);
|
|
10690
|
+
(i2 = (() => {
|
|
10691
|
+
var e2;
|
|
10692
|
+
return !!v.WORKERS_SUPPORTED && (e2 = (() => {
|
|
10693
|
+
var e3 = n.URL || n.webkitURL || null, t2 = r.toString();
|
|
10694
|
+
return v.BLOB_URL || (v.BLOB_URL = e3.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", "(", t2, ")();"], { type: "text/javascript" })));
|
|
10695
|
+
})(), (e2 = new n.Worker(e2)).onmessage = g, e2.id = h++, o[e2.id] = e2);
|
|
10696
|
+
})()).userStep = t.step, i2.userChunk = t.chunk, i2.userComplete = t.complete, i2.userError = t.error, t.step = U(t.step), t.chunk = U(t.chunk), t.complete = U(t.complete), t.error = U(t.error), delete t.worker, i2.postMessage({ input: e, config: t, workerId: i2.id });
|
|
10697
|
+
}, v.unparse = function(e, t) {
|
|
10698
|
+
var n2 = false, _2 = true, m2 = ",", y2 = `\r
|
|
10699
|
+
`, s2 = '"', a2 = s2 + s2, i2 = false, r2 = null, o2 = false, h2 = ((() => {
|
|
10700
|
+
if (typeof t == "object") {
|
|
10701
|
+
if (typeof t.delimiter != "string" || v.BAD_DELIMITERS.filter(function(e2) {
|
|
10702
|
+
return t.delimiter.indexOf(e2) !== -1;
|
|
10703
|
+
}).length || (m2 = t.delimiter), typeof t.quotes != "boolean" && typeof t.quotes != "function" && !Array.isArray(t.quotes) || (n2 = t.quotes), typeof t.skipEmptyLines != "boolean" && typeof t.skipEmptyLines != "string" || (i2 = t.skipEmptyLines), typeof t.newline == "string" && (y2 = t.newline), typeof t.quoteChar == "string" && (s2 = t.quoteChar), typeof t.header == "boolean" && (_2 = t.header), Array.isArray(t.columns)) {
|
|
10704
|
+
if (t.columns.length === 0)
|
|
10705
|
+
throw new Error("Option columns is empty");
|
|
10706
|
+
r2 = t.columns;
|
|
10707
|
+
}
|
|
10708
|
+
t.escapeChar !== undefined && (a2 = t.escapeChar + s2), t.escapeFormulae instanceof RegExp ? o2 = t.escapeFormulae : typeof t.escapeFormulae == "boolean" && t.escapeFormulae && (o2 = /^[=+\-@\t\r].*$/);
|
|
10709
|
+
}
|
|
10710
|
+
})(), new RegExp(P(s2), "g"));
|
|
10711
|
+
typeof e == "string" && (e = JSON.parse(e));
|
|
10712
|
+
if (Array.isArray(e)) {
|
|
10713
|
+
if (!e.length || Array.isArray(e[0]))
|
|
10714
|
+
return u2(null, e, i2);
|
|
10715
|
+
if (typeof e[0] == "object")
|
|
10716
|
+
return u2(r2 || Object.keys(e[0]), e, i2);
|
|
10717
|
+
} else if (typeof e == "object")
|
|
10718
|
+
return typeof e.data == "string" && (e.data = JSON.parse(e.data)), Array.isArray(e.data) && (e.fields || (e.fields = e.meta && e.meta.fields || r2), e.fields || (e.fields = Array.isArray(e.data[0]) ? e.fields : typeof e.data[0] == "object" ? Object.keys(e.data[0]) : []), Array.isArray(e.data[0]) || typeof e.data[0] == "object" || (e.data = [e.data])), u2(e.fields || [], e.data || [], i2);
|
|
10719
|
+
throw new Error("Unable to serialize unrecognized input");
|
|
10720
|
+
function u2(e2, t2, i3) {
|
|
10721
|
+
var r3 = "", n3 = (typeof e2 == "string" && (e2 = JSON.parse(e2)), typeof t2 == "string" && (t2 = JSON.parse(t2)), Array.isArray(e2) && 0 < e2.length), s3 = !Array.isArray(t2[0]);
|
|
10722
|
+
if (n3 && _2) {
|
|
10723
|
+
for (var a3 = 0;a3 < e2.length; a3++)
|
|
10724
|
+
0 < a3 && (r3 += m2), r3 += k(e2[a3], a3);
|
|
10725
|
+
0 < t2.length && (r3 += y2);
|
|
10726
|
+
}
|
|
10727
|
+
for (var o3 = 0;o3 < t2.length; o3++) {
|
|
10728
|
+
var h3 = (n3 ? e2 : t2[o3]).length, u3 = false, d2 = n3 ? Object.keys(t2[o3]).length === 0 : t2[o3].length === 0;
|
|
10729
|
+
if (i3 && !n3 && (u3 = i3 === "greedy" ? t2[o3].join("").trim() === "" : t2[o3].length === 1 && t2[o3][0].length === 0), i3 === "greedy" && n3) {
|
|
10730
|
+
for (var f2 = [], l2 = 0;l2 < h3; l2++) {
|
|
10731
|
+
var c2 = s3 ? e2[l2] : l2;
|
|
10732
|
+
f2.push(t2[o3][c2]);
|
|
10733
|
+
}
|
|
10734
|
+
u3 = f2.join("").trim() === "";
|
|
10735
|
+
}
|
|
10736
|
+
if (!u3) {
|
|
10737
|
+
for (var p2 = 0;p2 < h3; p2++) {
|
|
10738
|
+
0 < p2 && !d2 && (r3 += m2);
|
|
10739
|
+
var g2 = n3 && s3 ? e2[p2] : p2;
|
|
10740
|
+
r3 += k(t2[o3][g2], p2);
|
|
10741
|
+
}
|
|
10742
|
+
o3 < t2.length - 1 && (!i3 || 0 < h3 && !d2) && (r3 += y2);
|
|
10743
|
+
}
|
|
10744
|
+
}
|
|
10745
|
+
return r3;
|
|
10746
|
+
}
|
|
10747
|
+
function k(e2, t2) {
|
|
10748
|
+
var i3, r3;
|
|
10749
|
+
return e2 == null ? "" : e2.constructor === Date ? JSON.stringify(e2).slice(1, 25) : (r3 = false, o2 && typeof e2 == "string" && o2.test(e2) && (e2 = "'" + e2, r3 = true), i3 = e2.toString().replace(h2, a2), (r3 = r3 || n2 === true || typeof n2 == "function" && n2(e2, t2) || Array.isArray(n2) && n2[t2] || ((e3, t3) => {
|
|
10750
|
+
for (var i4 = 0;i4 < t3.length; i4++)
|
|
10751
|
+
if (-1 < e3.indexOf(t3[i4]))
|
|
10752
|
+
return true;
|
|
10753
|
+
return false;
|
|
10754
|
+
})(i3, v.BAD_DELIMITERS) || -1 < i3.indexOf(m2) || i3.charAt(0) === " " || i3.charAt(i3.length - 1) === " ") ? s2 + i3 + s2 : i3);
|
|
10755
|
+
}
|
|
10756
|
+
}, v.RECORD_SEP = String.fromCharCode(30), v.UNIT_SEP = String.fromCharCode(31), v.BYTE_ORDER_MARK = "\uFEFF", v.BAD_DELIMITERS = ["\r", `
|
|
10757
|
+
`, '"', v.BYTE_ORDER_MARK], v.WORKERS_SUPPORTED = !s && !!n.Worker, v.NODE_STREAM_INPUT = 1, v.LocalChunkSize = 10485760, v.RemoteChunkSize = 5242880, v.DefaultDelimiter = ",", v.Parser = E, v.ParserHandle = i, v.NetworkStreamer = f, v.FileStreamer = l, v.StringStreamer = c, v.ReadableStreamStreamer = p, n.jQuery && ((d = n.jQuery).fn.parse = function(o2) {
|
|
10758
|
+
var i2 = o2.config || {}, h2 = [];
|
|
10759
|
+
return this.each(function(e2) {
|
|
10760
|
+
if (!(d(this).prop("tagName").toUpperCase() === "INPUT" && d(this).attr("type").toLowerCase() === "file" && n.FileReader) || !this.files || this.files.length === 0)
|
|
10761
|
+
return true;
|
|
10762
|
+
for (var t = 0;t < this.files.length; t++)
|
|
10763
|
+
h2.push({ file: this.files[t], inputElem: this, instanceConfig: d.extend({}, i2) });
|
|
10764
|
+
}), e(), this;
|
|
10765
|
+
function e() {
|
|
10766
|
+
if (h2.length === 0)
|
|
10767
|
+
U(o2.complete) && o2.complete();
|
|
10768
|
+
else {
|
|
10769
|
+
var e2, t, i3, r2, n2 = h2[0];
|
|
10770
|
+
if (U(o2.before)) {
|
|
10771
|
+
var s2 = o2.before(n2.file, n2.inputElem);
|
|
10772
|
+
if (typeof s2 == "object") {
|
|
10773
|
+
if (s2.action === "abort")
|
|
10774
|
+
return e2 = "AbortError", t = n2.file, i3 = n2.inputElem, r2 = s2.reason, void (U(o2.error) && o2.error({ name: e2 }, t, i3, r2));
|
|
10775
|
+
if (s2.action === "skip")
|
|
10776
|
+
return void u2();
|
|
10777
|
+
typeof s2.config == "object" && (n2.instanceConfig = d.extend(n2.instanceConfig, s2.config));
|
|
10778
|
+
} else if (s2 === "skip")
|
|
10779
|
+
return void u2();
|
|
10780
|
+
}
|
|
10781
|
+
var a2 = n2.instanceConfig.complete;
|
|
10782
|
+
n2.instanceConfig.complete = function(e3) {
|
|
10783
|
+
U(a2) && a2(e3, n2.file, n2.inputElem), u2();
|
|
10784
|
+
}, v.parse(n2.file, n2.instanceConfig);
|
|
10785
|
+
}
|
|
10786
|
+
}
|
|
10787
|
+
function u2() {
|
|
10788
|
+
h2.splice(0, 1), e();
|
|
10789
|
+
}
|
|
10790
|
+
}), a && (n.onmessage = function(e) {
|
|
10791
|
+
e = e.data;
|
|
10792
|
+
v.WORKER_ID === undefined && e && (v.WORKER_ID = e.workerId);
|
|
10793
|
+
typeof e.input == "string" ? n.postMessage({ workerId: v.WORKER_ID, results: v.parse(e.input, e.config), finished: true }) : (n.File && e.input instanceof File || e.input instanceof Object) && (e = v.parse(e.input, e.config)) && n.postMessage({ workerId: v.WORKER_ID, results: e, finished: true });
|
|
10794
|
+
}), (f.prototype = Object.create(u.prototype)).constructor = f, (l.prototype = Object.create(u.prototype)).constructor = l, (c.prototype = Object.create(c.prototype)).constructor = c, (p.prototype = Object.create(u.prototype)).constructor = p, v;
|
|
10795
|
+
});
|
|
10796
|
+
});
|
|
10797
|
+
|
|
10322
10798
|
// src/web.ts
|
|
10323
10799
|
var exports_web = {};
|
|
10324
10800
|
__export(exports_web, {
|
|
10325
10801
|
z: () => exports_external,
|
|
10326
|
-
watch: () => watch,
|
|
10327
10802
|
void: () => voidType,
|
|
10328
10803
|
util: () => util,
|
|
10329
|
-
urlGetPath: () => urlGetPath,
|
|
10330
|
-
url2Params: () => url2Params,
|
|
10331
10804
|
unknown: () => unknownType,
|
|
10332
10805
|
union: () => unionType,
|
|
10333
10806
|
undefined: () => undefinedType,
|
|
10334
10807
|
tuple: () => tupleType,
|
|
10335
10808
|
transformer: () => effectsType,
|
|
10336
|
-
|
|
10809
|
+
transformOptions: () => transformOptions,
|
|
10337
10810
|
symbol: () => symbolType,
|
|
10338
10811
|
string: () => stringType,
|
|
10339
10812
|
strictObject: () => strictObjectType,
|
|
10340
|
-
shuffleArray: () => shuffleArray,
|
|
10341
|
-
setUrlParams: () => setUrlParams,
|
|
10342
10813
|
setErrorMap: () => setErrorMap,
|
|
10343
10814
|
set: () => setType,
|
|
10344
10815
|
scrollIntoView: () => scrollIntoView,
|
|
10816
|
+
safeJsonParse: () => safeJsonParse,
|
|
10345
10817
|
retryPromise: () => retryPromise,
|
|
10346
10818
|
replaceByVariables: () => replaceByVariables,
|
|
10347
10819
|
replaceByRules: () => replaceByRules,
|
|
10348
|
-
replaceAll: () => replaceAll,
|
|
10349
10820
|
removeSimilarDuplicates: () => removeSimilarDuplicates,
|
|
10350
10821
|
record: () => recordType,
|
|
10351
10822
|
readClipboard: () => readClipboard,
|
|
10352
10823
|
quotelessJson: () => quotelessJson,
|
|
10353
10824
|
promise: () => promiseType,
|
|
10354
|
-
|
|
10825
|
+
prettyBytes: () => prettyBytes,
|
|
10355
10826
|
preprocess: () => preprocessType,
|
|
10356
10827
|
pipeline: () => pipelineType,
|
|
10357
|
-
performDecimalOperation: () => performDecimalOperation,
|
|
10358
|
-
params2Url: () => params2Url,
|
|
10359
10828
|
ostring: () => ostring,
|
|
10360
10829
|
optionsToEnum: () => optionsToEnum,
|
|
10830
|
+
options2valueEnum: () => options2valueEnum,
|
|
10361
10831
|
optional: () => optionalType,
|
|
10362
10832
|
onumber: () => onumber,
|
|
10363
10833
|
oboolean: () => oboolean,
|
|
10364
10834
|
objectUtil: () => objectUtil,
|
|
10365
10835
|
object: () => objectType,
|
|
10366
|
-
numberWithCommas: () => numberWithCommas,
|
|
10367
10836
|
number: () => numberType,
|
|
10368
10837
|
nullable: () => nullableType,
|
|
10369
10838
|
null: () => nullType,
|
|
@@ -10373,53 +10842,40 @@ __export(exports_web, {
|
|
|
10373
10842
|
md5: () => import_md5.default,
|
|
10374
10843
|
map: () => mapType,
|
|
10375
10844
|
makeIssue: () => makeIssue,
|
|
10845
|
+
logNetwork: () => logNetwork,
|
|
10376
10846
|
localforage: () => import_localforage.default,
|
|
10377
10847
|
literal: () => literalType,
|
|
10378
|
-
limitDecimals: () => limitDecimals,
|
|
10379
10848
|
levenshteinDistance: () => levenshteinDistance,
|
|
10380
10849
|
lazy: () => lazyType,
|
|
10381
10850
|
late: () => late,
|
|
10382
|
-
jsonParse: () => jsonParse,
|
|
10383
10851
|
json5: () => import_json53.default,
|
|
10384
|
-
isValidNumber: () => isValidNumber,
|
|
10385
10852
|
isValid: () => isValid,
|
|
10386
|
-
|
|
10853
|
+
isJsonObject: () => isJsonObject,
|
|
10387
10854
|
isElementInViewport: () => isElementInViewport,
|
|
10388
10855
|
isDirty: () => isDirty,
|
|
10389
10856
|
isAsync: () => isAsync,
|
|
10390
10857
|
isAborted: () => isAborted,
|
|
10391
10858
|
intersection: () => intersectionType,
|
|
10392
10859
|
instanceof: () => instanceOfType,
|
|
10393
|
-
initChinaDayjs: () => initChinaDayjs,
|
|
10394
|
-
imageToBase64: () => imageToBase64,
|
|
10395
10860
|
hexToRgba: () => hexToRgba2,
|
|
10396
10861
|
getType: () => getType,
|
|
10397
|
-
getTotal: () => getTotal,
|
|
10398
10862
|
getStrLength: () => getStrLength,
|
|
10399
10863
|
getSliceStr: () => getSliceStr,
|
|
10400
10864
|
getRandomString: () => getRandomString,
|
|
10401
|
-
getRandomNum: () => getRandomNum,
|
|
10402
10865
|
getRandomColor: () => getRandomColor,
|
|
10403
10866
|
getPublicUrl: () => getPublicUrl,
|
|
10404
|
-
getProxyUrl: () => getProxyUrl,
|
|
10405
10867
|
getParsedType: () => getParsedType,
|
|
10406
|
-
getLength: () => getLength,
|
|
10407
10868
|
getErrorMap: () => getErrorMap,
|
|
10408
|
-
|
|
10409
|
-
getCookie: () => getCookie,
|
|
10869
|
+
getColumns: () => getColumns,
|
|
10410
10870
|
getChineseByStr: () => getChineseByStr,
|
|
10411
|
-
getChinese: () => getChinese,
|
|
10412
|
-
generateUniqueFileName: () => generateUniqueFileName,
|
|
10413
10871
|
generateAlphabetArray: () => generateAlphabetArray,
|
|
10414
10872
|
function: () => functionType,
|
|
10415
|
-
|
|
10416
|
-
flashBorder: () => flashBorder,
|
|
10417
|
-
flashBackground: () => flashBackground,
|
|
10418
|
-
findItem: () => findItem,
|
|
10873
|
+
findAttr: () => findAttr,
|
|
10419
10874
|
filterParams: () => filterParams,
|
|
10420
10875
|
executePromise: () => executePromise,
|
|
10421
10876
|
enum: () => enumType,
|
|
10422
10877
|
effect: () => effectsType,
|
|
10878
|
+
downloadDataSource: () => downloadDataSource,
|
|
10423
10879
|
discriminatedUnion: () => discriminatedUnionType,
|
|
10424
10880
|
delay: () => delay,
|
|
10425
10881
|
defaultErrorMap: () => en_default,
|
|
@@ -10431,7 +10887,6 @@ __export(exports_web, {
|
|
|
10431
10887
|
consola: () => import_consola.default,
|
|
10432
10888
|
coerce: () => coerce,
|
|
10433
10889
|
classnames: () => import_classnames.default,
|
|
10434
|
-
chinaDayjs: () => chinaDayjs,
|
|
10435
10890
|
calcJsText: () => calcJsText,
|
|
10436
10891
|
boolean: () => booleanType,
|
|
10437
10892
|
bigint: () => bigIntType,
|
|
@@ -10439,7 +10894,6 @@ __export(exports_web, {
|
|
|
10439
10894
|
array: () => arrayType,
|
|
10440
10895
|
any: () => anyType,
|
|
10441
10896
|
anime: () => anime_es_default,
|
|
10442
|
-
amount: () => amount,
|
|
10443
10897
|
ai: () => exports_ai,
|
|
10444
10898
|
addIssueToContext: () => addIssueToContext,
|
|
10445
10899
|
_: () => _,
|
|
@@ -18299,7 +18753,149 @@ var import_consola = __toESM(require_consola_browser(), 1);
|
|
|
18299
18753
|
var import_classnames = __toESM(require_classnames(), 1);
|
|
18300
18754
|
var import_localforage = __toESM(require_localforage(), 1);
|
|
18301
18755
|
var import_copy_to_clipboard = __toESM(require_copy_to_clipboard(), 1);
|
|
18302
|
-
|
|
18756
|
+
|
|
18757
|
+
// ../../node_modules/pretty-bytes/index.js
|
|
18758
|
+
var BYTE_UNITS = [
|
|
18759
|
+
"B",
|
|
18760
|
+
"kB",
|
|
18761
|
+
"MB",
|
|
18762
|
+
"GB",
|
|
18763
|
+
"TB",
|
|
18764
|
+
"PB",
|
|
18765
|
+
"EB",
|
|
18766
|
+
"ZB",
|
|
18767
|
+
"YB"
|
|
18768
|
+
];
|
|
18769
|
+
var BIBYTE_UNITS = [
|
|
18770
|
+
"B",
|
|
18771
|
+
"KiB",
|
|
18772
|
+
"MiB",
|
|
18773
|
+
"GiB",
|
|
18774
|
+
"TiB",
|
|
18775
|
+
"PiB",
|
|
18776
|
+
"EiB",
|
|
18777
|
+
"ZiB",
|
|
18778
|
+
"YiB"
|
|
18779
|
+
];
|
|
18780
|
+
var BIT_UNITS = [
|
|
18781
|
+
"b",
|
|
18782
|
+
"kbit",
|
|
18783
|
+
"Mbit",
|
|
18784
|
+
"Gbit",
|
|
18785
|
+
"Tbit",
|
|
18786
|
+
"Pbit",
|
|
18787
|
+
"Ebit",
|
|
18788
|
+
"Zbit",
|
|
18789
|
+
"Ybit"
|
|
18790
|
+
];
|
|
18791
|
+
var BIBIT_UNITS = [
|
|
18792
|
+
"b",
|
|
18793
|
+
"kibit",
|
|
18794
|
+
"Mibit",
|
|
18795
|
+
"Gibit",
|
|
18796
|
+
"Tibit",
|
|
18797
|
+
"Pibit",
|
|
18798
|
+
"Eibit",
|
|
18799
|
+
"Zibit",
|
|
18800
|
+
"Yibit"
|
|
18801
|
+
];
|
|
18802
|
+
var toLocaleString = (number, locale, options) => {
|
|
18803
|
+
let result = number;
|
|
18804
|
+
if (typeof locale === "string" || Array.isArray(locale)) {
|
|
18805
|
+
result = number.toLocaleString(locale, options);
|
|
18806
|
+
} else if (locale === true || options !== undefined) {
|
|
18807
|
+
result = number.toLocaleString(undefined, options);
|
|
18808
|
+
}
|
|
18809
|
+
return result;
|
|
18810
|
+
};
|
|
18811
|
+
var log10 = (numberOrBigInt) => {
|
|
18812
|
+
if (typeof numberOrBigInt === "number") {
|
|
18813
|
+
return Math.log10(numberOrBigInt);
|
|
18814
|
+
}
|
|
18815
|
+
const string = numberOrBigInt.toString(10);
|
|
18816
|
+
return string.length + Math.log10(`0.${string.slice(0, 15)}`);
|
|
18817
|
+
};
|
|
18818
|
+
var log = (numberOrBigInt) => {
|
|
18819
|
+
if (typeof numberOrBigInt === "number") {
|
|
18820
|
+
return Math.log(numberOrBigInt);
|
|
18821
|
+
}
|
|
18822
|
+
return log10(numberOrBigInt) * Math.log(10);
|
|
18823
|
+
};
|
|
18824
|
+
var divide = (numberOrBigInt, divisor) => {
|
|
18825
|
+
if (typeof numberOrBigInt === "number") {
|
|
18826
|
+
return numberOrBigInt / divisor;
|
|
18827
|
+
}
|
|
18828
|
+
const integerPart = numberOrBigInt / BigInt(divisor);
|
|
18829
|
+
const remainder = numberOrBigInt % BigInt(divisor);
|
|
18830
|
+
return Number(integerPart) + Number(remainder) / divisor;
|
|
18831
|
+
};
|
|
18832
|
+
var applyFixedWidth = (result, fixedWidth) => {
|
|
18833
|
+
if (fixedWidth === undefined) {
|
|
18834
|
+
return result;
|
|
18835
|
+
}
|
|
18836
|
+
if (typeof fixedWidth !== "number" || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) {
|
|
18837
|
+
throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
|
|
18838
|
+
}
|
|
18839
|
+
if (fixedWidth === 0) {
|
|
18840
|
+
return result;
|
|
18841
|
+
}
|
|
18842
|
+
return result.length < fixedWidth ? result.padStart(fixedWidth, " ") : result;
|
|
18843
|
+
};
|
|
18844
|
+
var buildLocaleOptions = (options) => {
|
|
18845
|
+
const { minimumFractionDigits, maximumFractionDigits } = options;
|
|
18846
|
+
if (minimumFractionDigits === undefined && maximumFractionDigits === undefined) {
|
|
18847
|
+
return;
|
|
18848
|
+
}
|
|
18849
|
+
return {
|
|
18850
|
+
...minimumFractionDigits !== undefined && { minimumFractionDigits },
|
|
18851
|
+
...maximumFractionDigits !== undefined && { maximumFractionDigits },
|
|
18852
|
+
roundingMode: "trunc"
|
|
18853
|
+
};
|
|
18854
|
+
};
|
|
18855
|
+
function prettyBytes(number, options) {
|
|
18856
|
+
if (typeof number !== "bigint" && !Number.isFinite(number)) {
|
|
18857
|
+
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
18858
|
+
}
|
|
18859
|
+
options = {
|
|
18860
|
+
bits: false,
|
|
18861
|
+
binary: false,
|
|
18862
|
+
space: true,
|
|
18863
|
+
nonBreakingSpace: false,
|
|
18864
|
+
...options
|
|
18865
|
+
};
|
|
18866
|
+
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
18867
|
+
const separator = options.space ? options.nonBreakingSpace ? " " : " " : "";
|
|
18868
|
+
const isZero = typeof number === "number" ? number === 0 : number === 0n;
|
|
18869
|
+
if (options.signed && isZero) {
|
|
18870
|
+
const result2 = ` 0${separator}${UNITS[0]}`;
|
|
18871
|
+
return applyFixedWidth(result2, options.fixedWidth);
|
|
18872
|
+
}
|
|
18873
|
+
const isNegative = number < 0;
|
|
18874
|
+
const prefix = isNegative ? "-" : options.signed ? "+" : "";
|
|
18875
|
+
if (isNegative) {
|
|
18876
|
+
number = -number;
|
|
18877
|
+
}
|
|
18878
|
+
const localeOptions = buildLocaleOptions(options);
|
|
18879
|
+
let result;
|
|
18880
|
+
if (number < 1) {
|
|
18881
|
+
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
18882
|
+
result = prefix + numberString + separator + UNITS[0];
|
|
18883
|
+
} else {
|
|
18884
|
+
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
|
18885
|
+
number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
|
|
18886
|
+
if (!localeOptions) {
|
|
18887
|
+
const minPrecision = Math.max(3, Math.floor(number).toString().length);
|
|
18888
|
+
number = number.toPrecision(minPrecision);
|
|
18889
|
+
}
|
|
18890
|
+
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
18891
|
+
const unit = UNITS[exponent];
|
|
18892
|
+
result = prefix + numberString + separator + unit;
|
|
18893
|
+
}
|
|
18894
|
+
return applyFixedWidth(result, options.fixedWidth);
|
|
18895
|
+
}
|
|
18896
|
+
|
|
18897
|
+
// src/web.ts
|
|
18898
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
18303
18899
|
|
|
18304
18900
|
// src/common/ai/index.ts
|
|
18305
18901
|
var exports_ai = {};
|
|
@@ -19739,16 +20335,6 @@ var getStrLength = (value) => {
|
|
|
19739
20335
|
const chineseLength = getChineseByStr(value).length;
|
|
19740
20336
|
return value.length - chineseLength + chineseLength * 2;
|
|
19741
20337
|
};
|
|
19742
|
-
var replaceAll = (str, searchValue, replaceValue) => {
|
|
19743
|
-
if (!str || !searchValue || !replaceValue) {
|
|
19744
|
-
return str || "";
|
|
19745
|
-
}
|
|
19746
|
-
str = str.replace(searchValue, replaceValue);
|
|
19747
|
-
if (!str.includes(searchValue)) {
|
|
19748
|
-
return str;
|
|
19749
|
-
}
|
|
19750
|
-
return replaceAll(str, searchValue, replaceValue);
|
|
19751
|
-
};
|
|
19752
20338
|
var replaceByRules = (str, rules) => {
|
|
19753
20339
|
rules.forEach(([searchValue, replaceValue]) => {
|
|
19754
20340
|
str = str.replaceAll(searchValue, replaceValue);
|
|
@@ -19767,67 +20353,46 @@ var replaceByVariables = (prompt, variables) => {
|
|
|
19767
20353
|
var getType = (value) => {
|
|
19768
20354
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
19769
20355
|
};
|
|
19770
|
-
var
|
|
19771
|
-
|
|
19772
|
-
|
|
19773
|
-
};
|
|
19774
|
-
var jsonParse = (value) => {
|
|
19775
|
-
if (typeof value === "object") {
|
|
19776
|
-
return value;
|
|
20356
|
+
var safeJsonParse = (value, fallback) => {
|
|
20357
|
+
if (typeof value !== "string") {
|
|
20358
|
+
return value ?? fallback;
|
|
19777
20359
|
}
|
|
19778
20360
|
try {
|
|
19779
20361
|
return JSON.parse(value);
|
|
19780
|
-
} catch
|
|
19781
|
-
return
|
|
20362
|
+
} catch {
|
|
20363
|
+
return fallback;
|
|
19782
20364
|
}
|
|
19783
20365
|
};
|
|
19784
|
-
var
|
|
20366
|
+
var isJsonObject = (str) => {
|
|
19785
20367
|
try {
|
|
19786
|
-
|
|
19787
|
-
|
|
19788
|
-
|
|
19789
|
-
|
|
19790
|
-
|
|
19791
|
-
};
|
|
19792
|
-
var toString3 = (value) => {
|
|
19793
|
-
return Object.prototype.toString.call(value).slice(8, -1) === "object" ? JSON.stringify(value) : String(value);
|
|
20368
|
+
const val = JSON.parse(str);
|
|
20369
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
20370
|
+
} catch {
|
|
20371
|
+
return false;
|
|
20372
|
+
}
|
|
19794
20373
|
};
|
|
19795
20374
|
var getRandomColor = () => {
|
|
19796
|
-
const
|
|
19797
|
-
|
|
19798
|
-
return color;
|
|
19799
|
-
} else {
|
|
19800
|
-
return getRandomColor();
|
|
19801
|
-
}
|
|
20375
|
+
const rand = () => Math.floor(Math.random() * 156 + 50);
|
|
20376
|
+
return `rgb(${rand()},${rand()},${rand()})`;
|
|
19802
20377
|
};
|
|
19803
|
-
var
|
|
19804
|
-
|
|
20378
|
+
var hexToRgba2 = (hexColor, a = 1) => {
|
|
20379
|
+
let red = parseInt(hexColor.substr(1, 2), 16);
|
|
20380
|
+
let green = parseInt(hexColor.substr(3, 2), 16);
|
|
20381
|
+
let blue = parseInt(hexColor.substr(5, 2), 16);
|
|
20382
|
+
return {
|
|
20383
|
+
nums: { red, green, blue },
|
|
20384
|
+
text: `rgba(${red}, ${green}, ${blue}, ${a})`
|
|
20385
|
+
};
|
|
19805
20386
|
};
|
|
19806
|
-
var
|
|
19807
|
-
|
|
19808
|
-
return "";
|
|
19809
|
-
}
|
|
19810
|
-
const res = str.match(/[\u4e00-\u9fa5]/g);
|
|
19811
|
-
if (!res) {
|
|
19812
|
-
return "";
|
|
19813
|
-
}
|
|
19814
|
-
return res.join("");
|
|
20387
|
+
var getRandomString = (length = 4) => {
|
|
20388
|
+
return Math.random().toString(36).substring(2, 2 + length);
|
|
19815
20389
|
};
|
|
19816
20390
|
var getSliceStr = (str, before, after) => {
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
return
|
|
19822
|
-
};
|
|
19823
|
-
var getLength = (value) => {
|
|
19824
|
-
const chineseLength = getChinese(value).length;
|
|
19825
|
-
return value.length - chineseLength + chineseLength * 2;
|
|
19826
|
-
};
|
|
19827
|
-
var getCookie = (name) => {
|
|
19828
|
-
const reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
|
|
19829
|
-
const arr = document.cookie.match(reg);
|
|
19830
|
-
return arr ? unescape(arr[2]) : null;
|
|
20391
|
+
const start = str.indexOf(before);
|
|
20392
|
+
const end = str.indexOf(after, start + before.length);
|
|
20393
|
+
if (start === -1 || end === -1)
|
|
20394
|
+
return "";
|
|
20395
|
+
return str.slice(start + before.length, end);
|
|
19831
20396
|
};
|
|
19832
20397
|
var generateAlphabetArray = (n) => {
|
|
19833
20398
|
return Array.from({ length: n }, (_, i) => String.fromCharCode(97 + i));
|
|
@@ -19851,2553 +20416,126 @@ var levenshteinDistance = (a, b) => {
|
|
|
19851
20416
|
}
|
|
19852
20417
|
return matrix[b.length][a.length];
|
|
19853
20418
|
};
|
|
19854
|
-
|
|
19855
|
-
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
|
|
19859
|
-
|
|
19860
|
-
|
|
20419
|
+
|
|
20420
|
+
// src/common/base/array.ts
|
|
20421
|
+
var removeSimilarDuplicates = (arr, threshold, isLog) => {
|
|
20422
|
+
const uniqueArray = [];
|
|
20423
|
+
const similarPairs = [];
|
|
20424
|
+
for (const str of arr) {
|
|
20425
|
+
const isSimilar = uniqueArray.some((uniqueStr) => {
|
|
20426
|
+
const distance = levenshteinDistance(str, uniqueStr);
|
|
20427
|
+
if (distance <= threshold) {
|
|
20428
|
+
similarPairs.push([str, uniqueStr]);
|
|
20429
|
+
return true;
|
|
20430
|
+
}
|
|
20431
|
+
return false;
|
|
20432
|
+
});
|
|
20433
|
+
if (!isSimilar) {
|
|
20434
|
+
uniqueArray.push(str);
|
|
20435
|
+
}
|
|
20436
|
+
}
|
|
20437
|
+
if (isLog) {
|
|
20438
|
+
if (similarPairs.length > 0) {
|
|
20439
|
+
similarPairs.forEach((pair) => {
|
|
20440
|
+
console.log(pair[0]);
|
|
20441
|
+
console.log(pair[1]);
|
|
20442
|
+
console.log();
|
|
20443
|
+
});
|
|
19861
20444
|
} else {
|
|
19862
|
-
|
|
20445
|
+
console.log("没有找到类似的字符串");
|
|
19863
20446
|
}
|
|
19864
20447
|
}
|
|
19865
|
-
|
|
20448
|
+
return uniqueArray;
|
|
19866
20449
|
};
|
|
19867
20450
|
|
|
19868
|
-
//
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
|
|
19875
|
-
*/
|
|
19876
|
-
var EXP_LIMIT = 9000000000000000;
|
|
19877
|
-
var MAX_DIGITS = 1e9;
|
|
19878
|
-
var NUMERALS = "0123456789abcdef";
|
|
19879
|
-
var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
|
|
19880
|
-
var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
|
|
19881
|
-
var DEFAULTS = {
|
|
19882
|
-
precision: 20,
|
|
19883
|
-
rounding: 4,
|
|
19884
|
-
modulo: 1,
|
|
19885
|
-
toExpNeg: -7,
|
|
19886
|
-
toExpPos: 21,
|
|
19887
|
-
minE: -EXP_LIMIT,
|
|
19888
|
-
maxE: EXP_LIMIT,
|
|
19889
|
-
crypto: false
|
|
19890
|
-
};
|
|
19891
|
-
var inexact;
|
|
19892
|
-
var quadrant;
|
|
19893
|
-
var external2 = true;
|
|
19894
|
-
var decimalError = "[DecimalError] ";
|
|
19895
|
-
var invalidArgument = decimalError + "Invalid argument: ";
|
|
19896
|
-
var precisionLimitExceeded = decimalError + "Precision limit exceeded";
|
|
19897
|
-
var cryptoUnavailable = decimalError + "crypto unavailable";
|
|
19898
|
-
var tag = "[object Decimal]";
|
|
19899
|
-
var mathfloor = Math.floor;
|
|
19900
|
-
var mathpow = Math.pow;
|
|
19901
|
-
var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
|
|
19902
|
-
var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
|
|
19903
|
-
var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
|
|
19904
|
-
var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
19905
|
-
var BASE = 1e7;
|
|
19906
|
-
var LOG_BASE = 7;
|
|
19907
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
19908
|
-
var LN10_PRECISION = LN10.length - 1;
|
|
19909
|
-
var PI_PRECISION = PI.length - 1;
|
|
19910
|
-
var P = { toStringTag: tag };
|
|
19911
|
-
P.absoluteValue = P.abs = function() {
|
|
19912
|
-
var x = new this.constructor(this);
|
|
19913
|
-
if (x.s < 0)
|
|
19914
|
-
x.s = 1;
|
|
19915
|
-
return finalise(x);
|
|
19916
|
-
};
|
|
19917
|
-
P.ceil = function() {
|
|
19918
|
-
return finalise(new this.constructor(this), this.e + 1, 2);
|
|
19919
|
-
};
|
|
19920
|
-
P.clampedTo = P.clamp = function(min, max) {
|
|
19921
|
-
var k, x = this, Ctor = x.constructor;
|
|
19922
|
-
min = new Ctor(min);
|
|
19923
|
-
max = new Ctor(max);
|
|
19924
|
-
if (!min.s || !max.s)
|
|
19925
|
-
return new Ctor(NaN);
|
|
19926
|
-
if (min.gt(max))
|
|
19927
|
-
throw Error(invalidArgument + max);
|
|
19928
|
-
k = x.cmp(min);
|
|
19929
|
-
return k < 0 ? min : x.cmp(max) > 0 ? max : new Ctor(x);
|
|
19930
|
-
};
|
|
19931
|
-
P.comparedTo = P.cmp = function(y) {
|
|
19932
|
-
var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
|
|
19933
|
-
if (!xd || !yd) {
|
|
19934
|
-
return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
|
|
19935
|
-
}
|
|
19936
|
-
if (!xd[0] || !yd[0])
|
|
19937
|
-
return xd[0] ? xs : yd[0] ? -ys : 0;
|
|
19938
|
-
if (xs !== ys)
|
|
19939
|
-
return xs;
|
|
19940
|
-
if (x.e !== y.e)
|
|
19941
|
-
return x.e > y.e ^ xs < 0 ? 1 : -1;
|
|
19942
|
-
xdL = xd.length;
|
|
19943
|
-
ydL = yd.length;
|
|
19944
|
-
for (i = 0, j = xdL < ydL ? xdL : ydL;i < j; ++i) {
|
|
19945
|
-
if (xd[i] !== yd[i])
|
|
19946
|
-
return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
|
|
19947
|
-
}
|
|
19948
|
-
return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
|
|
19949
|
-
};
|
|
19950
|
-
P.cosine = P.cos = function() {
|
|
19951
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
19952
|
-
if (!x.d)
|
|
19953
|
-
return new Ctor(NaN);
|
|
19954
|
-
if (!x.d[0])
|
|
19955
|
-
return new Ctor(1);
|
|
19956
|
-
pr = Ctor.precision;
|
|
19957
|
-
rm = Ctor.rounding;
|
|
19958
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
19959
|
-
Ctor.rounding = 1;
|
|
19960
|
-
x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
19961
|
-
Ctor.precision = pr;
|
|
19962
|
-
Ctor.rounding = rm;
|
|
19963
|
-
return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
|
|
19964
|
-
};
|
|
19965
|
-
P.cubeRoot = P.cbrt = function() {
|
|
19966
|
-
var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
|
|
19967
|
-
if (!x.isFinite() || x.isZero())
|
|
19968
|
-
return new Ctor(x);
|
|
19969
|
-
external2 = false;
|
|
19970
|
-
s = x.s * mathpow(x.s * x, 1 / 3);
|
|
19971
|
-
if (!s || Math.abs(s) == 1 / 0) {
|
|
19972
|
-
n = digitsToString(x.d);
|
|
19973
|
-
e = x.e;
|
|
19974
|
-
if (s = (e - n.length + 1) % 3)
|
|
19975
|
-
n += s == 1 || s == -2 ? "0" : "00";
|
|
19976
|
-
s = mathpow(n, 1 / 3);
|
|
19977
|
-
e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
|
|
19978
|
-
if (s == 1 / 0) {
|
|
19979
|
-
n = "5e" + e;
|
|
19980
|
-
} else {
|
|
19981
|
-
n = s.toExponential();
|
|
19982
|
-
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
20451
|
+
// src/common/base/object.ts
|
|
20452
|
+
var findAttr = (data, target, path = "data") => {
|
|
20453
|
+
if (Array.isArray(data)) {
|
|
20454
|
+
for (let i = 0;i < data.length; i++) {
|
|
20455
|
+
const res = findAttr(data[i], target, `${path}[${i}]`);
|
|
20456
|
+
if (res)
|
|
20457
|
+
return res;
|
|
19983
20458
|
}
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
t3 = t.times(t).times(t);
|
|
19993
|
-
t3plusx = t3.plus(x);
|
|
19994
|
-
r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
|
|
19995
|
-
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
19996
|
-
n = n.slice(sd - 3, sd + 1);
|
|
19997
|
-
if (n == "9999" || !rep && n == "4999") {
|
|
19998
|
-
if (!rep) {
|
|
19999
|
-
finalise(t, e + 1, 0);
|
|
20000
|
-
if (t.times(t).times(t).eq(x)) {
|
|
20001
|
-
r = t;
|
|
20002
|
-
break;
|
|
20003
|
-
}
|
|
20004
|
-
}
|
|
20005
|
-
sd += 4;
|
|
20006
|
-
rep = 1;
|
|
20007
|
-
} else {
|
|
20008
|
-
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
20009
|
-
finalise(r, e + 1, 1);
|
|
20010
|
-
m = !r.times(r).times(r).eq(x);
|
|
20011
|
-
}
|
|
20012
|
-
break;
|
|
20013
|
-
}
|
|
20459
|
+
}
|
|
20460
|
+
if (data && typeof data === "object") {
|
|
20461
|
+
if (target in data)
|
|
20462
|
+
return `${path}.${target}`;
|
|
20463
|
+
for (const key2 in data) {
|
|
20464
|
+
const res = findAttr(data[key2], target, `${path}.${key2}`);
|
|
20465
|
+
if (res)
|
|
20466
|
+
return res;
|
|
20014
20467
|
}
|
|
20015
20468
|
}
|
|
20016
|
-
|
|
20017
|
-
return finalise(r, e, Ctor.rounding, m);
|
|
20018
|
-
};
|
|
20019
|
-
P.decimalPlaces = P.dp = function() {
|
|
20020
|
-
var w, d = this.d, n = NaN;
|
|
20021
|
-
if (d) {
|
|
20022
|
-
w = d.length - 1;
|
|
20023
|
-
n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
|
20024
|
-
w = d[w];
|
|
20025
|
-
if (w)
|
|
20026
|
-
for (;w % 10 == 0; w /= 10)
|
|
20027
|
-
n--;
|
|
20028
|
-
if (n < 0)
|
|
20029
|
-
n = 0;
|
|
20030
|
-
}
|
|
20031
|
-
return n;
|
|
20032
|
-
};
|
|
20033
|
-
P.dividedBy = P.div = function(y) {
|
|
20034
|
-
return divide(this, new this.constructor(y));
|
|
20035
|
-
};
|
|
20036
|
-
P.dividedToIntegerBy = P.divToInt = function(y) {
|
|
20037
|
-
var x = this, Ctor = x.constructor;
|
|
20038
|
-
return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
|
|
20039
|
-
};
|
|
20040
|
-
P.equals = P.eq = function(y) {
|
|
20041
|
-
return this.cmp(y) === 0;
|
|
20469
|
+
return null;
|
|
20042
20470
|
};
|
|
20043
|
-
|
|
20044
|
-
|
|
20471
|
+
var filterParams = (params, deep = false) => {
|
|
20472
|
+
const clean = (value) => {
|
|
20473
|
+
if (value === undefined || value === null) {
|
|
20474
|
+
return;
|
|
20475
|
+
}
|
|
20476
|
+
if (!deep) {
|
|
20477
|
+
return value;
|
|
20478
|
+
}
|
|
20479
|
+
if (Array.isArray(value)) {
|
|
20480
|
+
return value.map((v) => clean(v)).filter((v) => v !== undefined);
|
|
20481
|
+
}
|
|
20482
|
+
if (typeof value === "object") {
|
|
20483
|
+
return Object.entries(value).reduce((acc, [k, v]) => {
|
|
20484
|
+
const cleaned = clean(v);
|
|
20485
|
+
if (cleaned !== undefined)
|
|
20486
|
+
acc[k] = cleaned;
|
|
20487
|
+
return acc;
|
|
20488
|
+
}, {});
|
|
20489
|
+
}
|
|
20490
|
+
return value;
|
|
20491
|
+
};
|
|
20492
|
+
return clean(params);
|
|
20045
20493
|
};
|
|
20046
|
-
|
|
20047
|
-
|
|
20494
|
+
|
|
20495
|
+
// src/common/base/other.ts
|
|
20496
|
+
var delay = (time = 1000) => {
|
|
20497
|
+
return new Promise((resolve2) => setTimeout(resolve2, time));
|
|
20048
20498
|
};
|
|
20049
|
-
|
|
20050
|
-
|
|
20051
|
-
|
|
20499
|
+
var calcJsText = (expr, context) => {
|
|
20500
|
+
const keys = Object.keys(context);
|
|
20501
|
+
const values = keys.map((key2) => context[key2]);
|
|
20502
|
+
return Function(...keys, `return (${expr})`)(...values);
|
|
20052
20503
|
};
|
|
20053
|
-
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
Ctor.rounding = 1;
|
|
20063
|
-
len = x.d.length;
|
|
20064
|
-
if (len < 32) {
|
|
20065
|
-
k = Math.ceil(len / 3);
|
|
20066
|
-
n = (1 / tinyPow(4, k)).toString();
|
|
20067
|
-
} else {
|
|
20068
|
-
k = 16;
|
|
20069
|
-
n = "2.3283064365386962890625e-10";
|
|
20504
|
+
var logNetwork = (type, path, params, response) => {
|
|
20505
|
+
const styles = {
|
|
20506
|
+
header: "color: #fff; background: #35495e; padding: 2px 8px; border-radius: 3px 0 0 3px;",
|
|
20507
|
+
value: "color: #35495e; background: #f0f4f8; padding: 2px 6px; border-radius: 0 3px 3px 0;",
|
|
20508
|
+
separator: "color: #409EFF; margin: 0 4px;"
|
|
20509
|
+
};
|
|
20510
|
+
console.groupCollapsed(`666 %c${type}%c${path}`, styles.header, styles.value);
|
|
20511
|
+
if (params) {
|
|
20512
|
+
console.table(params);
|
|
20070
20513
|
}
|
|
20071
|
-
|
|
20072
|
-
|
|
20073
|
-
for (;i--; ) {
|
|
20074
|
-
cosh2_x = x.times(x);
|
|
20075
|
-
x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
|
|
20514
|
+
if (response) {
|
|
20515
|
+
console.table(response);
|
|
20076
20516
|
}
|
|
20077
|
-
|
|
20078
|
-
};
|
|
20079
|
-
P.hyperbolicSine = P.sinh = function() {
|
|
20080
|
-
var k, pr, rm, len, x = this, Ctor = x.constructor;
|
|
20081
|
-
if (!x.isFinite() || x.isZero())
|
|
20082
|
-
return new Ctor(x);
|
|
20083
|
-
pr = Ctor.precision;
|
|
20084
|
-
rm = Ctor.rounding;
|
|
20085
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
20086
|
-
Ctor.rounding = 1;
|
|
20087
|
-
len = x.d.length;
|
|
20088
|
-
if (len < 3) {
|
|
20089
|
-
x = taylorSeries(Ctor, 2, x, x, true);
|
|
20090
|
-
} else {
|
|
20091
|
-
k = 1.4 * Math.sqrt(len);
|
|
20092
|
-
k = k > 16 ? 16 : k | 0;
|
|
20093
|
-
x = x.times(1 / tinyPow(5, k));
|
|
20094
|
-
x = taylorSeries(Ctor, 2, x, x, true);
|
|
20095
|
-
var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
20096
|
-
for (;k--; ) {
|
|
20097
|
-
sinh2_x = x.times(x);
|
|
20098
|
-
x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
|
|
20099
|
-
}
|
|
20100
|
-
}
|
|
20101
|
-
Ctor.precision = pr;
|
|
20102
|
-
Ctor.rounding = rm;
|
|
20103
|
-
return finalise(x, pr, rm, true);
|
|
20104
|
-
};
|
|
20105
|
-
P.hyperbolicTangent = P.tanh = function() {
|
|
20106
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
20107
|
-
if (!x.isFinite())
|
|
20108
|
-
return new Ctor(x.s);
|
|
20109
|
-
if (x.isZero())
|
|
20110
|
-
return new Ctor(x);
|
|
20111
|
-
pr = Ctor.precision;
|
|
20112
|
-
rm = Ctor.rounding;
|
|
20113
|
-
Ctor.precision = pr + 7;
|
|
20114
|
-
Ctor.rounding = 1;
|
|
20115
|
-
return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
|
|
20116
|
-
};
|
|
20117
|
-
P.inverseCosine = P.acos = function() {
|
|
20118
|
-
var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
|
|
20119
|
-
if (k !== -1) {
|
|
20120
|
-
return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
|
|
20121
|
-
}
|
|
20122
|
-
if (x.isZero())
|
|
20123
|
-
return getPi(Ctor, pr + 4, rm).times(0.5);
|
|
20124
|
-
Ctor.precision = pr + 6;
|
|
20125
|
-
Ctor.rounding = 1;
|
|
20126
|
-
x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
|
|
20127
|
-
Ctor.precision = pr;
|
|
20128
|
-
Ctor.rounding = rm;
|
|
20129
|
-
return x.times(2);
|
|
20130
|
-
};
|
|
20131
|
-
P.inverseHyperbolicCosine = P.acosh = function() {
|
|
20132
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
20133
|
-
if (x.lte(1))
|
|
20134
|
-
return new Ctor(x.eq(1) ? 0 : NaN);
|
|
20135
|
-
if (!x.isFinite())
|
|
20136
|
-
return new Ctor(x);
|
|
20137
|
-
pr = Ctor.precision;
|
|
20138
|
-
rm = Ctor.rounding;
|
|
20139
|
-
Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
|
|
20140
|
-
Ctor.rounding = 1;
|
|
20141
|
-
external2 = false;
|
|
20142
|
-
x = x.times(x).minus(1).sqrt().plus(x);
|
|
20143
|
-
external2 = true;
|
|
20144
|
-
Ctor.precision = pr;
|
|
20145
|
-
Ctor.rounding = rm;
|
|
20146
|
-
return x.ln();
|
|
20147
|
-
};
|
|
20148
|
-
P.inverseHyperbolicSine = P.asinh = function() {
|
|
20149
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
20150
|
-
if (!x.isFinite() || x.isZero())
|
|
20151
|
-
return new Ctor(x);
|
|
20152
|
-
pr = Ctor.precision;
|
|
20153
|
-
rm = Ctor.rounding;
|
|
20154
|
-
Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
|
|
20155
|
-
Ctor.rounding = 1;
|
|
20156
|
-
external2 = false;
|
|
20157
|
-
x = x.times(x).plus(1).sqrt().plus(x);
|
|
20158
|
-
external2 = true;
|
|
20159
|
-
Ctor.precision = pr;
|
|
20160
|
-
Ctor.rounding = rm;
|
|
20161
|
-
return x.ln();
|
|
20162
|
-
};
|
|
20163
|
-
P.inverseHyperbolicTangent = P.atanh = function() {
|
|
20164
|
-
var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
|
|
20165
|
-
if (!x.isFinite())
|
|
20166
|
-
return new Ctor(NaN);
|
|
20167
|
-
if (x.e >= 0)
|
|
20168
|
-
return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
|
|
20169
|
-
pr = Ctor.precision;
|
|
20170
|
-
rm = Ctor.rounding;
|
|
20171
|
-
xsd = x.sd();
|
|
20172
|
-
if (Math.max(xsd, pr) < 2 * -x.e - 1)
|
|
20173
|
-
return finalise(new Ctor(x), pr, rm, true);
|
|
20174
|
-
Ctor.precision = wpr = xsd - x.e;
|
|
20175
|
-
x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
|
|
20176
|
-
Ctor.precision = pr + 4;
|
|
20177
|
-
Ctor.rounding = 1;
|
|
20178
|
-
x = x.ln();
|
|
20179
|
-
Ctor.precision = pr;
|
|
20180
|
-
Ctor.rounding = rm;
|
|
20181
|
-
return x.times(0.5);
|
|
20517
|
+
console.groupEnd();
|
|
20182
20518
|
};
|
|
20183
|
-
|
|
20184
|
-
|
|
20185
|
-
|
|
20186
|
-
|
|
20187
|
-
|
|
20188
|
-
|
|
20189
|
-
|
|
20190
|
-
|
|
20191
|
-
|
|
20192
|
-
|
|
20193
|
-
halfPi.s = x.s;
|
|
20194
|
-
return halfPi;
|
|
20195
|
-
}
|
|
20196
|
-
return new Ctor(NaN);
|
|
20197
|
-
}
|
|
20198
|
-
Ctor.precision = pr + 6;
|
|
20199
|
-
Ctor.rounding = 1;
|
|
20200
|
-
x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
|
|
20201
|
-
Ctor.precision = pr;
|
|
20202
|
-
Ctor.rounding = rm;
|
|
20203
|
-
return x.times(2);
|
|
20519
|
+
|
|
20520
|
+
// src/common/base/promise.ts
|
|
20521
|
+
var executePromise = async (promise) => {
|
|
20522
|
+
const start = Date.now();
|
|
20523
|
+
const result = await promise;
|
|
20524
|
+
const time = Date.now() - start;
|
|
20525
|
+
return {
|
|
20526
|
+
result,
|
|
20527
|
+
time
|
|
20528
|
+
};
|
|
20204
20529
|
};
|
|
20205
|
-
|
|
20206
|
-
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
|
|
20210
|
-
|
|
20211
|
-
|
|
20212
|
-
|
|
20213
|
-
|
|
20214
|
-
}
|
|
20215
|
-
} else if (x.isZero()) {
|
|
20216
|
-
return new Ctor(x);
|
|
20217
|
-
} else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
|
|
20218
|
-
r = getPi(Ctor, pr + 4, rm).times(0.25);
|
|
20219
|
-
r.s = x.s;
|
|
20220
|
-
return r;
|
|
20221
|
-
}
|
|
20222
|
-
Ctor.precision = wpr = pr + 10;
|
|
20223
|
-
Ctor.rounding = 1;
|
|
20224
|
-
k = Math.min(28, wpr / LOG_BASE + 2 | 0);
|
|
20225
|
-
for (i = k;i; --i)
|
|
20226
|
-
x = x.div(x.times(x).plus(1).sqrt().plus(1));
|
|
20227
|
-
external2 = false;
|
|
20228
|
-
j = Math.ceil(wpr / LOG_BASE);
|
|
20229
|
-
n = 1;
|
|
20230
|
-
x2 = x.times(x);
|
|
20231
|
-
r = new Ctor(x);
|
|
20232
|
-
px = x;
|
|
20233
|
-
for (;i !== -1; ) {
|
|
20234
|
-
px = px.times(x2);
|
|
20235
|
-
t = r.minus(px.div(n += 2));
|
|
20236
|
-
px = px.times(x2);
|
|
20237
|
-
r = t.plus(px.div(n += 2));
|
|
20238
|
-
if (r.d[j] !== undefined)
|
|
20239
|
-
for (i = j;r.d[i] === t.d[i] && i--; )
|
|
20240
|
-
;
|
|
20241
|
-
}
|
|
20242
|
-
if (k)
|
|
20243
|
-
r = r.times(2 << k - 1);
|
|
20244
|
-
external2 = true;
|
|
20245
|
-
return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
20246
|
-
};
|
|
20247
|
-
P.isFinite = function() {
|
|
20248
|
-
return !!this.d;
|
|
20249
|
-
};
|
|
20250
|
-
P.isInteger = P.isInt = function() {
|
|
20251
|
-
return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
|
|
20252
|
-
};
|
|
20253
|
-
P.isNaN = function() {
|
|
20254
|
-
return !this.s;
|
|
20255
|
-
};
|
|
20256
|
-
P.isNegative = P.isNeg = function() {
|
|
20257
|
-
return this.s < 0;
|
|
20258
|
-
};
|
|
20259
|
-
P.isPositive = P.isPos = function() {
|
|
20260
|
-
return this.s > 0;
|
|
20261
|
-
};
|
|
20262
|
-
P.isZero = function() {
|
|
20263
|
-
return !!this.d && this.d[0] === 0;
|
|
20264
|
-
};
|
|
20265
|
-
P.lessThan = P.lt = function(y) {
|
|
20266
|
-
return this.cmp(y) < 0;
|
|
20267
|
-
};
|
|
20268
|
-
P.lessThanOrEqualTo = P.lte = function(y) {
|
|
20269
|
-
return this.cmp(y) < 1;
|
|
20270
|
-
};
|
|
20271
|
-
P.logarithm = P.log = function(base) {
|
|
20272
|
-
var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
|
|
20273
|
-
if (base == null) {
|
|
20274
|
-
base = new Ctor(10);
|
|
20275
|
-
isBase10 = true;
|
|
20276
|
-
} else {
|
|
20277
|
-
base = new Ctor(base);
|
|
20278
|
-
d = base.d;
|
|
20279
|
-
if (base.s < 0 || !d || !d[0] || base.eq(1))
|
|
20280
|
-
return new Ctor(NaN);
|
|
20281
|
-
isBase10 = base.eq(10);
|
|
20282
|
-
}
|
|
20283
|
-
d = arg.d;
|
|
20284
|
-
if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
|
|
20285
|
-
return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
|
|
20286
|
-
}
|
|
20287
|
-
if (isBase10) {
|
|
20288
|
-
if (d.length > 1) {
|
|
20289
|
-
inf = true;
|
|
20290
|
-
} else {
|
|
20291
|
-
for (k = d[0];k % 10 === 0; )
|
|
20292
|
-
k /= 10;
|
|
20293
|
-
inf = k !== 1;
|
|
20294
|
-
}
|
|
20295
|
-
}
|
|
20296
|
-
external2 = false;
|
|
20297
|
-
sd = pr + guard;
|
|
20298
|
-
num = naturalLogarithm(arg, sd);
|
|
20299
|
-
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
20300
|
-
r = divide(num, denominator, sd, 1);
|
|
20301
|
-
if (checkRoundingDigits(r.d, k = pr, rm)) {
|
|
20302
|
-
do {
|
|
20303
|
-
sd += 10;
|
|
20304
|
-
num = naturalLogarithm(arg, sd);
|
|
20305
|
-
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
20306
|
-
r = divide(num, denominator, sd, 1);
|
|
20307
|
-
if (!inf) {
|
|
20308
|
-
if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 100000000000000) {
|
|
20309
|
-
r = finalise(r, pr + 1, 0);
|
|
20310
|
-
}
|
|
20311
|
-
break;
|
|
20312
|
-
}
|
|
20313
|
-
} while (checkRoundingDigits(r.d, k += 10, rm));
|
|
20314
|
-
}
|
|
20315
|
-
external2 = true;
|
|
20316
|
-
return finalise(r, pr, rm);
|
|
20317
|
-
};
|
|
20318
|
-
P.minus = P.sub = function(y) {
|
|
20319
|
-
var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
|
|
20320
|
-
y = new Ctor(y);
|
|
20321
|
-
if (!x.d || !y.d) {
|
|
20322
|
-
if (!x.s || !y.s)
|
|
20323
|
-
y = new Ctor(NaN);
|
|
20324
|
-
else if (x.d)
|
|
20325
|
-
y.s = -y.s;
|
|
20326
|
-
else
|
|
20327
|
-
y = new Ctor(y.d || x.s !== y.s ? x : NaN);
|
|
20328
|
-
return y;
|
|
20329
|
-
}
|
|
20330
|
-
if (x.s != y.s) {
|
|
20331
|
-
y.s = -y.s;
|
|
20332
|
-
return x.plus(y);
|
|
20333
|
-
}
|
|
20334
|
-
xd = x.d;
|
|
20335
|
-
yd = y.d;
|
|
20336
|
-
pr = Ctor.precision;
|
|
20337
|
-
rm = Ctor.rounding;
|
|
20338
|
-
if (!xd[0] || !yd[0]) {
|
|
20339
|
-
if (yd[0])
|
|
20340
|
-
y.s = -y.s;
|
|
20341
|
-
else if (xd[0])
|
|
20342
|
-
y = new Ctor(x);
|
|
20343
|
-
else
|
|
20344
|
-
return new Ctor(rm === 3 ? -0 : 0);
|
|
20345
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20346
|
-
}
|
|
20347
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
20348
|
-
xe = mathfloor(x.e / LOG_BASE);
|
|
20349
|
-
xd = xd.slice();
|
|
20350
|
-
k = xe - e;
|
|
20351
|
-
if (k) {
|
|
20352
|
-
xLTy = k < 0;
|
|
20353
|
-
if (xLTy) {
|
|
20354
|
-
d = xd;
|
|
20355
|
-
k = -k;
|
|
20356
|
-
len = yd.length;
|
|
20357
|
-
} else {
|
|
20358
|
-
d = yd;
|
|
20359
|
-
e = xe;
|
|
20360
|
-
len = xd.length;
|
|
20361
|
-
}
|
|
20362
|
-
i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
|
|
20363
|
-
if (k > i) {
|
|
20364
|
-
k = i;
|
|
20365
|
-
d.length = 1;
|
|
20366
|
-
}
|
|
20367
|
-
d.reverse();
|
|
20368
|
-
for (i = k;i--; )
|
|
20369
|
-
d.push(0);
|
|
20370
|
-
d.reverse();
|
|
20371
|
-
} else {
|
|
20372
|
-
i = xd.length;
|
|
20373
|
-
len = yd.length;
|
|
20374
|
-
xLTy = i < len;
|
|
20375
|
-
if (xLTy)
|
|
20376
|
-
len = i;
|
|
20377
|
-
for (i = 0;i < len; i++) {
|
|
20378
|
-
if (xd[i] != yd[i]) {
|
|
20379
|
-
xLTy = xd[i] < yd[i];
|
|
20380
|
-
break;
|
|
20381
|
-
}
|
|
20382
|
-
}
|
|
20383
|
-
k = 0;
|
|
20384
|
-
}
|
|
20385
|
-
if (xLTy) {
|
|
20386
|
-
d = xd;
|
|
20387
|
-
xd = yd;
|
|
20388
|
-
yd = d;
|
|
20389
|
-
y.s = -y.s;
|
|
20390
|
-
}
|
|
20391
|
-
len = xd.length;
|
|
20392
|
-
for (i = yd.length - len;i > 0; --i)
|
|
20393
|
-
xd[len++] = 0;
|
|
20394
|
-
for (i = yd.length;i > k; ) {
|
|
20395
|
-
if (xd[--i] < yd[i]) {
|
|
20396
|
-
for (j = i;j && xd[--j] === 0; )
|
|
20397
|
-
xd[j] = BASE - 1;
|
|
20398
|
-
--xd[j];
|
|
20399
|
-
xd[i] += BASE;
|
|
20400
|
-
}
|
|
20401
|
-
xd[i] -= yd[i];
|
|
20402
|
-
}
|
|
20403
|
-
for (;xd[--len] === 0; )
|
|
20404
|
-
xd.pop();
|
|
20405
|
-
for (;xd[0] === 0; xd.shift())
|
|
20406
|
-
--e;
|
|
20407
|
-
if (!xd[0])
|
|
20408
|
-
return new Ctor(rm === 3 ? -0 : 0);
|
|
20409
|
-
y.d = xd;
|
|
20410
|
-
y.e = getBase10Exponent(xd, e);
|
|
20411
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20412
|
-
};
|
|
20413
|
-
P.modulo = P.mod = function(y) {
|
|
20414
|
-
var q, x = this, Ctor = x.constructor;
|
|
20415
|
-
y = new Ctor(y);
|
|
20416
|
-
if (!x.d || !y.s || y.d && !y.d[0])
|
|
20417
|
-
return new Ctor(NaN);
|
|
20418
|
-
if (!y.d || x.d && !x.d[0]) {
|
|
20419
|
-
return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
|
|
20420
|
-
}
|
|
20421
|
-
external2 = false;
|
|
20422
|
-
if (Ctor.modulo == 9) {
|
|
20423
|
-
q = divide(x, y.abs(), 0, 3, 1);
|
|
20424
|
-
q.s *= y.s;
|
|
20425
|
-
} else {
|
|
20426
|
-
q = divide(x, y, 0, Ctor.modulo, 1);
|
|
20427
|
-
}
|
|
20428
|
-
q = q.times(y);
|
|
20429
|
-
external2 = true;
|
|
20430
|
-
return x.minus(q);
|
|
20431
|
-
};
|
|
20432
|
-
P.naturalExponential = P.exp = function() {
|
|
20433
|
-
return naturalExponential(this);
|
|
20434
|
-
};
|
|
20435
|
-
P.naturalLogarithm = P.ln = function() {
|
|
20436
|
-
return naturalLogarithm(this);
|
|
20437
|
-
};
|
|
20438
|
-
P.negated = P.neg = function() {
|
|
20439
|
-
var x = new this.constructor(this);
|
|
20440
|
-
x.s = -x.s;
|
|
20441
|
-
return finalise(x);
|
|
20442
|
-
};
|
|
20443
|
-
P.plus = P.add = function(y) {
|
|
20444
|
-
var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
|
|
20445
|
-
y = new Ctor(y);
|
|
20446
|
-
if (!x.d || !y.d) {
|
|
20447
|
-
if (!x.s || !y.s)
|
|
20448
|
-
y = new Ctor(NaN);
|
|
20449
|
-
else if (!x.d)
|
|
20450
|
-
y = new Ctor(y.d || x.s === y.s ? x : NaN);
|
|
20451
|
-
return y;
|
|
20452
|
-
}
|
|
20453
|
-
if (x.s != y.s) {
|
|
20454
|
-
y.s = -y.s;
|
|
20455
|
-
return x.minus(y);
|
|
20456
|
-
}
|
|
20457
|
-
xd = x.d;
|
|
20458
|
-
yd = y.d;
|
|
20459
|
-
pr = Ctor.precision;
|
|
20460
|
-
rm = Ctor.rounding;
|
|
20461
|
-
if (!xd[0] || !yd[0]) {
|
|
20462
|
-
if (!yd[0])
|
|
20463
|
-
y = new Ctor(x);
|
|
20464
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20465
|
-
}
|
|
20466
|
-
k = mathfloor(x.e / LOG_BASE);
|
|
20467
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
20468
|
-
xd = xd.slice();
|
|
20469
|
-
i = k - e;
|
|
20470
|
-
if (i) {
|
|
20471
|
-
if (i < 0) {
|
|
20472
|
-
d = xd;
|
|
20473
|
-
i = -i;
|
|
20474
|
-
len = yd.length;
|
|
20475
|
-
} else {
|
|
20476
|
-
d = yd;
|
|
20477
|
-
e = k;
|
|
20478
|
-
len = xd.length;
|
|
20479
|
-
}
|
|
20480
|
-
k = Math.ceil(pr / LOG_BASE);
|
|
20481
|
-
len = k > len ? k + 1 : len + 1;
|
|
20482
|
-
if (i > len) {
|
|
20483
|
-
i = len;
|
|
20484
|
-
d.length = 1;
|
|
20485
|
-
}
|
|
20486
|
-
d.reverse();
|
|
20487
|
-
for (;i--; )
|
|
20488
|
-
d.push(0);
|
|
20489
|
-
d.reverse();
|
|
20490
|
-
}
|
|
20491
|
-
len = xd.length;
|
|
20492
|
-
i = yd.length;
|
|
20493
|
-
if (len - i < 0) {
|
|
20494
|
-
i = len;
|
|
20495
|
-
d = yd;
|
|
20496
|
-
yd = xd;
|
|
20497
|
-
xd = d;
|
|
20498
|
-
}
|
|
20499
|
-
for (carry = 0;i; ) {
|
|
20500
|
-
carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
|
|
20501
|
-
xd[i] %= BASE;
|
|
20502
|
-
}
|
|
20503
|
-
if (carry) {
|
|
20504
|
-
xd.unshift(carry);
|
|
20505
|
-
++e;
|
|
20506
|
-
}
|
|
20507
|
-
for (len = xd.length;xd[--len] == 0; )
|
|
20508
|
-
xd.pop();
|
|
20509
|
-
y.d = xd;
|
|
20510
|
-
y.e = getBase10Exponent(xd, e);
|
|
20511
|
-
return external2 ? finalise(y, pr, rm) : y;
|
|
20512
|
-
};
|
|
20513
|
-
P.precision = P.sd = function(z) {
|
|
20514
|
-
var k, x = this;
|
|
20515
|
-
if (z !== undefined && z !== !!z && z !== 1 && z !== 0)
|
|
20516
|
-
throw Error(invalidArgument + z);
|
|
20517
|
-
if (x.d) {
|
|
20518
|
-
k = getPrecision(x.d);
|
|
20519
|
-
if (z && x.e + 1 > k)
|
|
20520
|
-
k = x.e + 1;
|
|
20521
|
-
} else {
|
|
20522
|
-
k = NaN;
|
|
20523
|
-
}
|
|
20524
|
-
return k;
|
|
20525
|
-
};
|
|
20526
|
-
P.round = function() {
|
|
20527
|
-
var x = this, Ctor = x.constructor;
|
|
20528
|
-
return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
|
|
20529
|
-
};
|
|
20530
|
-
P.sine = P.sin = function() {
|
|
20531
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
20532
|
-
if (!x.isFinite())
|
|
20533
|
-
return new Ctor(NaN);
|
|
20534
|
-
if (x.isZero())
|
|
20535
|
-
return new Ctor(x);
|
|
20536
|
-
pr = Ctor.precision;
|
|
20537
|
-
rm = Ctor.rounding;
|
|
20538
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
20539
|
-
Ctor.rounding = 1;
|
|
20540
|
-
x = sine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
20541
|
-
Ctor.precision = pr;
|
|
20542
|
-
Ctor.rounding = rm;
|
|
20543
|
-
return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
|
|
20544
|
-
};
|
|
20545
|
-
P.squareRoot = P.sqrt = function() {
|
|
20546
|
-
var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
|
|
20547
|
-
if (s !== 1 || !d || !d[0]) {
|
|
20548
|
-
return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
|
|
20549
|
-
}
|
|
20550
|
-
external2 = false;
|
|
20551
|
-
s = Math.sqrt(+x);
|
|
20552
|
-
if (s == 0 || s == 1 / 0) {
|
|
20553
|
-
n = digitsToString(d);
|
|
20554
|
-
if ((n.length + e) % 2 == 0)
|
|
20555
|
-
n += "0";
|
|
20556
|
-
s = Math.sqrt(n);
|
|
20557
|
-
e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
|
|
20558
|
-
if (s == 1 / 0) {
|
|
20559
|
-
n = "5e" + e;
|
|
20560
|
-
} else {
|
|
20561
|
-
n = s.toExponential();
|
|
20562
|
-
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
20563
|
-
}
|
|
20564
|
-
r = new Ctor(n);
|
|
20565
|
-
} else {
|
|
20566
|
-
r = new Ctor(s.toString());
|
|
20567
|
-
}
|
|
20568
|
-
sd = (e = Ctor.precision) + 3;
|
|
20569
|
-
for (;; ) {
|
|
20570
|
-
t = r;
|
|
20571
|
-
r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
|
|
20572
|
-
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
20573
|
-
n = n.slice(sd - 3, sd + 1);
|
|
20574
|
-
if (n == "9999" || !rep && n == "4999") {
|
|
20575
|
-
if (!rep) {
|
|
20576
|
-
finalise(t, e + 1, 0);
|
|
20577
|
-
if (t.times(t).eq(x)) {
|
|
20578
|
-
r = t;
|
|
20579
|
-
break;
|
|
20580
|
-
}
|
|
20581
|
-
}
|
|
20582
|
-
sd += 4;
|
|
20583
|
-
rep = 1;
|
|
20584
|
-
} else {
|
|
20585
|
-
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
20586
|
-
finalise(r, e + 1, 1);
|
|
20587
|
-
m = !r.times(r).eq(x);
|
|
20588
|
-
}
|
|
20589
|
-
break;
|
|
20590
|
-
}
|
|
20591
|
-
}
|
|
20592
|
-
}
|
|
20593
|
-
external2 = true;
|
|
20594
|
-
return finalise(r, e, Ctor.rounding, m);
|
|
20595
|
-
};
|
|
20596
|
-
P.tangent = P.tan = function() {
|
|
20597
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
20598
|
-
if (!x.isFinite())
|
|
20599
|
-
return new Ctor(NaN);
|
|
20600
|
-
if (x.isZero())
|
|
20601
|
-
return new Ctor(x);
|
|
20602
|
-
pr = Ctor.precision;
|
|
20603
|
-
rm = Ctor.rounding;
|
|
20604
|
-
Ctor.precision = pr + 10;
|
|
20605
|
-
Ctor.rounding = 1;
|
|
20606
|
-
x = x.sin();
|
|
20607
|
-
x.s = 1;
|
|
20608
|
-
x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
|
|
20609
|
-
Ctor.precision = pr;
|
|
20610
|
-
Ctor.rounding = rm;
|
|
20611
|
-
return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
|
|
20612
|
-
};
|
|
20613
|
-
P.times = P.mul = function(y) {
|
|
20614
|
-
var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
|
|
20615
|
-
y.s *= x.s;
|
|
20616
|
-
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
20617
|
-
return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
|
|
20618
|
-
}
|
|
20619
|
-
e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
|
|
20620
|
-
xdL = xd.length;
|
|
20621
|
-
ydL = yd.length;
|
|
20622
|
-
if (xdL < ydL) {
|
|
20623
|
-
r = xd;
|
|
20624
|
-
xd = yd;
|
|
20625
|
-
yd = r;
|
|
20626
|
-
rL = xdL;
|
|
20627
|
-
xdL = ydL;
|
|
20628
|
-
ydL = rL;
|
|
20629
|
-
}
|
|
20630
|
-
r = [];
|
|
20631
|
-
rL = xdL + ydL;
|
|
20632
|
-
for (i = rL;i--; )
|
|
20633
|
-
r.push(0);
|
|
20634
|
-
for (i = ydL;--i >= 0; ) {
|
|
20635
|
-
carry = 0;
|
|
20636
|
-
for (k = xdL + i;k > i; ) {
|
|
20637
|
-
t = r[k] + yd[i] * xd[k - i - 1] + carry;
|
|
20638
|
-
r[k--] = t % BASE | 0;
|
|
20639
|
-
carry = t / BASE | 0;
|
|
20640
|
-
}
|
|
20641
|
-
r[k] = (r[k] + carry) % BASE | 0;
|
|
20642
|
-
}
|
|
20643
|
-
for (;!r[--rL]; )
|
|
20644
|
-
r.pop();
|
|
20645
|
-
if (carry)
|
|
20646
|
-
++e;
|
|
20647
|
-
else
|
|
20648
|
-
r.shift();
|
|
20649
|
-
y.d = r;
|
|
20650
|
-
y.e = getBase10Exponent(r, e);
|
|
20651
|
-
return external2 ? finalise(y, Ctor.precision, Ctor.rounding) : y;
|
|
20652
|
-
};
|
|
20653
|
-
P.toBinary = function(sd, rm) {
|
|
20654
|
-
return toStringBinary(this, 2, sd, rm);
|
|
20655
|
-
};
|
|
20656
|
-
P.toDecimalPlaces = P.toDP = function(dp, rm) {
|
|
20657
|
-
var x = this, Ctor = x.constructor;
|
|
20658
|
-
x = new Ctor(x);
|
|
20659
|
-
if (dp === undefined)
|
|
20660
|
-
return x;
|
|
20661
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
20662
|
-
if (rm === undefined)
|
|
20663
|
-
rm = Ctor.rounding;
|
|
20664
|
-
else
|
|
20665
|
-
checkInt32(rm, 0, 8);
|
|
20666
|
-
return finalise(x, dp + x.e + 1, rm);
|
|
20667
|
-
};
|
|
20668
|
-
P.toExponential = function(dp, rm) {
|
|
20669
|
-
var str, x = this, Ctor = x.constructor;
|
|
20670
|
-
if (dp === undefined) {
|
|
20671
|
-
str = finiteToString(x, true);
|
|
20672
|
-
} else {
|
|
20673
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
20674
|
-
if (rm === undefined)
|
|
20675
|
-
rm = Ctor.rounding;
|
|
20676
|
-
else
|
|
20677
|
-
checkInt32(rm, 0, 8);
|
|
20678
|
-
x = finalise(new Ctor(x), dp + 1, rm);
|
|
20679
|
-
str = finiteToString(x, true, dp + 1);
|
|
20680
|
-
}
|
|
20681
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20682
|
-
};
|
|
20683
|
-
P.toFixed = function(dp, rm) {
|
|
20684
|
-
var str, y, x = this, Ctor = x.constructor;
|
|
20685
|
-
if (dp === undefined) {
|
|
20686
|
-
str = finiteToString(x);
|
|
20687
|
-
} else {
|
|
20688
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
20689
|
-
if (rm === undefined)
|
|
20690
|
-
rm = Ctor.rounding;
|
|
20691
|
-
else
|
|
20692
|
-
checkInt32(rm, 0, 8);
|
|
20693
|
-
y = finalise(new Ctor(x), dp + x.e + 1, rm);
|
|
20694
|
-
str = finiteToString(y, false, dp + y.e + 1);
|
|
20695
|
-
}
|
|
20696
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20697
|
-
};
|
|
20698
|
-
P.toFraction = function(maxD) {
|
|
20699
|
-
var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
|
|
20700
|
-
if (!xd)
|
|
20701
|
-
return new Ctor(x);
|
|
20702
|
-
n1 = d0 = new Ctor(1);
|
|
20703
|
-
d1 = n0 = new Ctor(0);
|
|
20704
|
-
d = new Ctor(d1);
|
|
20705
|
-
e = d.e = getPrecision(xd) - x.e - 1;
|
|
20706
|
-
k = e % LOG_BASE;
|
|
20707
|
-
d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
|
|
20708
|
-
if (maxD == null) {
|
|
20709
|
-
maxD = e > 0 ? d : n1;
|
|
20710
|
-
} else {
|
|
20711
|
-
n = new Ctor(maxD);
|
|
20712
|
-
if (!n.isInt() || n.lt(n1))
|
|
20713
|
-
throw Error(invalidArgument + n);
|
|
20714
|
-
maxD = n.gt(d) ? e > 0 ? d : n1 : n;
|
|
20715
|
-
}
|
|
20716
|
-
external2 = false;
|
|
20717
|
-
n = new Ctor(digitsToString(xd));
|
|
20718
|
-
pr = Ctor.precision;
|
|
20719
|
-
Ctor.precision = e = xd.length * LOG_BASE * 2;
|
|
20720
|
-
for (;; ) {
|
|
20721
|
-
q = divide(n, d, 0, 1, 1);
|
|
20722
|
-
d2 = d0.plus(q.times(d1));
|
|
20723
|
-
if (d2.cmp(maxD) == 1)
|
|
20724
|
-
break;
|
|
20725
|
-
d0 = d1;
|
|
20726
|
-
d1 = d2;
|
|
20727
|
-
d2 = n1;
|
|
20728
|
-
n1 = n0.plus(q.times(d2));
|
|
20729
|
-
n0 = d2;
|
|
20730
|
-
d2 = d;
|
|
20731
|
-
d = n.minus(q.times(d2));
|
|
20732
|
-
n = d2;
|
|
20733
|
-
}
|
|
20734
|
-
d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
|
|
20735
|
-
n0 = n0.plus(d2.times(n1));
|
|
20736
|
-
d0 = d0.plus(d2.times(d1));
|
|
20737
|
-
n0.s = n1.s = x.s;
|
|
20738
|
-
r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
|
|
20739
|
-
Ctor.precision = pr;
|
|
20740
|
-
external2 = true;
|
|
20741
|
-
return r;
|
|
20742
|
-
};
|
|
20743
|
-
P.toHexadecimal = P.toHex = function(sd, rm) {
|
|
20744
|
-
return toStringBinary(this, 16, sd, rm);
|
|
20745
|
-
};
|
|
20746
|
-
P.toNearest = function(y, rm) {
|
|
20747
|
-
var x = this, Ctor = x.constructor;
|
|
20748
|
-
x = new Ctor(x);
|
|
20749
|
-
if (y == null) {
|
|
20750
|
-
if (!x.d)
|
|
20751
|
-
return x;
|
|
20752
|
-
y = new Ctor(1);
|
|
20753
|
-
rm = Ctor.rounding;
|
|
20754
|
-
} else {
|
|
20755
|
-
y = new Ctor(y);
|
|
20756
|
-
if (rm === undefined) {
|
|
20757
|
-
rm = Ctor.rounding;
|
|
20758
|
-
} else {
|
|
20759
|
-
checkInt32(rm, 0, 8);
|
|
20760
|
-
}
|
|
20761
|
-
if (!x.d)
|
|
20762
|
-
return y.s ? x : y;
|
|
20763
|
-
if (!y.d) {
|
|
20764
|
-
if (y.s)
|
|
20765
|
-
y.s = x.s;
|
|
20766
|
-
return y;
|
|
20767
|
-
}
|
|
20768
|
-
}
|
|
20769
|
-
if (y.d[0]) {
|
|
20770
|
-
external2 = false;
|
|
20771
|
-
x = divide(x, y, 0, rm, 1).times(y);
|
|
20772
|
-
external2 = true;
|
|
20773
|
-
finalise(x);
|
|
20774
|
-
} else {
|
|
20775
|
-
y.s = x.s;
|
|
20776
|
-
x = y;
|
|
20777
|
-
}
|
|
20778
|
-
return x;
|
|
20779
|
-
};
|
|
20780
|
-
P.toNumber = function() {
|
|
20781
|
-
return +this;
|
|
20782
|
-
};
|
|
20783
|
-
P.toOctal = function(sd, rm) {
|
|
20784
|
-
return toStringBinary(this, 8, sd, rm);
|
|
20785
|
-
};
|
|
20786
|
-
P.toPower = P.pow = function(y) {
|
|
20787
|
-
var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
|
|
20788
|
-
if (!x.d || !y.d || !x.d[0] || !y.d[0])
|
|
20789
|
-
return new Ctor(mathpow(+x, yn));
|
|
20790
|
-
x = new Ctor(x);
|
|
20791
|
-
if (x.eq(1))
|
|
20792
|
-
return x;
|
|
20793
|
-
pr = Ctor.precision;
|
|
20794
|
-
rm = Ctor.rounding;
|
|
20795
|
-
if (y.eq(1))
|
|
20796
|
-
return finalise(x, pr, rm);
|
|
20797
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
20798
|
-
if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
|
|
20799
|
-
r = intPow(Ctor, x, k, pr);
|
|
20800
|
-
return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
|
|
20801
|
-
}
|
|
20802
|
-
s = x.s;
|
|
20803
|
-
if (s < 0) {
|
|
20804
|
-
if (e < y.d.length - 1)
|
|
20805
|
-
return new Ctor(NaN);
|
|
20806
|
-
if ((y.d[e] & 1) == 0)
|
|
20807
|
-
s = 1;
|
|
20808
|
-
if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
|
|
20809
|
-
x.s = s;
|
|
20810
|
-
return x;
|
|
20811
|
-
}
|
|
20812
|
-
}
|
|
20813
|
-
k = mathpow(+x, yn);
|
|
20814
|
-
e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
|
|
20815
|
-
if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
|
|
20816
|
-
return new Ctor(e > 0 ? s / 0 : 0);
|
|
20817
|
-
external2 = false;
|
|
20818
|
-
Ctor.rounding = x.s = 1;
|
|
20819
|
-
k = Math.min(12, (e + "").length);
|
|
20820
|
-
r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
|
|
20821
|
-
if (r.d) {
|
|
20822
|
-
r = finalise(r, pr + 5, 1);
|
|
20823
|
-
if (checkRoundingDigits(r.d, pr, rm)) {
|
|
20824
|
-
e = pr + 10;
|
|
20825
|
-
r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
|
|
20826
|
-
if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 100000000000000) {
|
|
20827
|
-
r = finalise(r, pr + 1, 0);
|
|
20828
|
-
}
|
|
20829
|
-
}
|
|
20830
|
-
}
|
|
20831
|
-
r.s = s;
|
|
20832
|
-
external2 = true;
|
|
20833
|
-
Ctor.rounding = rm;
|
|
20834
|
-
return finalise(r, pr, rm);
|
|
20835
|
-
};
|
|
20836
|
-
P.toPrecision = function(sd, rm) {
|
|
20837
|
-
var str, x = this, Ctor = x.constructor;
|
|
20838
|
-
if (sd === undefined) {
|
|
20839
|
-
str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
20840
|
-
} else {
|
|
20841
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
20842
|
-
if (rm === undefined)
|
|
20843
|
-
rm = Ctor.rounding;
|
|
20844
|
-
else
|
|
20845
|
-
checkInt32(rm, 0, 8);
|
|
20846
|
-
x = finalise(new Ctor(x), sd, rm);
|
|
20847
|
-
str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
|
|
20848
|
-
}
|
|
20849
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20850
|
-
};
|
|
20851
|
-
P.toSignificantDigits = P.toSD = function(sd, rm) {
|
|
20852
|
-
var x = this, Ctor = x.constructor;
|
|
20853
|
-
if (sd === undefined) {
|
|
20854
|
-
sd = Ctor.precision;
|
|
20855
|
-
rm = Ctor.rounding;
|
|
20856
|
-
} else {
|
|
20857
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
20858
|
-
if (rm === undefined)
|
|
20859
|
-
rm = Ctor.rounding;
|
|
20860
|
-
else
|
|
20861
|
-
checkInt32(rm, 0, 8);
|
|
20862
|
-
}
|
|
20863
|
-
return finalise(new Ctor(x), sd, rm);
|
|
20864
|
-
};
|
|
20865
|
-
P.toString = function() {
|
|
20866
|
-
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
20867
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
20868
|
-
};
|
|
20869
|
-
P.truncated = P.trunc = function() {
|
|
20870
|
-
return finalise(new this.constructor(this), this.e + 1, 1);
|
|
20871
|
-
};
|
|
20872
|
-
P.valueOf = P.toJSON = function() {
|
|
20873
|
-
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
20874
|
-
return x.isNeg() ? "-" + str : str;
|
|
20875
|
-
};
|
|
20876
|
-
function digitsToString(d) {
|
|
20877
|
-
var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
|
|
20878
|
-
if (indexOfLastWord > 0) {
|
|
20879
|
-
str += w;
|
|
20880
|
-
for (i = 1;i < indexOfLastWord; i++) {
|
|
20881
|
-
ws = d[i] + "";
|
|
20882
|
-
k = LOG_BASE - ws.length;
|
|
20883
|
-
if (k)
|
|
20884
|
-
str += getZeroString(k);
|
|
20885
|
-
str += ws;
|
|
20886
|
-
}
|
|
20887
|
-
w = d[i];
|
|
20888
|
-
ws = w + "";
|
|
20889
|
-
k = LOG_BASE - ws.length;
|
|
20890
|
-
if (k)
|
|
20891
|
-
str += getZeroString(k);
|
|
20892
|
-
} else if (w === 0) {
|
|
20893
|
-
return "0";
|
|
20894
|
-
}
|
|
20895
|
-
for (;w % 10 === 0; )
|
|
20896
|
-
w /= 10;
|
|
20897
|
-
return str + w;
|
|
20898
|
-
}
|
|
20899
|
-
function checkInt32(i, min, max) {
|
|
20900
|
-
if (i !== ~~i || i < min || i > max) {
|
|
20901
|
-
throw Error(invalidArgument + i);
|
|
20902
|
-
}
|
|
20903
|
-
}
|
|
20904
|
-
function checkRoundingDigits(d, i, rm, repeating) {
|
|
20905
|
-
var di, k, r, rd;
|
|
20906
|
-
for (k = d[0];k >= 10; k /= 10)
|
|
20907
|
-
--i;
|
|
20908
|
-
if (--i < 0) {
|
|
20909
|
-
i += LOG_BASE;
|
|
20910
|
-
di = 0;
|
|
20911
|
-
} else {
|
|
20912
|
-
di = Math.ceil((i + 1) / LOG_BASE);
|
|
20913
|
-
i %= LOG_BASE;
|
|
20914
|
-
}
|
|
20915
|
-
k = mathpow(10, LOG_BASE - i);
|
|
20916
|
-
rd = d[di] % k | 0;
|
|
20917
|
-
if (repeating == null) {
|
|
20918
|
-
if (i < 3) {
|
|
20919
|
-
if (i == 0)
|
|
20920
|
-
rd = rd / 100 | 0;
|
|
20921
|
-
else if (i == 1)
|
|
20922
|
-
rd = rd / 10 | 0;
|
|
20923
|
-
r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
|
|
20924
|
-
} else {
|
|
20925
|
-
r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
|
|
20926
|
-
}
|
|
20927
|
-
} else {
|
|
20928
|
-
if (i < 4) {
|
|
20929
|
-
if (i == 0)
|
|
20930
|
-
rd = rd / 1000 | 0;
|
|
20931
|
-
else if (i == 1)
|
|
20932
|
-
rd = rd / 100 | 0;
|
|
20933
|
-
else if (i == 2)
|
|
20934
|
-
rd = rd / 10 | 0;
|
|
20935
|
-
r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
|
|
20936
|
-
} else {
|
|
20937
|
-
r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1;
|
|
20938
|
-
}
|
|
20939
|
-
}
|
|
20940
|
-
return r;
|
|
20941
|
-
}
|
|
20942
|
-
function convertBase(str, baseIn, baseOut) {
|
|
20943
|
-
var j, arr = [0], arrL, i = 0, strL = str.length;
|
|
20944
|
-
for (;i < strL; ) {
|
|
20945
|
-
for (arrL = arr.length;arrL--; )
|
|
20946
|
-
arr[arrL] *= baseIn;
|
|
20947
|
-
arr[0] += NUMERALS.indexOf(str.charAt(i++));
|
|
20948
|
-
for (j = 0;j < arr.length; j++) {
|
|
20949
|
-
if (arr[j] > baseOut - 1) {
|
|
20950
|
-
if (arr[j + 1] === undefined)
|
|
20951
|
-
arr[j + 1] = 0;
|
|
20952
|
-
arr[j + 1] += arr[j] / baseOut | 0;
|
|
20953
|
-
arr[j] %= baseOut;
|
|
20954
|
-
}
|
|
20955
|
-
}
|
|
20956
|
-
}
|
|
20957
|
-
return arr.reverse();
|
|
20958
|
-
}
|
|
20959
|
-
function cosine(Ctor, x) {
|
|
20960
|
-
var k, len, y;
|
|
20961
|
-
if (x.isZero())
|
|
20962
|
-
return x;
|
|
20963
|
-
len = x.d.length;
|
|
20964
|
-
if (len < 32) {
|
|
20965
|
-
k = Math.ceil(len / 3);
|
|
20966
|
-
y = (1 / tinyPow(4, k)).toString();
|
|
20967
|
-
} else {
|
|
20968
|
-
k = 16;
|
|
20969
|
-
y = "2.3283064365386962890625e-10";
|
|
20970
|
-
}
|
|
20971
|
-
Ctor.precision += k;
|
|
20972
|
-
x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
|
|
20973
|
-
for (var i = k;i--; ) {
|
|
20974
|
-
var cos2x = x.times(x);
|
|
20975
|
-
x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
|
|
20976
|
-
}
|
|
20977
|
-
Ctor.precision -= k;
|
|
20978
|
-
return x;
|
|
20979
|
-
}
|
|
20980
|
-
var divide = function() {
|
|
20981
|
-
function multiplyInteger(x, k, base) {
|
|
20982
|
-
var temp, carry = 0, i = x.length;
|
|
20983
|
-
for (x = x.slice();i--; ) {
|
|
20984
|
-
temp = x[i] * k + carry;
|
|
20985
|
-
x[i] = temp % base | 0;
|
|
20986
|
-
carry = temp / base | 0;
|
|
20987
|
-
}
|
|
20988
|
-
if (carry)
|
|
20989
|
-
x.unshift(carry);
|
|
20990
|
-
return x;
|
|
20991
|
-
}
|
|
20992
|
-
function compare(a, b, aL, bL) {
|
|
20993
|
-
var i, r;
|
|
20994
|
-
if (aL != bL) {
|
|
20995
|
-
r = aL > bL ? 1 : -1;
|
|
20996
|
-
} else {
|
|
20997
|
-
for (i = r = 0;i < aL; i++) {
|
|
20998
|
-
if (a[i] != b[i]) {
|
|
20999
|
-
r = a[i] > b[i] ? 1 : -1;
|
|
21000
|
-
break;
|
|
21001
|
-
}
|
|
21002
|
-
}
|
|
21003
|
-
}
|
|
21004
|
-
return r;
|
|
21005
|
-
}
|
|
21006
|
-
function subtract(a, b, aL, base) {
|
|
21007
|
-
var i = 0;
|
|
21008
|
-
for (;aL--; ) {
|
|
21009
|
-
a[aL] -= i;
|
|
21010
|
-
i = a[aL] < b[aL] ? 1 : 0;
|
|
21011
|
-
a[aL] = i * base + a[aL] - b[aL];
|
|
21012
|
-
}
|
|
21013
|
-
for (;!a[0] && a.length > 1; )
|
|
21014
|
-
a.shift();
|
|
21015
|
-
}
|
|
21016
|
-
return function(x, y, pr, rm, dp, base) {
|
|
21017
|
-
var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
|
|
21018
|
-
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
21019
|
-
return new Ctor(!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
|
|
21020
|
-
}
|
|
21021
|
-
if (base) {
|
|
21022
|
-
logBase = 1;
|
|
21023
|
-
e = x.e - y.e;
|
|
21024
|
-
} else {
|
|
21025
|
-
base = BASE;
|
|
21026
|
-
logBase = LOG_BASE;
|
|
21027
|
-
e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
|
|
21028
|
-
}
|
|
21029
|
-
yL = yd.length;
|
|
21030
|
-
xL = xd.length;
|
|
21031
|
-
q = new Ctor(sign);
|
|
21032
|
-
qd = q.d = [];
|
|
21033
|
-
for (i = 0;yd[i] == (xd[i] || 0); i++)
|
|
21034
|
-
;
|
|
21035
|
-
if (yd[i] > (xd[i] || 0))
|
|
21036
|
-
e--;
|
|
21037
|
-
if (pr == null) {
|
|
21038
|
-
sd = pr = Ctor.precision;
|
|
21039
|
-
rm = Ctor.rounding;
|
|
21040
|
-
} else if (dp) {
|
|
21041
|
-
sd = pr + (x.e - y.e) + 1;
|
|
21042
|
-
} else {
|
|
21043
|
-
sd = pr;
|
|
21044
|
-
}
|
|
21045
|
-
if (sd < 0) {
|
|
21046
|
-
qd.push(1);
|
|
21047
|
-
more = true;
|
|
21048
|
-
} else {
|
|
21049
|
-
sd = sd / logBase + 2 | 0;
|
|
21050
|
-
i = 0;
|
|
21051
|
-
if (yL == 1) {
|
|
21052
|
-
k = 0;
|
|
21053
|
-
yd = yd[0];
|
|
21054
|
-
sd++;
|
|
21055
|
-
for (;(i < xL || k) && sd--; i++) {
|
|
21056
|
-
t = k * base + (xd[i] || 0);
|
|
21057
|
-
qd[i] = t / yd | 0;
|
|
21058
|
-
k = t % yd | 0;
|
|
21059
|
-
}
|
|
21060
|
-
more = k || i < xL;
|
|
21061
|
-
} else {
|
|
21062
|
-
k = base / (yd[0] + 1) | 0;
|
|
21063
|
-
if (k > 1) {
|
|
21064
|
-
yd = multiplyInteger(yd, k, base);
|
|
21065
|
-
xd = multiplyInteger(xd, k, base);
|
|
21066
|
-
yL = yd.length;
|
|
21067
|
-
xL = xd.length;
|
|
21068
|
-
}
|
|
21069
|
-
xi = yL;
|
|
21070
|
-
rem = xd.slice(0, yL);
|
|
21071
|
-
remL = rem.length;
|
|
21072
|
-
for (;remL < yL; )
|
|
21073
|
-
rem[remL++] = 0;
|
|
21074
|
-
yz = yd.slice();
|
|
21075
|
-
yz.unshift(0);
|
|
21076
|
-
yd0 = yd[0];
|
|
21077
|
-
if (yd[1] >= base / 2)
|
|
21078
|
-
++yd0;
|
|
21079
|
-
do {
|
|
21080
|
-
k = 0;
|
|
21081
|
-
cmp = compare(yd, rem, yL, remL);
|
|
21082
|
-
if (cmp < 0) {
|
|
21083
|
-
rem0 = rem[0];
|
|
21084
|
-
if (yL != remL)
|
|
21085
|
-
rem0 = rem0 * base + (rem[1] || 0);
|
|
21086
|
-
k = rem0 / yd0 | 0;
|
|
21087
|
-
if (k > 1) {
|
|
21088
|
-
if (k >= base)
|
|
21089
|
-
k = base - 1;
|
|
21090
|
-
prod = multiplyInteger(yd, k, base);
|
|
21091
|
-
prodL = prod.length;
|
|
21092
|
-
remL = rem.length;
|
|
21093
|
-
cmp = compare(prod, rem, prodL, remL);
|
|
21094
|
-
if (cmp == 1) {
|
|
21095
|
-
k--;
|
|
21096
|
-
subtract(prod, yL < prodL ? yz : yd, prodL, base);
|
|
21097
|
-
}
|
|
21098
|
-
} else {
|
|
21099
|
-
if (k == 0)
|
|
21100
|
-
cmp = k = 1;
|
|
21101
|
-
prod = yd.slice();
|
|
21102
|
-
}
|
|
21103
|
-
prodL = prod.length;
|
|
21104
|
-
if (prodL < remL)
|
|
21105
|
-
prod.unshift(0);
|
|
21106
|
-
subtract(rem, prod, remL, base);
|
|
21107
|
-
if (cmp == -1) {
|
|
21108
|
-
remL = rem.length;
|
|
21109
|
-
cmp = compare(yd, rem, yL, remL);
|
|
21110
|
-
if (cmp < 1) {
|
|
21111
|
-
k++;
|
|
21112
|
-
subtract(rem, yL < remL ? yz : yd, remL, base);
|
|
21113
|
-
}
|
|
21114
|
-
}
|
|
21115
|
-
remL = rem.length;
|
|
21116
|
-
} else if (cmp === 0) {
|
|
21117
|
-
k++;
|
|
21118
|
-
rem = [0];
|
|
21119
|
-
}
|
|
21120
|
-
qd[i++] = k;
|
|
21121
|
-
if (cmp && rem[0]) {
|
|
21122
|
-
rem[remL++] = xd[xi] || 0;
|
|
21123
|
-
} else {
|
|
21124
|
-
rem = [xd[xi]];
|
|
21125
|
-
remL = 1;
|
|
21126
|
-
}
|
|
21127
|
-
} while ((xi++ < xL || rem[0] !== undefined) && sd--);
|
|
21128
|
-
more = rem[0] !== undefined;
|
|
21129
|
-
}
|
|
21130
|
-
if (!qd[0])
|
|
21131
|
-
qd.shift();
|
|
21132
|
-
}
|
|
21133
|
-
if (logBase == 1) {
|
|
21134
|
-
q.e = e;
|
|
21135
|
-
inexact = more;
|
|
21136
|
-
} else {
|
|
21137
|
-
for (i = 1, k = qd[0];k >= 10; k /= 10)
|
|
21138
|
-
i++;
|
|
21139
|
-
q.e = i + e * logBase - 1;
|
|
21140
|
-
finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
|
|
21141
|
-
}
|
|
21142
|
-
return q;
|
|
21143
|
-
};
|
|
21144
|
-
}();
|
|
21145
|
-
function finalise(x, sd, rm, isTruncated) {
|
|
21146
|
-
var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
|
|
21147
|
-
out:
|
|
21148
|
-
if (sd != null) {
|
|
21149
|
-
xd = x.d;
|
|
21150
|
-
if (!xd)
|
|
21151
|
-
return x;
|
|
21152
|
-
for (digits = 1, k = xd[0];k >= 10; k /= 10)
|
|
21153
|
-
digits++;
|
|
21154
|
-
i = sd - digits;
|
|
21155
|
-
if (i < 0) {
|
|
21156
|
-
i += LOG_BASE;
|
|
21157
|
-
j = sd;
|
|
21158
|
-
w = xd[xdi = 0];
|
|
21159
|
-
rd = w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
21160
|
-
} else {
|
|
21161
|
-
xdi = Math.ceil((i + 1) / LOG_BASE);
|
|
21162
|
-
k = xd.length;
|
|
21163
|
-
if (xdi >= k) {
|
|
21164
|
-
if (isTruncated) {
|
|
21165
|
-
for (;k++ <= xdi; )
|
|
21166
|
-
xd.push(0);
|
|
21167
|
-
w = rd = 0;
|
|
21168
|
-
digits = 1;
|
|
21169
|
-
i %= LOG_BASE;
|
|
21170
|
-
j = i - LOG_BASE + 1;
|
|
21171
|
-
} else {
|
|
21172
|
-
break out;
|
|
21173
|
-
}
|
|
21174
|
-
} else {
|
|
21175
|
-
w = k = xd[xdi];
|
|
21176
|
-
for (digits = 1;k >= 10; k /= 10)
|
|
21177
|
-
digits++;
|
|
21178
|
-
i %= LOG_BASE;
|
|
21179
|
-
j = i - LOG_BASE + digits;
|
|
21180
|
-
rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
21181
|
-
}
|
|
21182
|
-
}
|
|
21183
|
-
isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== undefined || (j < 0 ? w : w % mathpow(10, digits - j - 1));
|
|
21184
|
-
roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
21185
|
-
if (sd < 1 || !xd[0]) {
|
|
21186
|
-
xd.length = 0;
|
|
21187
|
-
if (roundUp) {
|
|
21188
|
-
sd -= x.e + 1;
|
|
21189
|
-
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
|
|
21190
|
-
x.e = -sd || 0;
|
|
21191
|
-
} else {
|
|
21192
|
-
xd[0] = x.e = 0;
|
|
21193
|
-
}
|
|
21194
|
-
return x;
|
|
21195
|
-
}
|
|
21196
|
-
if (i == 0) {
|
|
21197
|
-
xd.length = xdi;
|
|
21198
|
-
k = 1;
|
|
21199
|
-
xdi--;
|
|
21200
|
-
} else {
|
|
21201
|
-
xd.length = xdi + 1;
|
|
21202
|
-
k = mathpow(10, LOG_BASE - i);
|
|
21203
|
-
xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
|
|
21204
|
-
}
|
|
21205
|
-
if (roundUp) {
|
|
21206
|
-
for (;; ) {
|
|
21207
|
-
if (xdi == 0) {
|
|
21208
|
-
for (i = 1, j = xd[0];j >= 10; j /= 10)
|
|
21209
|
-
i++;
|
|
21210
|
-
j = xd[0] += k;
|
|
21211
|
-
for (k = 1;j >= 10; j /= 10)
|
|
21212
|
-
k++;
|
|
21213
|
-
if (i != k) {
|
|
21214
|
-
x.e++;
|
|
21215
|
-
if (xd[0] == BASE)
|
|
21216
|
-
xd[0] = 1;
|
|
21217
|
-
}
|
|
21218
|
-
break;
|
|
21219
|
-
} else {
|
|
21220
|
-
xd[xdi] += k;
|
|
21221
|
-
if (xd[xdi] != BASE)
|
|
21222
|
-
break;
|
|
21223
|
-
xd[xdi--] = 0;
|
|
21224
|
-
k = 1;
|
|
21225
|
-
}
|
|
21226
|
-
}
|
|
21227
|
-
}
|
|
21228
|
-
for (i = xd.length;xd[--i] === 0; )
|
|
21229
|
-
xd.pop();
|
|
21230
|
-
}
|
|
21231
|
-
if (external2) {
|
|
21232
|
-
if (x.e > Ctor.maxE) {
|
|
21233
|
-
x.d = null;
|
|
21234
|
-
x.e = NaN;
|
|
21235
|
-
} else if (x.e < Ctor.minE) {
|
|
21236
|
-
x.e = 0;
|
|
21237
|
-
x.d = [0];
|
|
21238
|
-
}
|
|
21239
|
-
}
|
|
21240
|
-
return x;
|
|
21241
|
-
}
|
|
21242
|
-
function finiteToString(x, isExp, sd) {
|
|
21243
|
-
if (!x.isFinite())
|
|
21244
|
-
return nonFiniteToString(x);
|
|
21245
|
-
var k, e = x.e, str = digitsToString(x.d), len = str.length;
|
|
21246
|
-
if (isExp) {
|
|
21247
|
-
if (sd && (k = sd - len) > 0) {
|
|
21248
|
-
str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
|
|
21249
|
-
} else if (len > 1) {
|
|
21250
|
-
str = str.charAt(0) + "." + str.slice(1);
|
|
21251
|
-
}
|
|
21252
|
-
str = str + (x.e < 0 ? "e" : "e+") + x.e;
|
|
21253
|
-
} else if (e < 0) {
|
|
21254
|
-
str = "0." + getZeroString(-e - 1) + str;
|
|
21255
|
-
if (sd && (k = sd - len) > 0)
|
|
21256
|
-
str += getZeroString(k);
|
|
21257
|
-
} else if (e >= len) {
|
|
21258
|
-
str += getZeroString(e + 1 - len);
|
|
21259
|
-
if (sd && (k = sd - e - 1) > 0)
|
|
21260
|
-
str = str + "." + getZeroString(k);
|
|
21261
|
-
} else {
|
|
21262
|
-
if ((k = e + 1) < len)
|
|
21263
|
-
str = str.slice(0, k) + "." + str.slice(k);
|
|
21264
|
-
if (sd && (k = sd - len) > 0) {
|
|
21265
|
-
if (e + 1 === len)
|
|
21266
|
-
str += ".";
|
|
21267
|
-
str += getZeroString(k);
|
|
21268
|
-
}
|
|
21269
|
-
}
|
|
21270
|
-
return str;
|
|
21271
|
-
}
|
|
21272
|
-
function getBase10Exponent(digits, e) {
|
|
21273
|
-
var w = digits[0];
|
|
21274
|
-
for (e *= LOG_BASE;w >= 10; w /= 10)
|
|
21275
|
-
e++;
|
|
21276
|
-
return e;
|
|
21277
|
-
}
|
|
21278
|
-
function getLn10(Ctor, sd, pr) {
|
|
21279
|
-
if (sd > LN10_PRECISION) {
|
|
21280
|
-
external2 = true;
|
|
21281
|
-
if (pr)
|
|
21282
|
-
Ctor.precision = pr;
|
|
21283
|
-
throw Error(precisionLimitExceeded);
|
|
21284
|
-
}
|
|
21285
|
-
return finalise(new Ctor(LN10), sd, 1, true);
|
|
21286
|
-
}
|
|
21287
|
-
function getPi(Ctor, sd, rm) {
|
|
21288
|
-
if (sd > PI_PRECISION)
|
|
21289
|
-
throw Error(precisionLimitExceeded);
|
|
21290
|
-
return finalise(new Ctor(PI), sd, rm, true);
|
|
21291
|
-
}
|
|
21292
|
-
function getPrecision(digits) {
|
|
21293
|
-
var w = digits.length - 1, len = w * LOG_BASE + 1;
|
|
21294
|
-
w = digits[w];
|
|
21295
|
-
if (w) {
|
|
21296
|
-
for (;w % 10 == 0; w /= 10)
|
|
21297
|
-
len--;
|
|
21298
|
-
for (w = digits[0];w >= 10; w /= 10)
|
|
21299
|
-
len++;
|
|
21300
|
-
}
|
|
21301
|
-
return len;
|
|
21302
|
-
}
|
|
21303
|
-
function getZeroString(k) {
|
|
21304
|
-
var zs = "";
|
|
21305
|
-
for (;k--; )
|
|
21306
|
-
zs += "0";
|
|
21307
|
-
return zs;
|
|
21308
|
-
}
|
|
21309
|
-
function intPow(Ctor, x, n, pr) {
|
|
21310
|
-
var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
|
|
21311
|
-
external2 = false;
|
|
21312
|
-
for (;; ) {
|
|
21313
|
-
if (n % 2) {
|
|
21314
|
-
r = r.times(x);
|
|
21315
|
-
if (truncate(r.d, k))
|
|
21316
|
-
isTruncated = true;
|
|
21317
|
-
}
|
|
21318
|
-
n = mathfloor(n / 2);
|
|
21319
|
-
if (n === 0) {
|
|
21320
|
-
n = r.d.length - 1;
|
|
21321
|
-
if (isTruncated && r.d[n] === 0)
|
|
21322
|
-
++r.d[n];
|
|
21323
|
-
break;
|
|
21324
|
-
}
|
|
21325
|
-
x = x.times(x);
|
|
21326
|
-
truncate(x.d, k);
|
|
21327
|
-
}
|
|
21328
|
-
external2 = true;
|
|
21329
|
-
return r;
|
|
21330
|
-
}
|
|
21331
|
-
function isOdd(n) {
|
|
21332
|
-
return n.d[n.d.length - 1] & 1;
|
|
21333
|
-
}
|
|
21334
|
-
function maxOrMin(Ctor, args, n) {
|
|
21335
|
-
var k, y, x = new Ctor(args[0]), i = 0;
|
|
21336
|
-
for (;++i < args.length; ) {
|
|
21337
|
-
y = new Ctor(args[i]);
|
|
21338
|
-
if (!y.s) {
|
|
21339
|
-
x = y;
|
|
21340
|
-
break;
|
|
21341
|
-
}
|
|
21342
|
-
k = x.cmp(y);
|
|
21343
|
-
if (k === n || k === 0 && x.s === n) {
|
|
21344
|
-
x = y;
|
|
21345
|
-
}
|
|
21346
|
-
}
|
|
21347
|
-
return x;
|
|
21348
|
-
}
|
|
21349
|
-
function naturalExponential(x, sd) {
|
|
21350
|
-
var denominator, guard, j, pow, sum, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
21351
|
-
if (!x.d || !x.d[0] || x.e > 17) {
|
|
21352
|
-
return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
|
|
21353
|
-
}
|
|
21354
|
-
if (sd == null) {
|
|
21355
|
-
external2 = false;
|
|
21356
|
-
wpr = pr;
|
|
21357
|
-
} else {
|
|
21358
|
-
wpr = sd;
|
|
21359
|
-
}
|
|
21360
|
-
t = new Ctor(0.03125);
|
|
21361
|
-
while (x.e > -2) {
|
|
21362
|
-
x = x.times(t);
|
|
21363
|
-
k += 5;
|
|
21364
|
-
}
|
|
21365
|
-
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
|
|
21366
|
-
wpr += guard;
|
|
21367
|
-
denominator = pow = sum = new Ctor(1);
|
|
21368
|
-
Ctor.precision = wpr;
|
|
21369
|
-
for (;; ) {
|
|
21370
|
-
pow = finalise(pow.times(x), wpr, 1);
|
|
21371
|
-
denominator = denominator.times(++i);
|
|
21372
|
-
t = sum.plus(divide(pow, denominator, wpr, 1));
|
|
21373
|
-
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
21374
|
-
j = k;
|
|
21375
|
-
while (j--)
|
|
21376
|
-
sum = finalise(sum.times(sum), wpr, 1);
|
|
21377
|
-
if (sd == null) {
|
|
21378
|
-
if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
|
|
21379
|
-
Ctor.precision = wpr += 10;
|
|
21380
|
-
denominator = pow = t = new Ctor(1);
|
|
21381
|
-
i = 0;
|
|
21382
|
-
rep++;
|
|
21383
|
-
} else {
|
|
21384
|
-
return finalise(sum, Ctor.precision = pr, rm, external2 = true);
|
|
21385
|
-
}
|
|
21386
|
-
} else {
|
|
21387
|
-
Ctor.precision = pr;
|
|
21388
|
-
return sum;
|
|
21389
|
-
}
|
|
21390
|
-
}
|
|
21391
|
-
sum = t;
|
|
21392
|
-
}
|
|
21393
|
-
}
|
|
21394
|
-
function naturalLogarithm(y, sd) {
|
|
21395
|
-
var c, c0, denominator, e, numerator, rep, sum, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
21396
|
-
if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
|
|
21397
|
-
return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
|
|
21398
|
-
}
|
|
21399
|
-
if (sd == null) {
|
|
21400
|
-
external2 = false;
|
|
21401
|
-
wpr = pr;
|
|
21402
|
-
} else {
|
|
21403
|
-
wpr = sd;
|
|
21404
|
-
}
|
|
21405
|
-
Ctor.precision = wpr += guard;
|
|
21406
|
-
c = digitsToString(xd);
|
|
21407
|
-
c0 = c.charAt(0);
|
|
21408
|
-
if (Math.abs(e = x.e) < 1500000000000000) {
|
|
21409
|
-
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
|
|
21410
|
-
x = x.times(y);
|
|
21411
|
-
c = digitsToString(x.d);
|
|
21412
|
-
c0 = c.charAt(0);
|
|
21413
|
-
n++;
|
|
21414
|
-
}
|
|
21415
|
-
e = x.e;
|
|
21416
|
-
if (c0 > 1) {
|
|
21417
|
-
x = new Ctor("0." + c);
|
|
21418
|
-
e++;
|
|
21419
|
-
} else {
|
|
21420
|
-
x = new Ctor(c0 + "." + c.slice(1));
|
|
21421
|
-
}
|
|
21422
|
-
} else {
|
|
21423
|
-
t = getLn10(Ctor, wpr + 2, pr).times(e + "");
|
|
21424
|
-
x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
|
|
21425
|
-
Ctor.precision = pr;
|
|
21426
|
-
return sd == null ? finalise(x, pr, rm, external2 = true) : x;
|
|
21427
|
-
}
|
|
21428
|
-
x1 = x;
|
|
21429
|
-
sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
|
|
21430
|
-
x2 = finalise(x.times(x), wpr, 1);
|
|
21431
|
-
denominator = 3;
|
|
21432
|
-
for (;; ) {
|
|
21433
|
-
numerator = finalise(numerator.times(x2), wpr, 1);
|
|
21434
|
-
t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
|
|
21435
|
-
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
21436
|
-
sum = sum.times(2);
|
|
21437
|
-
if (e !== 0)
|
|
21438
|
-
sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
|
|
21439
|
-
sum = divide(sum, new Ctor(n), wpr, 1);
|
|
21440
|
-
if (sd == null) {
|
|
21441
|
-
if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
|
|
21442
|
-
Ctor.precision = wpr += guard;
|
|
21443
|
-
t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
|
|
21444
|
-
x2 = finalise(x.times(x), wpr, 1);
|
|
21445
|
-
denominator = rep = 1;
|
|
21446
|
-
} else {
|
|
21447
|
-
return finalise(sum, Ctor.precision = pr, rm, external2 = true);
|
|
21448
|
-
}
|
|
21449
|
-
} else {
|
|
21450
|
-
Ctor.precision = pr;
|
|
21451
|
-
return sum;
|
|
21452
|
-
}
|
|
21453
|
-
}
|
|
21454
|
-
sum = t;
|
|
21455
|
-
denominator += 2;
|
|
21456
|
-
}
|
|
21457
|
-
}
|
|
21458
|
-
function nonFiniteToString(x) {
|
|
21459
|
-
return String(x.s * x.s / 0);
|
|
21460
|
-
}
|
|
21461
|
-
function parseDecimal(x, str) {
|
|
21462
|
-
var e, i, len;
|
|
21463
|
-
if ((e = str.indexOf(".")) > -1)
|
|
21464
|
-
str = str.replace(".", "");
|
|
21465
|
-
if ((i = str.search(/e/i)) > 0) {
|
|
21466
|
-
if (e < 0)
|
|
21467
|
-
e = i;
|
|
21468
|
-
e += +str.slice(i + 1);
|
|
21469
|
-
str = str.substring(0, i);
|
|
21470
|
-
} else if (e < 0) {
|
|
21471
|
-
e = str.length;
|
|
21472
|
-
}
|
|
21473
|
-
for (i = 0;str.charCodeAt(i) === 48; i++)
|
|
21474
|
-
;
|
|
21475
|
-
for (len = str.length;str.charCodeAt(len - 1) === 48; --len)
|
|
21476
|
-
;
|
|
21477
|
-
str = str.slice(i, len);
|
|
21478
|
-
if (str) {
|
|
21479
|
-
len -= i;
|
|
21480
|
-
x.e = e = e - i - 1;
|
|
21481
|
-
x.d = [];
|
|
21482
|
-
i = (e + 1) % LOG_BASE;
|
|
21483
|
-
if (e < 0)
|
|
21484
|
-
i += LOG_BASE;
|
|
21485
|
-
if (i < len) {
|
|
21486
|
-
if (i)
|
|
21487
|
-
x.d.push(+str.slice(0, i));
|
|
21488
|
-
for (len -= LOG_BASE;i < len; )
|
|
21489
|
-
x.d.push(+str.slice(i, i += LOG_BASE));
|
|
21490
|
-
str = str.slice(i);
|
|
21491
|
-
i = LOG_BASE - str.length;
|
|
21492
|
-
} else {
|
|
21493
|
-
i -= len;
|
|
21494
|
-
}
|
|
21495
|
-
for (;i--; )
|
|
21496
|
-
str += "0";
|
|
21497
|
-
x.d.push(+str);
|
|
21498
|
-
if (external2) {
|
|
21499
|
-
if (x.e > x.constructor.maxE) {
|
|
21500
|
-
x.d = null;
|
|
21501
|
-
x.e = NaN;
|
|
21502
|
-
} else if (x.e < x.constructor.minE) {
|
|
21503
|
-
x.e = 0;
|
|
21504
|
-
x.d = [0];
|
|
21505
|
-
}
|
|
21506
|
-
}
|
|
21507
|
-
} else {
|
|
21508
|
-
x.e = 0;
|
|
21509
|
-
x.d = [0];
|
|
21510
|
-
}
|
|
21511
|
-
return x;
|
|
21512
|
-
}
|
|
21513
|
-
function parseOther(x, str) {
|
|
21514
|
-
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
|
21515
|
-
if (str.indexOf("_") > -1) {
|
|
21516
|
-
str = str.replace(/(\d)_(?=\d)/g, "$1");
|
|
21517
|
-
if (isDecimal.test(str))
|
|
21518
|
-
return parseDecimal(x, str);
|
|
21519
|
-
} else if (str === "Infinity" || str === "NaN") {
|
|
21520
|
-
if (!+str)
|
|
21521
|
-
x.s = NaN;
|
|
21522
|
-
x.e = NaN;
|
|
21523
|
-
x.d = null;
|
|
21524
|
-
return x;
|
|
21525
|
-
}
|
|
21526
|
-
if (isHex.test(str)) {
|
|
21527
|
-
base = 16;
|
|
21528
|
-
str = str.toLowerCase();
|
|
21529
|
-
} else if (isBinary.test(str)) {
|
|
21530
|
-
base = 2;
|
|
21531
|
-
} else if (isOctal.test(str)) {
|
|
21532
|
-
base = 8;
|
|
21533
|
-
} else {
|
|
21534
|
-
throw Error(invalidArgument + str);
|
|
21535
|
-
}
|
|
21536
|
-
i = str.search(/p/i);
|
|
21537
|
-
if (i > 0) {
|
|
21538
|
-
p = +str.slice(i + 1);
|
|
21539
|
-
str = str.substring(2, i);
|
|
21540
|
-
} else {
|
|
21541
|
-
str = str.slice(2);
|
|
21542
|
-
}
|
|
21543
|
-
i = str.indexOf(".");
|
|
21544
|
-
isFloat = i >= 0;
|
|
21545
|
-
Ctor = x.constructor;
|
|
21546
|
-
if (isFloat) {
|
|
21547
|
-
str = str.replace(".", "");
|
|
21548
|
-
len = str.length;
|
|
21549
|
-
i = len - i;
|
|
21550
|
-
divisor = intPow(Ctor, new Ctor(base), i, i * 2);
|
|
21551
|
-
}
|
|
21552
|
-
xd = convertBase(str, base, BASE);
|
|
21553
|
-
xe = xd.length - 1;
|
|
21554
|
-
for (i = xe;xd[i] === 0; --i)
|
|
21555
|
-
xd.pop();
|
|
21556
|
-
if (i < 0)
|
|
21557
|
-
return new Ctor(x.s * 0);
|
|
21558
|
-
x.e = getBase10Exponent(xd, xe);
|
|
21559
|
-
x.d = xd;
|
|
21560
|
-
external2 = false;
|
|
21561
|
-
if (isFloat)
|
|
21562
|
-
x = divide(x, divisor, len * 4);
|
|
21563
|
-
if (p)
|
|
21564
|
-
x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
|
|
21565
|
-
external2 = true;
|
|
21566
|
-
return x;
|
|
21567
|
-
}
|
|
21568
|
-
function sine(Ctor, x) {
|
|
21569
|
-
var k, len = x.d.length;
|
|
21570
|
-
if (len < 3) {
|
|
21571
|
-
return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
|
|
21572
|
-
}
|
|
21573
|
-
k = 1.4 * Math.sqrt(len);
|
|
21574
|
-
k = k > 16 ? 16 : k | 0;
|
|
21575
|
-
x = x.times(1 / tinyPow(5, k));
|
|
21576
|
-
x = taylorSeries(Ctor, 2, x, x);
|
|
21577
|
-
var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
21578
|
-
for (;k--; ) {
|
|
21579
|
-
sin2_x = x.times(x);
|
|
21580
|
-
x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
|
|
21581
|
-
}
|
|
21582
|
-
return x;
|
|
21583
|
-
}
|
|
21584
|
-
function taylorSeries(Ctor, n, x, y, isHyperbolic) {
|
|
21585
|
-
var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
|
|
21586
|
-
external2 = false;
|
|
21587
|
-
x2 = x.times(x);
|
|
21588
|
-
u = new Ctor(y);
|
|
21589
|
-
for (;; ) {
|
|
21590
|
-
t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
21591
|
-
u = isHyperbolic ? y.plus(t) : y.minus(t);
|
|
21592
|
-
y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
21593
|
-
t = u.plus(y);
|
|
21594
|
-
if (t.d[k] !== undefined) {
|
|
21595
|
-
for (j = k;t.d[j] === u.d[j] && j--; )
|
|
21596
|
-
;
|
|
21597
|
-
if (j == -1)
|
|
21598
|
-
break;
|
|
21599
|
-
}
|
|
21600
|
-
j = u;
|
|
21601
|
-
u = y;
|
|
21602
|
-
y = t;
|
|
21603
|
-
t = j;
|
|
21604
|
-
i++;
|
|
21605
|
-
}
|
|
21606
|
-
external2 = true;
|
|
21607
|
-
t.d.length = k + 1;
|
|
21608
|
-
return t;
|
|
21609
|
-
}
|
|
21610
|
-
function tinyPow(b, e) {
|
|
21611
|
-
var n = b;
|
|
21612
|
-
while (--e)
|
|
21613
|
-
n *= b;
|
|
21614
|
-
return n;
|
|
21615
|
-
}
|
|
21616
|
-
function toLessThanHalfPi(Ctor, x) {
|
|
21617
|
-
var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
|
|
21618
|
-
x = x.abs();
|
|
21619
|
-
if (x.lte(halfPi)) {
|
|
21620
|
-
quadrant = isNeg ? 4 : 1;
|
|
21621
|
-
return x;
|
|
21622
|
-
}
|
|
21623
|
-
t = x.divToInt(pi);
|
|
21624
|
-
if (t.isZero()) {
|
|
21625
|
-
quadrant = isNeg ? 3 : 2;
|
|
21626
|
-
} else {
|
|
21627
|
-
x = x.minus(t.times(pi));
|
|
21628
|
-
if (x.lte(halfPi)) {
|
|
21629
|
-
quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
|
|
21630
|
-
return x;
|
|
21631
|
-
}
|
|
21632
|
-
quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
|
|
21633
|
-
}
|
|
21634
|
-
return x.minus(pi).abs();
|
|
21635
|
-
}
|
|
21636
|
-
function toStringBinary(x, baseOut, sd, rm) {
|
|
21637
|
-
var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== undefined;
|
|
21638
|
-
if (isExp) {
|
|
21639
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
21640
|
-
if (rm === undefined)
|
|
21641
|
-
rm = Ctor.rounding;
|
|
21642
|
-
else
|
|
21643
|
-
checkInt32(rm, 0, 8);
|
|
21644
|
-
} else {
|
|
21645
|
-
sd = Ctor.precision;
|
|
21646
|
-
rm = Ctor.rounding;
|
|
21647
|
-
}
|
|
21648
|
-
if (!x.isFinite()) {
|
|
21649
|
-
str = nonFiniteToString(x);
|
|
21650
|
-
} else {
|
|
21651
|
-
str = finiteToString(x);
|
|
21652
|
-
i = str.indexOf(".");
|
|
21653
|
-
if (isExp) {
|
|
21654
|
-
base = 2;
|
|
21655
|
-
if (baseOut == 16) {
|
|
21656
|
-
sd = sd * 4 - 3;
|
|
21657
|
-
} else if (baseOut == 8) {
|
|
21658
|
-
sd = sd * 3 - 2;
|
|
21659
|
-
}
|
|
21660
|
-
} else {
|
|
21661
|
-
base = baseOut;
|
|
21662
|
-
}
|
|
21663
|
-
if (i >= 0) {
|
|
21664
|
-
str = str.replace(".", "");
|
|
21665
|
-
y = new Ctor(1);
|
|
21666
|
-
y.e = str.length - i;
|
|
21667
|
-
y.d = convertBase(finiteToString(y), 10, base);
|
|
21668
|
-
y.e = y.d.length;
|
|
21669
|
-
}
|
|
21670
|
-
xd = convertBase(str, 10, base);
|
|
21671
|
-
e = len = xd.length;
|
|
21672
|
-
for (;xd[--len] == 0; )
|
|
21673
|
-
xd.pop();
|
|
21674
|
-
if (!xd[0]) {
|
|
21675
|
-
str = isExp ? "0p+0" : "0";
|
|
21676
|
-
} else {
|
|
21677
|
-
if (i < 0) {
|
|
21678
|
-
e--;
|
|
21679
|
-
} else {
|
|
21680
|
-
x = new Ctor(x);
|
|
21681
|
-
x.d = xd;
|
|
21682
|
-
x.e = e;
|
|
21683
|
-
x = divide(x, y, sd, rm, 0, base);
|
|
21684
|
-
xd = x.d;
|
|
21685
|
-
e = x.e;
|
|
21686
|
-
roundUp = inexact;
|
|
21687
|
-
}
|
|
21688
|
-
i = xd[sd];
|
|
21689
|
-
k = base / 2;
|
|
21690
|
-
roundUp = roundUp || xd[sd + 1] !== undefined;
|
|
21691
|
-
roundUp = rm < 4 ? (i !== undefined || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
|
|
21692
|
-
xd.length = sd;
|
|
21693
|
-
if (roundUp) {
|
|
21694
|
-
for (;++xd[--sd] > base - 1; ) {
|
|
21695
|
-
xd[sd] = 0;
|
|
21696
|
-
if (!sd) {
|
|
21697
|
-
++e;
|
|
21698
|
-
xd.unshift(1);
|
|
21699
|
-
}
|
|
21700
|
-
}
|
|
21701
|
-
}
|
|
21702
|
-
for (len = xd.length;!xd[len - 1]; --len)
|
|
21703
|
-
;
|
|
21704
|
-
for (i = 0, str = "";i < len; i++)
|
|
21705
|
-
str += NUMERALS.charAt(xd[i]);
|
|
21706
|
-
if (isExp) {
|
|
21707
|
-
if (len > 1) {
|
|
21708
|
-
if (baseOut == 16 || baseOut == 8) {
|
|
21709
|
-
i = baseOut == 16 ? 4 : 3;
|
|
21710
|
-
for (--len;len % i; len++)
|
|
21711
|
-
str += "0";
|
|
21712
|
-
xd = convertBase(str, base, baseOut);
|
|
21713
|
-
for (len = xd.length;!xd[len - 1]; --len)
|
|
21714
|
-
;
|
|
21715
|
-
for (i = 1, str = "1.";i < len; i++)
|
|
21716
|
-
str += NUMERALS.charAt(xd[i]);
|
|
21717
|
-
} else {
|
|
21718
|
-
str = str.charAt(0) + "." + str.slice(1);
|
|
21719
|
-
}
|
|
21720
|
-
}
|
|
21721
|
-
str = str + (e < 0 ? "p" : "p+") + e;
|
|
21722
|
-
} else if (e < 0) {
|
|
21723
|
-
for (;++e; )
|
|
21724
|
-
str = "0" + str;
|
|
21725
|
-
str = "0." + str;
|
|
21726
|
-
} else {
|
|
21727
|
-
if (++e > len)
|
|
21728
|
-
for (e -= len;e--; )
|
|
21729
|
-
str += "0";
|
|
21730
|
-
else if (e < len)
|
|
21731
|
-
str = str.slice(0, e) + "." + str.slice(e);
|
|
21732
|
-
}
|
|
21733
|
-
}
|
|
21734
|
-
str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
|
|
21735
|
-
}
|
|
21736
|
-
return x.s < 0 ? "-" + str : str;
|
|
21737
|
-
}
|
|
21738
|
-
function truncate(arr, len) {
|
|
21739
|
-
if (arr.length > len) {
|
|
21740
|
-
arr.length = len;
|
|
21741
|
-
return true;
|
|
21742
|
-
}
|
|
21743
|
-
}
|
|
21744
|
-
function abs(x) {
|
|
21745
|
-
return new this(x).abs();
|
|
21746
|
-
}
|
|
21747
|
-
function acos(x) {
|
|
21748
|
-
return new this(x).acos();
|
|
21749
|
-
}
|
|
21750
|
-
function acosh(x) {
|
|
21751
|
-
return new this(x).acosh();
|
|
21752
|
-
}
|
|
21753
|
-
function add(x, y) {
|
|
21754
|
-
return new this(x).plus(y);
|
|
21755
|
-
}
|
|
21756
|
-
function asin(x) {
|
|
21757
|
-
return new this(x).asin();
|
|
21758
|
-
}
|
|
21759
|
-
function asinh(x) {
|
|
21760
|
-
return new this(x).asinh();
|
|
21761
|
-
}
|
|
21762
|
-
function atan(x) {
|
|
21763
|
-
return new this(x).atan();
|
|
21764
|
-
}
|
|
21765
|
-
function atanh(x) {
|
|
21766
|
-
return new this(x).atanh();
|
|
21767
|
-
}
|
|
21768
|
-
function atan2(y, x) {
|
|
21769
|
-
y = new this(y);
|
|
21770
|
-
x = new this(x);
|
|
21771
|
-
var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
|
|
21772
|
-
if (!y.s || !x.s) {
|
|
21773
|
-
r = new this(NaN);
|
|
21774
|
-
} else if (!y.d && !x.d) {
|
|
21775
|
-
r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
|
|
21776
|
-
r.s = y.s;
|
|
21777
|
-
} else if (!x.d || y.isZero()) {
|
|
21778
|
-
r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
|
|
21779
|
-
r.s = y.s;
|
|
21780
|
-
} else if (!y.d || x.isZero()) {
|
|
21781
|
-
r = getPi(this, wpr, 1).times(0.5);
|
|
21782
|
-
r.s = y.s;
|
|
21783
|
-
} else if (x.s < 0) {
|
|
21784
|
-
this.precision = wpr;
|
|
21785
|
-
this.rounding = 1;
|
|
21786
|
-
r = this.atan(divide(y, x, wpr, 1));
|
|
21787
|
-
x = getPi(this, wpr, 1);
|
|
21788
|
-
this.precision = pr;
|
|
21789
|
-
this.rounding = rm;
|
|
21790
|
-
r = y.s < 0 ? r.minus(x) : r.plus(x);
|
|
21791
|
-
} else {
|
|
21792
|
-
r = this.atan(divide(y, x, wpr, 1));
|
|
21793
|
-
}
|
|
21794
|
-
return r;
|
|
21795
|
-
}
|
|
21796
|
-
function cbrt(x) {
|
|
21797
|
-
return new this(x).cbrt();
|
|
21798
|
-
}
|
|
21799
|
-
function ceil(x) {
|
|
21800
|
-
return finalise(x = new this(x), x.e + 1, 2);
|
|
21801
|
-
}
|
|
21802
|
-
function clamp(x, min, max) {
|
|
21803
|
-
return new this(x).clamp(min, max);
|
|
21804
|
-
}
|
|
21805
|
-
function config(obj) {
|
|
21806
|
-
if (!obj || typeof obj !== "object")
|
|
21807
|
-
throw Error(decimalError + "Object expected");
|
|
21808
|
-
var i, p, v, useDefaults = obj.defaults === true, ps = [
|
|
21809
|
-
"precision",
|
|
21810
|
-
1,
|
|
21811
|
-
MAX_DIGITS,
|
|
21812
|
-
"rounding",
|
|
21813
|
-
0,
|
|
21814
|
-
8,
|
|
21815
|
-
"toExpNeg",
|
|
21816
|
-
-EXP_LIMIT,
|
|
21817
|
-
0,
|
|
21818
|
-
"toExpPos",
|
|
21819
|
-
0,
|
|
21820
|
-
EXP_LIMIT,
|
|
21821
|
-
"maxE",
|
|
21822
|
-
0,
|
|
21823
|
-
EXP_LIMIT,
|
|
21824
|
-
"minE",
|
|
21825
|
-
-EXP_LIMIT,
|
|
21826
|
-
0,
|
|
21827
|
-
"modulo",
|
|
21828
|
-
0,
|
|
21829
|
-
9
|
|
21830
|
-
];
|
|
21831
|
-
for (i = 0;i < ps.length; i += 3) {
|
|
21832
|
-
if (p = ps[i], useDefaults)
|
|
21833
|
-
this[p] = DEFAULTS[p];
|
|
21834
|
-
if ((v = obj[p]) !== undefined) {
|
|
21835
|
-
if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
|
|
21836
|
-
this[p] = v;
|
|
21837
|
-
else
|
|
21838
|
-
throw Error(invalidArgument + p + ": " + v);
|
|
21839
|
-
}
|
|
21840
|
-
}
|
|
21841
|
-
if (p = "crypto", useDefaults)
|
|
21842
|
-
this[p] = DEFAULTS[p];
|
|
21843
|
-
if ((v = obj[p]) !== undefined) {
|
|
21844
|
-
if (v === true || v === false || v === 0 || v === 1) {
|
|
21845
|
-
if (v) {
|
|
21846
|
-
if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
|
|
21847
|
-
this[p] = true;
|
|
21848
|
-
} else {
|
|
21849
|
-
throw Error(cryptoUnavailable);
|
|
21850
|
-
}
|
|
21851
|
-
} else {
|
|
21852
|
-
this[p] = false;
|
|
21853
|
-
}
|
|
21854
|
-
} else {
|
|
21855
|
-
throw Error(invalidArgument + p + ": " + v);
|
|
21856
|
-
}
|
|
21857
|
-
}
|
|
21858
|
-
return this;
|
|
21859
|
-
}
|
|
21860
|
-
function cos(x) {
|
|
21861
|
-
return new this(x).cos();
|
|
21862
|
-
}
|
|
21863
|
-
function cosh(x) {
|
|
21864
|
-
return new this(x).cosh();
|
|
21865
|
-
}
|
|
21866
|
-
function clone(obj) {
|
|
21867
|
-
var i, p, ps;
|
|
21868
|
-
function Decimal(v) {
|
|
21869
|
-
var e, i2, t, x = this;
|
|
21870
|
-
if (!(x instanceof Decimal))
|
|
21871
|
-
return new Decimal(v);
|
|
21872
|
-
x.constructor = Decimal;
|
|
21873
|
-
if (isDecimalInstance(v)) {
|
|
21874
|
-
x.s = v.s;
|
|
21875
|
-
if (external2) {
|
|
21876
|
-
if (!v.d || v.e > Decimal.maxE) {
|
|
21877
|
-
x.e = NaN;
|
|
21878
|
-
x.d = null;
|
|
21879
|
-
} else if (v.e < Decimal.minE) {
|
|
21880
|
-
x.e = 0;
|
|
21881
|
-
x.d = [0];
|
|
21882
|
-
} else {
|
|
21883
|
-
x.e = v.e;
|
|
21884
|
-
x.d = v.d.slice();
|
|
21885
|
-
}
|
|
21886
|
-
} else {
|
|
21887
|
-
x.e = v.e;
|
|
21888
|
-
x.d = v.d ? v.d.slice() : v.d;
|
|
21889
|
-
}
|
|
21890
|
-
return;
|
|
21891
|
-
}
|
|
21892
|
-
t = typeof v;
|
|
21893
|
-
if (t === "number") {
|
|
21894
|
-
if (v === 0) {
|
|
21895
|
-
x.s = 1 / v < 0 ? -1 : 1;
|
|
21896
|
-
x.e = 0;
|
|
21897
|
-
x.d = [0];
|
|
21898
|
-
return;
|
|
21899
|
-
}
|
|
21900
|
-
if (v < 0) {
|
|
21901
|
-
v = -v;
|
|
21902
|
-
x.s = -1;
|
|
21903
|
-
} else {
|
|
21904
|
-
x.s = 1;
|
|
21905
|
-
}
|
|
21906
|
-
if (v === ~~v && v < 1e7) {
|
|
21907
|
-
for (e = 0, i2 = v;i2 >= 10; i2 /= 10)
|
|
21908
|
-
e++;
|
|
21909
|
-
if (external2) {
|
|
21910
|
-
if (e > Decimal.maxE) {
|
|
21911
|
-
x.e = NaN;
|
|
21912
|
-
x.d = null;
|
|
21913
|
-
} else if (e < Decimal.minE) {
|
|
21914
|
-
x.e = 0;
|
|
21915
|
-
x.d = [0];
|
|
21916
|
-
} else {
|
|
21917
|
-
x.e = e;
|
|
21918
|
-
x.d = [v];
|
|
21919
|
-
}
|
|
21920
|
-
} else {
|
|
21921
|
-
x.e = e;
|
|
21922
|
-
x.d = [v];
|
|
21923
|
-
}
|
|
21924
|
-
return;
|
|
21925
|
-
}
|
|
21926
|
-
if (v * 0 !== 0) {
|
|
21927
|
-
if (!v)
|
|
21928
|
-
x.s = NaN;
|
|
21929
|
-
x.e = NaN;
|
|
21930
|
-
x.d = null;
|
|
21931
|
-
return;
|
|
21932
|
-
}
|
|
21933
|
-
return parseDecimal(x, v.toString());
|
|
21934
|
-
}
|
|
21935
|
-
if (t === "string") {
|
|
21936
|
-
if ((i2 = v.charCodeAt(0)) === 45) {
|
|
21937
|
-
v = v.slice(1);
|
|
21938
|
-
x.s = -1;
|
|
21939
|
-
} else {
|
|
21940
|
-
if (i2 === 43)
|
|
21941
|
-
v = v.slice(1);
|
|
21942
|
-
x.s = 1;
|
|
21943
|
-
}
|
|
21944
|
-
return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
|
|
21945
|
-
}
|
|
21946
|
-
if (t === "bigint") {
|
|
21947
|
-
if (v < 0) {
|
|
21948
|
-
v = -v;
|
|
21949
|
-
x.s = -1;
|
|
21950
|
-
} else {
|
|
21951
|
-
x.s = 1;
|
|
21952
|
-
}
|
|
21953
|
-
return parseDecimal(x, v.toString());
|
|
21954
|
-
}
|
|
21955
|
-
throw Error(invalidArgument + v);
|
|
21956
|
-
}
|
|
21957
|
-
Decimal.prototype = P;
|
|
21958
|
-
Decimal.ROUND_UP = 0;
|
|
21959
|
-
Decimal.ROUND_DOWN = 1;
|
|
21960
|
-
Decimal.ROUND_CEIL = 2;
|
|
21961
|
-
Decimal.ROUND_FLOOR = 3;
|
|
21962
|
-
Decimal.ROUND_HALF_UP = 4;
|
|
21963
|
-
Decimal.ROUND_HALF_DOWN = 5;
|
|
21964
|
-
Decimal.ROUND_HALF_EVEN = 6;
|
|
21965
|
-
Decimal.ROUND_HALF_CEIL = 7;
|
|
21966
|
-
Decimal.ROUND_HALF_FLOOR = 8;
|
|
21967
|
-
Decimal.EUCLID = 9;
|
|
21968
|
-
Decimal.config = Decimal.set = config;
|
|
21969
|
-
Decimal.clone = clone;
|
|
21970
|
-
Decimal.isDecimal = isDecimalInstance;
|
|
21971
|
-
Decimal.abs = abs;
|
|
21972
|
-
Decimal.acos = acos;
|
|
21973
|
-
Decimal.acosh = acosh;
|
|
21974
|
-
Decimal.add = add;
|
|
21975
|
-
Decimal.asin = asin;
|
|
21976
|
-
Decimal.asinh = asinh;
|
|
21977
|
-
Decimal.atan = atan;
|
|
21978
|
-
Decimal.atanh = atanh;
|
|
21979
|
-
Decimal.atan2 = atan2;
|
|
21980
|
-
Decimal.cbrt = cbrt;
|
|
21981
|
-
Decimal.ceil = ceil;
|
|
21982
|
-
Decimal.clamp = clamp;
|
|
21983
|
-
Decimal.cos = cos;
|
|
21984
|
-
Decimal.cosh = cosh;
|
|
21985
|
-
Decimal.div = div;
|
|
21986
|
-
Decimal.exp = exp;
|
|
21987
|
-
Decimal.floor = floor;
|
|
21988
|
-
Decimal.hypot = hypot;
|
|
21989
|
-
Decimal.ln = ln;
|
|
21990
|
-
Decimal.log = log;
|
|
21991
|
-
Decimal.log10 = log10;
|
|
21992
|
-
Decimal.log2 = log2;
|
|
21993
|
-
Decimal.max = max;
|
|
21994
|
-
Decimal.min = min;
|
|
21995
|
-
Decimal.mod = mod;
|
|
21996
|
-
Decimal.mul = mul;
|
|
21997
|
-
Decimal.pow = pow;
|
|
21998
|
-
Decimal.random = random;
|
|
21999
|
-
Decimal.round = round;
|
|
22000
|
-
Decimal.sign = sign;
|
|
22001
|
-
Decimal.sin = sin;
|
|
22002
|
-
Decimal.sinh = sinh;
|
|
22003
|
-
Decimal.sqrt = sqrt;
|
|
22004
|
-
Decimal.sub = sub;
|
|
22005
|
-
Decimal.sum = sum;
|
|
22006
|
-
Decimal.tan = tan;
|
|
22007
|
-
Decimal.tanh = tanh;
|
|
22008
|
-
Decimal.trunc = trunc;
|
|
22009
|
-
if (obj === undefined)
|
|
22010
|
-
obj = {};
|
|
22011
|
-
if (obj) {
|
|
22012
|
-
if (obj.defaults !== true) {
|
|
22013
|
-
ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
|
|
22014
|
-
for (i = 0;i < ps.length; )
|
|
22015
|
-
if (!obj.hasOwnProperty(p = ps[i++]))
|
|
22016
|
-
obj[p] = this[p];
|
|
22017
|
-
}
|
|
22018
|
-
}
|
|
22019
|
-
Decimal.config(obj);
|
|
22020
|
-
return Decimal;
|
|
22021
|
-
}
|
|
22022
|
-
function div(x, y) {
|
|
22023
|
-
return new this(x).div(y);
|
|
22024
|
-
}
|
|
22025
|
-
function exp(x) {
|
|
22026
|
-
return new this(x).exp();
|
|
22027
|
-
}
|
|
22028
|
-
function floor(x) {
|
|
22029
|
-
return finalise(x = new this(x), x.e + 1, 3);
|
|
22030
|
-
}
|
|
22031
|
-
function hypot() {
|
|
22032
|
-
var i, n, t = new this(0);
|
|
22033
|
-
external2 = false;
|
|
22034
|
-
for (i = 0;i < arguments.length; ) {
|
|
22035
|
-
n = new this(arguments[i++]);
|
|
22036
|
-
if (!n.d) {
|
|
22037
|
-
if (n.s) {
|
|
22038
|
-
external2 = true;
|
|
22039
|
-
return new this(1 / 0);
|
|
22040
|
-
}
|
|
22041
|
-
t = n;
|
|
22042
|
-
} else if (t.d) {
|
|
22043
|
-
t = t.plus(n.times(n));
|
|
22044
|
-
}
|
|
22045
|
-
}
|
|
22046
|
-
external2 = true;
|
|
22047
|
-
return t.sqrt();
|
|
22048
|
-
}
|
|
22049
|
-
function isDecimalInstance(obj) {
|
|
22050
|
-
return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
|
|
22051
|
-
}
|
|
22052
|
-
function ln(x) {
|
|
22053
|
-
return new this(x).ln();
|
|
22054
|
-
}
|
|
22055
|
-
function log(x, y) {
|
|
22056
|
-
return new this(x).log(y);
|
|
22057
|
-
}
|
|
22058
|
-
function log2(x) {
|
|
22059
|
-
return new this(x).log(2);
|
|
22060
|
-
}
|
|
22061
|
-
function log10(x) {
|
|
22062
|
-
return new this(x).log(10);
|
|
22063
|
-
}
|
|
22064
|
-
function max() {
|
|
22065
|
-
return maxOrMin(this, arguments, -1);
|
|
22066
|
-
}
|
|
22067
|
-
function min() {
|
|
22068
|
-
return maxOrMin(this, arguments, 1);
|
|
22069
|
-
}
|
|
22070
|
-
function mod(x, y) {
|
|
22071
|
-
return new this(x).mod(y);
|
|
22072
|
-
}
|
|
22073
|
-
function mul(x, y) {
|
|
22074
|
-
return new this(x).mul(y);
|
|
22075
|
-
}
|
|
22076
|
-
function pow(x, y) {
|
|
22077
|
-
return new this(x).pow(y);
|
|
22078
|
-
}
|
|
22079
|
-
function random(sd) {
|
|
22080
|
-
var d, e, k, n, i = 0, r = new this(1), rd = [];
|
|
22081
|
-
if (sd === undefined)
|
|
22082
|
-
sd = this.precision;
|
|
22083
|
-
else
|
|
22084
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
22085
|
-
k = Math.ceil(sd / LOG_BASE);
|
|
22086
|
-
if (!this.crypto) {
|
|
22087
|
-
for (;i < k; )
|
|
22088
|
-
rd[i++] = Math.random() * 1e7 | 0;
|
|
22089
|
-
} else if (crypto.getRandomValues) {
|
|
22090
|
-
d = crypto.getRandomValues(new Uint32Array(k));
|
|
22091
|
-
for (;i < k; ) {
|
|
22092
|
-
n = d[i];
|
|
22093
|
-
if (n >= 4290000000) {
|
|
22094
|
-
d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
22095
|
-
} else {
|
|
22096
|
-
rd[i++] = n % 1e7;
|
|
22097
|
-
}
|
|
22098
|
-
}
|
|
22099
|
-
} else if (crypto.randomBytes) {
|
|
22100
|
-
d = crypto.randomBytes(k *= 4);
|
|
22101
|
-
for (;i < k; ) {
|
|
22102
|
-
n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
|
|
22103
|
-
if (n >= 2140000000) {
|
|
22104
|
-
crypto.randomBytes(4).copy(d, i);
|
|
22105
|
-
} else {
|
|
22106
|
-
rd.push(n % 1e7);
|
|
22107
|
-
i += 4;
|
|
22108
|
-
}
|
|
22109
|
-
}
|
|
22110
|
-
i = k / 4;
|
|
22111
|
-
} else {
|
|
22112
|
-
throw Error(cryptoUnavailable);
|
|
22113
|
-
}
|
|
22114
|
-
k = rd[--i];
|
|
22115
|
-
sd %= LOG_BASE;
|
|
22116
|
-
if (k && sd) {
|
|
22117
|
-
n = mathpow(10, LOG_BASE - sd);
|
|
22118
|
-
rd[i] = (k / n | 0) * n;
|
|
22119
|
-
}
|
|
22120
|
-
for (;rd[i] === 0; i--)
|
|
22121
|
-
rd.pop();
|
|
22122
|
-
if (i < 0) {
|
|
22123
|
-
e = 0;
|
|
22124
|
-
rd = [0];
|
|
22125
|
-
} else {
|
|
22126
|
-
e = -1;
|
|
22127
|
-
for (;rd[0] === 0; e -= LOG_BASE)
|
|
22128
|
-
rd.shift();
|
|
22129
|
-
for (k = 1, n = rd[0];n >= 10; n /= 10)
|
|
22130
|
-
k++;
|
|
22131
|
-
if (k < LOG_BASE)
|
|
22132
|
-
e -= LOG_BASE - k;
|
|
22133
|
-
}
|
|
22134
|
-
r.e = e;
|
|
22135
|
-
r.d = rd;
|
|
22136
|
-
return r;
|
|
22137
|
-
}
|
|
22138
|
-
function round(x) {
|
|
22139
|
-
return finalise(x = new this(x), x.e + 1, this.rounding);
|
|
22140
|
-
}
|
|
22141
|
-
function sign(x) {
|
|
22142
|
-
x = new this(x);
|
|
22143
|
-
return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
|
|
22144
|
-
}
|
|
22145
|
-
function sin(x) {
|
|
22146
|
-
return new this(x).sin();
|
|
22147
|
-
}
|
|
22148
|
-
function sinh(x) {
|
|
22149
|
-
return new this(x).sinh();
|
|
22150
|
-
}
|
|
22151
|
-
function sqrt(x) {
|
|
22152
|
-
return new this(x).sqrt();
|
|
22153
|
-
}
|
|
22154
|
-
function sub(x, y) {
|
|
22155
|
-
return new this(x).sub(y);
|
|
22156
|
-
}
|
|
22157
|
-
function sum() {
|
|
22158
|
-
var i = 0, args = arguments, x = new this(args[i]);
|
|
22159
|
-
external2 = false;
|
|
22160
|
-
for (;x.s && ++i < args.length; )
|
|
22161
|
-
x = x.plus(args[i]);
|
|
22162
|
-
external2 = true;
|
|
22163
|
-
return finalise(x, this.precision, this.rounding);
|
|
22164
|
-
}
|
|
22165
|
-
function tan(x) {
|
|
22166
|
-
return new this(x).tan();
|
|
22167
|
-
}
|
|
22168
|
-
function tanh(x) {
|
|
22169
|
-
return new this(x).tanh();
|
|
22170
|
-
}
|
|
22171
|
-
function trunc(x) {
|
|
22172
|
-
return finalise(x = new this(x), x.e + 1, 1);
|
|
22173
|
-
}
|
|
22174
|
-
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
22175
|
-
P[Symbol.toStringTag] = "Decimal";
|
|
22176
|
-
var Decimal = P.constructor = clone(DEFAULTS);
|
|
22177
|
-
LN10 = new Decimal(LN10);
|
|
22178
|
-
PI = new Decimal(PI);
|
|
22179
|
-
var decimal_default = Decimal;
|
|
22180
|
-
|
|
22181
|
-
// src/common/base/other.ts
|
|
22182
|
-
var delay = (time = 1000) => {
|
|
22183
|
-
return new Promise((resolve2) => setTimeout(resolve2, time));
|
|
22184
|
-
};
|
|
22185
|
-
var calcJsText = (expr, context) => {
|
|
22186
|
-
const keys = Object.keys(context);
|
|
22187
|
-
const values = keys.map((key2) => context[key2]);
|
|
22188
|
-
return Function(...keys, `return (${expr})`)(...values);
|
|
22189
|
-
};
|
|
22190
|
-
var optionsToEnum = (options, text, key2) => {
|
|
22191
|
-
return options.reduce((acc, cur) => {
|
|
22192
|
-
acc[cur[key2]] = {
|
|
22193
|
-
text: cur[text]
|
|
22194
|
-
};
|
|
22195
|
-
return acc;
|
|
22196
|
-
}, {});
|
|
22197
|
-
};
|
|
22198
|
-
var performDecimalOperation = (num1, num2, operator) => {
|
|
22199
|
-
if (num1 === undefined || num2 === undefined || !operator) {
|
|
22200
|
-
return;
|
|
22201
|
-
}
|
|
22202
|
-
const decimalNum1 = new decimal_default(Number(num1));
|
|
22203
|
-
const decimalNum2 = new decimal_default(Number(num2));
|
|
22204
|
-
switch (operator) {
|
|
22205
|
-
case "+":
|
|
22206
|
-
return decimalNum1.plus(decimalNum2).toNumber();
|
|
22207
|
-
case "-":
|
|
22208
|
-
return decimalNum1.minus(decimalNum2).toNumber();
|
|
22209
|
-
case "*":
|
|
22210
|
-
return decimalNum1.times(decimalNum2).toNumber();
|
|
22211
|
-
case "/":
|
|
22212
|
-
if (num2 !== 0) {
|
|
22213
|
-
return decimalNum1.dividedBy(decimalNum2).toNumber();
|
|
22214
|
-
} else {
|
|
22215
|
-
console.error("Division by zero is not allowed.");
|
|
22216
|
-
return NaN;
|
|
22217
|
-
}
|
|
22218
|
-
default:
|
|
22219
|
-
console.error("Invalid operator:", operator);
|
|
22220
|
-
return NaN;
|
|
22221
|
-
}
|
|
22222
|
-
};
|
|
22223
|
-
var printConsoleLog = (type, path, params, response) => {
|
|
22224
|
-
const styles = {
|
|
22225
|
-
header: "color: #fff; background: #35495e; padding: 2px 8px; border-radius: 3px 0 0 3px;",
|
|
22226
|
-
value: "color: #35495e; background: #f0f4f8; padding: 2px 6px; border-radius: 0 3px 3px 0;",
|
|
22227
|
-
separator: "color: #409EFF; margin: 0 4px;"
|
|
22228
|
-
};
|
|
22229
|
-
console.groupCollapsed(`666 %c${type}%c${path}`, styles.header, styles.value);
|
|
22230
|
-
if (params) {
|
|
22231
|
-
console.table(params);
|
|
22232
|
-
}
|
|
22233
|
-
if (response) {
|
|
22234
|
-
console.table(response);
|
|
22235
|
-
}
|
|
22236
|
-
console.groupEnd();
|
|
22237
|
-
};
|
|
22238
|
-
|
|
22239
|
-
// src/common/base/array.ts
|
|
22240
|
-
var shuffleArray = (array) => {
|
|
22241
|
-
const shuffledArray = [...array];
|
|
22242
|
-
for (let i = shuffledArray.length - 1;i > 0; i--) {
|
|
22243
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
22244
|
-
[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
|
|
22245
|
-
}
|
|
22246
|
-
return shuffledArray;
|
|
22247
|
-
};
|
|
22248
|
-
var removeSimilarDuplicates = (arr, threshold, isLog) => {
|
|
22249
|
-
const uniqueArray = [];
|
|
22250
|
-
const similarPairs = [];
|
|
22251
|
-
for (const str of arr) {
|
|
22252
|
-
const isSimilar = uniqueArray.some((uniqueStr) => {
|
|
22253
|
-
const distance = levenshteinDistance(str, uniqueStr);
|
|
22254
|
-
if (distance <= threshold) {
|
|
22255
|
-
similarPairs.push([str, uniqueStr]);
|
|
22256
|
-
return true;
|
|
22257
|
-
}
|
|
22258
|
-
return false;
|
|
22259
|
-
});
|
|
22260
|
-
if (!isSimilar) {
|
|
22261
|
-
uniqueArray.push(str);
|
|
22262
|
-
}
|
|
22263
|
-
}
|
|
22264
|
-
if (isLog) {
|
|
22265
|
-
if (similarPairs.length > 0) {
|
|
22266
|
-
similarPairs.forEach((pair) => {
|
|
22267
|
-
console.log(pair[0]);
|
|
22268
|
-
console.log(pair[1]);
|
|
22269
|
-
console.log();
|
|
22270
|
-
});
|
|
22271
|
-
} else {
|
|
22272
|
-
console.log("没有找到类似的字符串");
|
|
22273
|
-
}
|
|
22274
|
-
}
|
|
22275
|
-
return uniqueArray;
|
|
22276
|
-
};
|
|
22277
|
-
var getTotal = (arr, key2) => {
|
|
22278
|
-
if (!Array.isArray(arr) || !key2) {
|
|
22279
|
-
return 0;
|
|
22280
|
-
}
|
|
22281
|
-
return arr.reduce((total, item) => {
|
|
22282
|
-
const itemValue = Number(item[key2]);
|
|
22283
|
-
if (!isNaN(itemValue)) {
|
|
22284
|
-
return performDecimalOperation(total, itemValue, "+");
|
|
22285
|
-
}
|
|
22286
|
-
return total;
|
|
22287
|
-
}, 0);
|
|
22288
|
-
};
|
|
22289
|
-
|
|
22290
|
-
// src/common/base/number.ts
|
|
22291
|
-
var getRandomNum = (min2, max2) => {
|
|
22292
|
-
return Math.floor(Math.random() * (max2 - min2 + 1) + min2);
|
|
22293
|
-
};
|
|
22294
|
-
var limitDecimals = (v, num = 2, isForce) => {
|
|
22295
|
-
let value = parseFloat(v);
|
|
22296
|
-
if (isNaN(value)) {
|
|
22297
|
-
if (isForce) {
|
|
22298
|
-
value = 0;
|
|
22299
|
-
} else {
|
|
22300
|
-
return "";
|
|
22301
|
-
}
|
|
22302
|
-
}
|
|
22303
|
-
return value.toFixed(num).toString();
|
|
22304
|
-
};
|
|
22305
|
-
var formatFileSize = (bytes) => {
|
|
22306
|
-
if (!bytes || bytes === 0) {
|
|
22307
|
-
return "0 B";
|
|
22308
|
-
}
|
|
22309
|
-
const base = 1024;
|
|
22310
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
22311
|
-
const index = Math.floor(Math.log(bytes) / Math.log(base));
|
|
22312
|
-
return `${(bytes / Math.pow(base, index)).toFixed(1).replace(/\.0$/, "")} ${sizes[index]}`;
|
|
22313
|
-
};
|
|
22314
|
-
var isValidNumber = (value) => {
|
|
22315
|
-
if (typeof value !== "number") {
|
|
22316
|
-
return false;
|
|
22317
|
-
}
|
|
22318
|
-
if (isNaN(value)) {
|
|
22319
|
-
return false;
|
|
22320
|
-
}
|
|
22321
|
-
if (value === Infinity || value === -Infinity) {
|
|
22322
|
-
return false;
|
|
22323
|
-
}
|
|
22324
|
-
return true;
|
|
22325
|
-
};
|
|
22326
|
-
var numberWithCommas = (x) => {
|
|
22327
|
-
if (x === undefined || x === null) {
|
|
22328
|
-
return "";
|
|
22329
|
-
}
|
|
22330
|
-
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
22331
|
-
};
|
|
22332
|
-
|
|
22333
|
-
// src/common/base/object.ts
|
|
22334
|
-
var findItem = (list, attr, value) => {
|
|
22335
|
-
return list.find((item) => value === undefined ? item[attr] : item[attr] === value);
|
|
22336
|
-
};
|
|
22337
|
-
var filterParams = (params, deep = false) => {
|
|
22338
|
-
const clean = (value) => {
|
|
22339
|
-
if (value === undefined || value === null) {
|
|
22340
|
-
return;
|
|
22341
|
-
}
|
|
22342
|
-
if (!deep) {
|
|
22343
|
-
return value;
|
|
22344
|
-
}
|
|
22345
|
-
if (Array.isArray(value)) {
|
|
22346
|
-
return value.map((v) => clean(v)).filter((v) => v !== undefined);
|
|
22347
|
-
}
|
|
22348
|
-
if (typeof value === "object") {
|
|
22349
|
-
return Object.entries(value).reduce((acc, [k, v]) => {
|
|
22350
|
-
const cleaned = clean(v);
|
|
22351
|
-
if (cleaned !== undefined)
|
|
22352
|
-
acc[k] = cleaned;
|
|
22353
|
-
return acc;
|
|
22354
|
-
}, {});
|
|
22355
|
-
}
|
|
22356
|
-
return value;
|
|
22357
|
-
};
|
|
22358
|
-
return clean(params);
|
|
22359
|
-
};
|
|
22360
|
-
var watch = {
|
|
22361
|
-
observe(obj, key2, watchFun) {
|
|
22362
|
-
const val = obj[key2];
|
|
22363
|
-
Object.defineProperty(obj, key2, {
|
|
22364
|
-
configurable: true,
|
|
22365
|
-
enumerable: true,
|
|
22366
|
-
set(value) {
|
|
22367
|
-
obj[key2] = value;
|
|
22368
|
-
watchFun(value, val);
|
|
22369
|
-
},
|
|
22370
|
-
get() {
|
|
22371
|
-
return val;
|
|
22372
|
-
}
|
|
22373
|
-
});
|
|
22374
|
-
},
|
|
22375
|
-
setWatcher(data = {}, watch2 = {}) {
|
|
22376
|
-
Object.keys(watch2).forEach((v) => {
|
|
22377
|
-
this.observe(data, v, watch2[v]);
|
|
22378
|
-
});
|
|
22379
|
-
}
|
|
22380
|
-
};
|
|
22381
|
-
|
|
22382
|
-
// src/common/base/promise.ts
|
|
22383
|
-
var executePromise = async (promise) => {
|
|
22384
|
-
const start = Date.now();
|
|
22385
|
-
const result = await promise;
|
|
22386
|
-
const time = Date.now() - start;
|
|
22387
|
-
return {
|
|
22388
|
-
result,
|
|
22389
|
-
time
|
|
22390
|
-
};
|
|
22391
|
-
};
|
|
22392
|
-
var retryPromise = async (promiseFn, retryInterval = 1000, retryCount = 3) => {
|
|
22393
|
-
try {
|
|
22394
|
-
return await promiseFn();
|
|
22395
|
-
} catch (error) {
|
|
22396
|
-
if (retryCount <= 0) {
|
|
22397
|
-
throw error;
|
|
22398
|
-
}
|
|
22399
|
-
await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
|
|
22400
|
-
return retryPromise(promiseFn, retryCount - 1, retryInterval);
|
|
20530
|
+
var retryPromise = async (promiseFn, retryCount = 3, retryInterval = 1000) => {
|
|
20531
|
+
try {
|
|
20532
|
+
return await promiseFn();
|
|
20533
|
+
} catch (error) {
|
|
20534
|
+
if (retryCount <= 0) {
|
|
20535
|
+
throw error;
|
|
20536
|
+
}
|
|
20537
|
+
await new Promise((resolve2) => setTimeout(resolve2, retryInterval));
|
|
20538
|
+
return retryPromise(promiseFn, retryCount - 1, retryInterval);
|
|
22401
20539
|
}
|
|
22402
20540
|
};
|
|
22403
20541
|
// src/common/enum/index.ts
|
|
@@ -22405,10 +20543,10 @@ class EnumItem {
|
|
|
22405
20543
|
label;
|
|
22406
20544
|
value;
|
|
22407
20545
|
extra;
|
|
22408
|
-
constructor(
|
|
22409
|
-
this.value =
|
|
22410
|
-
this.label =
|
|
22411
|
-
this.extra =
|
|
20546
|
+
constructor(config) {
|
|
20547
|
+
this.value = config.value;
|
|
20548
|
+
this.label = config.label;
|
|
20549
|
+
this.extra = config.extra;
|
|
22412
20550
|
}
|
|
22413
20551
|
}
|
|
22414
20552
|
var Enum = {
|
|
@@ -22447,19 +20585,6 @@ var Enum = {
|
|
|
22447
20585
|
return enumObj;
|
|
22448
20586
|
}
|
|
22449
20587
|
};
|
|
22450
|
-
// src/common/image/index.ts
|
|
22451
|
-
async function imageToBase64(url) {
|
|
22452
|
-
try {
|
|
22453
|
-
const response = await axios_default.get(url, {
|
|
22454
|
-
responseType: "arraybuffer"
|
|
22455
|
-
});
|
|
22456
|
-
const base64String = Buffer.from(response.data).toString("base64");
|
|
22457
|
-
return `data:image/*;base64,${base64String}`;
|
|
22458
|
-
} catch (error) {
|
|
22459
|
-
console.error("Failed to fetch the image:", error);
|
|
22460
|
-
throw error;
|
|
22461
|
-
}
|
|
22462
|
-
}
|
|
22463
20588
|
// src/common/other/index.ts
|
|
22464
20589
|
function getPublicUrl(objectKey) {
|
|
22465
20590
|
if (!objectKey) {
|
|
@@ -22473,6 +20598,41 @@ function getPublicUrl(objectKey) {
|
|
|
22473
20598
|
const key2 = objectKey.startsWith("/") ? objectKey : `/${objectKey}`;
|
|
22474
20599
|
return `${baseUrl}${key2}`;
|
|
22475
20600
|
}
|
|
20601
|
+
// src/common/antd/index.ts
|
|
20602
|
+
var options2valueEnum = (options) => {
|
|
20603
|
+
return (options || []).reduce((acc, cur) => {
|
|
20604
|
+
acc[cur] = { text: cur };
|
|
20605
|
+
return acc;
|
|
20606
|
+
}, {});
|
|
20607
|
+
};
|
|
20608
|
+
var optionsToEnum = (options, text, key2) => {
|
|
20609
|
+
return options.reduce((acc, cur) => {
|
|
20610
|
+
acc[cur[key2]] = {
|
|
20611
|
+
text: cur[text]
|
|
20612
|
+
};
|
|
20613
|
+
return acc;
|
|
20614
|
+
}, {});
|
|
20615
|
+
};
|
|
20616
|
+
var transformOptions = (inputArray) => {
|
|
20617
|
+
if (!inputArray?.length) {
|
|
20618
|
+
return [];
|
|
20619
|
+
}
|
|
20620
|
+
return inputArray.map((item) => {
|
|
20621
|
+
if (typeof item === "string") {
|
|
20622
|
+
return { label: item, value: item };
|
|
20623
|
+
}
|
|
20624
|
+
return item;
|
|
20625
|
+
});
|
|
20626
|
+
};
|
|
20627
|
+
var getColumns = (dataSource) => {
|
|
20628
|
+
if (!Array.isArray(dataSource)) {
|
|
20629
|
+
return [];
|
|
20630
|
+
}
|
|
20631
|
+
return Object.keys(dataSource?.[0] || {}).map((item) => ({
|
|
20632
|
+
title: item,
|
|
20633
|
+
dataIndex: item
|
|
20634
|
+
}));
|
|
20635
|
+
};
|
|
22476
20636
|
// src/common/dayjs/index.ts
|
|
22477
20637
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
22478
20638
|
var import_isBetween = __toESM(require_isBetween(), 1);
|
|
@@ -22502,135 +20662,59 @@ var Timezone;
|
|
|
22502
20662
|
Timezone2["EuropeLondon"] = "Europe/London";
|
|
22503
20663
|
Timezone2["EuropeBerlin"] = "Europe/Berlin";
|
|
22504
20664
|
})(Timezone ||= {});
|
|
22505
|
-
var initChinaDayjs = () => {
|
|
22506
|
-
import_dayjs.default.locale("zh-cn");
|
|
22507
|
-
import_dayjs.default.tz.setDefault("Asia/Shanghai" /* AsiaShanghai */);
|
|
22508
|
-
import_dayjs.default.updateLocale("zh-cn", {
|
|
22509
|
-
weekStart: 1
|
|
22510
|
-
});
|
|
22511
|
-
return import_dayjs.default;
|
|
22512
|
-
};
|
|
22513
|
-
var chinaDayjs = initChinaDayjs();
|
|
22514
20665
|
var dayjs_default = import_dayjs.default;
|
|
22515
20666
|
// src/web/element.ts
|
|
22516
20667
|
var scrollIntoView = (el, option) => {
|
|
22517
|
-
|
|
22518
|
-
return;
|
|
22519
|
-
}
|
|
22520
|
-
el.scrollIntoView({ behavior: "smooth", block: "start", ...option });
|
|
22521
|
-
};
|
|
22522
|
-
var getElement = (el) => {
|
|
22523
|
-
const element = typeof el === "string" ? document.querySelector(el) : el;
|
|
22524
|
-
if (!element) {
|
|
22525
|
-
return {
|
|
22526
|
-
element: null,
|
|
22527
|
-
originalStyle: {}
|
|
22528
|
-
};
|
|
22529
|
-
}
|
|
22530
|
-
return {
|
|
22531
|
-
element,
|
|
22532
|
-
originalStyle: window.getComputedStyle(element)
|
|
22533
|
-
};
|
|
20668
|
+
el?.scrollIntoView({ behavior: "smooth", block: "start", ...option });
|
|
22534
20669
|
};
|
|
22535
20670
|
var isElementInViewport = (el) => {
|
|
22536
|
-
const
|
|
20671
|
+
const element = document.querySelector(el);
|
|
22537
20672
|
if (!element) {
|
|
22538
20673
|
return;
|
|
22539
20674
|
}
|
|
22540
20675
|
const rect = element.getBoundingClientRect();
|
|
22541
20676
|
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
22542
20677
|
};
|
|
22543
|
-
|
|
22544
|
-
// src/web/style.ts
|
|
22545
|
-
var hexToRgba2 = (hexColor, a = 1) => {
|
|
22546
|
-
let red = parseInt(hexColor.substr(1, 2), 16);
|
|
22547
|
-
let green = parseInt(hexColor.substr(3, 2), 16);
|
|
22548
|
-
let blue = parseInt(hexColor.substr(5, 2), 16);
|
|
22549
|
-
return {
|
|
22550
|
-
nums: { red, green, blue },
|
|
22551
|
-
text: `rgba(${red}, ${green}, ${blue}, ${a})`
|
|
22552
|
-
};
|
|
22553
|
-
};
|
|
22554
|
-
var flashBackground = (el, color, a = 1) => {
|
|
22555
|
-
const { element, originalStyle } = getElement(el);
|
|
22556
|
-
if (!element) {
|
|
22557
|
-
return;
|
|
22558
|
-
}
|
|
22559
|
-
anime_es_default({
|
|
22560
|
-
targets: element,
|
|
22561
|
-
backgroundColor: [hexToRgba2(color, a).text, originalStyle.backgroundColor],
|
|
22562
|
-
duration: 1500,
|
|
22563
|
-
easing: "easeInOutSine",
|
|
22564
|
-
direction: "alternate",
|
|
22565
|
-
loop: false
|
|
22566
|
-
});
|
|
22567
|
-
};
|
|
22568
|
-
var flashBorder = (el, color, a = 1) => {
|
|
22569
|
-
const { element } = getElement(el);
|
|
22570
|
-
if (!element) {
|
|
22571
|
-
return;
|
|
22572
|
-
}
|
|
22573
|
-
anime_es_default({
|
|
22574
|
-
targets: element,
|
|
22575
|
-
border: [`1px solid ${hexToRgba2(color, a).text}`, "none"],
|
|
22576
|
-
duration: 1500,
|
|
22577
|
-
easing: "easeInOutSine",
|
|
22578
|
-
direction: "alternate",
|
|
22579
|
-
loop: false
|
|
22580
|
-
});
|
|
22581
|
-
};
|
|
22582
|
-
// src/web/location.ts
|
|
22583
|
-
var import_lodash = __toESM(require_lodash(), 1);
|
|
22584
|
-
var url2Params = (url = location.href) => {
|
|
22585
|
-
url = decodeURIComponent(url);
|
|
22586
|
-
let jsonList = {};
|
|
22587
|
-
if (url.indexOf("?") > -1) {
|
|
22588
|
-
let str = url.slice(url.indexOf("?") + 1);
|
|
22589
|
-
let strs = str.split("&");
|
|
22590
|
-
for (let i = 0;i < strs.length; i++) {
|
|
22591
|
-
jsonList[strs[i].split("=")[0]] = strs[i].split("=")[1];
|
|
22592
|
-
}
|
|
22593
|
-
}
|
|
22594
|
-
return jsonList || {};
|
|
22595
|
-
};
|
|
22596
|
-
var params2Url = (params) => {
|
|
22597
|
-
let url = "";
|
|
22598
|
-
for (let k in params) {
|
|
22599
|
-
if (k) {
|
|
22600
|
-
url += `${k}=${params[k]}&`;
|
|
22601
|
-
}
|
|
22602
|
-
}
|
|
22603
|
-
return url.substr(0, url.length - 1);
|
|
22604
|
-
};
|
|
22605
|
-
var setUrlParams = (key2, value, keepName) => {
|
|
22606
|
-
if (key2 === undefined || value === undefined)
|
|
22607
|
-
return;
|
|
22608
|
-
let allParams = url2Params();
|
|
22609
|
-
if (keepName) {
|
|
22610
|
-
allParams = import_lodash.pick(allParams, keepName) || {};
|
|
22611
|
-
}
|
|
22612
|
-
allParams[key2] = encodeURIComponent(value);
|
|
22613
|
-
const url = location.href;
|
|
22614
|
-
const sliceEnd = url.indexOf("?") === -1 ? url.length : url.indexOf("?");
|
|
22615
|
-
const domainPath = url.slice(0, sliceEnd);
|
|
22616
|
-
const params = params2Url(allParams);
|
|
22617
|
-
location.replace(`${domainPath}?${params}`);
|
|
22618
|
-
};
|
|
22619
|
-
var urlGetPath = (url = location.href) => {
|
|
22620
|
-
let lastIndex = url.indexOf("?");
|
|
22621
|
-
if (lastIndex === -1) {
|
|
22622
|
-
lastIndex = url.length;
|
|
22623
|
-
}
|
|
22624
|
-
return url.slice(0, lastIndex);
|
|
22625
|
-
};
|
|
22626
20678
|
// src/web/clipboard.ts
|
|
22627
20679
|
var readClipboard = async () => {
|
|
22628
20680
|
try {
|
|
22629
|
-
return
|
|
20681
|
+
return navigator.clipboard.readText();
|
|
22630
20682
|
} catch (error) {
|
|
22631
20683
|
return "";
|
|
22632
20684
|
}
|
|
22633
20685
|
};
|
|
20686
|
+
// src/web/download.ts
|
|
20687
|
+
var import_dayjs3 = __toESM(require_dayjs_min(), 1);
|
|
20688
|
+
var import_papaparse = __toESM(require_papaparse_min(), 1);
|
|
20689
|
+
var downloadDataSource = (dataSource, name, columns) => {
|
|
20690
|
+
if (!Array.isArray(dataSource)) {
|
|
20691
|
+
return;
|
|
20692
|
+
}
|
|
20693
|
+
dataSource = dataSource.map((item) => {
|
|
20694
|
+
const obj = {};
|
|
20695
|
+
for (const key2 in item) {
|
|
20696
|
+
if (item.hasOwnProperty(key2)) {
|
|
20697
|
+
const element = item[key2];
|
|
20698
|
+
if (key2 !== "rowSpan") {
|
|
20699
|
+
if (typeof element === "string" || typeof element === "number") {
|
|
20700
|
+
obj[key2] = element;
|
|
20701
|
+
} else if (Array.isArray(element)) {
|
|
20702
|
+
obj[key2] = element.join(",");
|
|
20703
|
+
} else if (typeof element === "object") {
|
|
20704
|
+
obj[key2] = JSON.stringify(element);
|
|
20705
|
+
}
|
|
20706
|
+
}
|
|
20707
|
+
}
|
|
20708
|
+
}
|
|
20709
|
+
return obj;
|
|
20710
|
+
});
|
|
20711
|
+
const csv = import_papaparse.default.unparse(dataSource, columns ? { columns: columns.map((i) => i.dataIndex) } : undefined);
|
|
20712
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
20713
|
+
const downloadLink = document.createElement("a");
|
|
20714
|
+
downloadLink.href = URL.createObjectURL(blob);
|
|
20715
|
+
downloadLink.download = (name ? `${name}_` : "") + import_dayjs3.default().format("YYYY-MM-DD HH:mm:ss") + ".csv";
|
|
20716
|
+
downloadLink.click();
|
|
20717
|
+
};
|
|
22634
20718
|
|
|
22635
20719
|
// src/web.ts
|
|
22636
|
-
var _ =
|
|
20720
|
+
var _ = import_lodash.default;
|