@wzyjs/utils 0.3.6 → 0.3.7
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/common/ai/index.d.ts +2 -0
- package/dist/common/index.d.ts +3 -3
- package/dist/node.cjs.js +2759 -39
- package/dist/node.d.ts +2 -2
- package/dist/node.esm.js +2763 -45
- package/dist/web.cjs.js +20663 -17943
- package/dist/web.d.ts +5 -5
- package/dist/web.esm.js +20329 -17611
- package/package.json +2 -2
- /package/dist/common/{dayjs.d.ts → dayjs/index.d.ts} +0 -0
- /package/dist/common/{enum.d.ts → enum/index.d.ts} +0 -0
- /package/dist/common/{image.d.ts → image/index.d.ts} +0 -0
package/dist/node.cjs.js
CHANGED
|
@@ -373,9 +373,9 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
373
373
|
var freeProcess = moduleExports && freeGlobal.process;
|
|
374
374
|
var nodeUtil = function() {
|
|
375
375
|
try {
|
|
376
|
-
var
|
|
377
|
-
if (
|
|
378
|
-
return
|
|
376
|
+
var types2 = freeModule && freeModule.require && freeModule.require("util").types;
|
|
377
|
+
if (types2) {
|
|
378
|
+
return types2;
|
|
379
379
|
}
|
|
380
380
|
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
381
381
|
} catch (e) {}
|
|
@@ -1204,7 +1204,7 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
1204
1204
|
if (typeof func != "function") {
|
|
1205
1205
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
1206
1206
|
}
|
|
1207
|
-
return
|
|
1207
|
+
return setTimeout2(function() {
|
|
1208
1208
|
func.apply(undefined2, args);
|
|
1209
1209
|
}, wait);
|
|
1210
1210
|
}
|
|
@@ -3013,7 +3013,7 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
3013
3013
|
return object[key];
|
|
3014
3014
|
}
|
|
3015
3015
|
var setData = shortOut(baseSetData);
|
|
3016
|
-
var
|
|
3016
|
+
var setTimeout2 = ctxSetTimeout || function(func, wait) {
|
|
3017
3017
|
return root.setTimeout(func, wait);
|
|
3018
3018
|
};
|
|
3019
3019
|
var setToString = shortOut(baseSetToString);
|
|
@@ -3803,7 +3803,7 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
3803
3803
|
}
|
|
3804
3804
|
function leadingEdge(time) {
|
|
3805
3805
|
lastInvokeTime = time;
|
|
3806
|
-
timerId =
|
|
3806
|
+
timerId = setTimeout2(timerExpired, wait);
|
|
3807
3807
|
return leading ? invokeFunc(time) : result2;
|
|
3808
3808
|
}
|
|
3809
3809
|
function remainingWait(time) {
|
|
@@ -3819,7 +3819,7 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
3819
3819
|
if (shouldInvoke(time)) {
|
|
3820
3820
|
return trailingEdge(time);
|
|
3821
3821
|
}
|
|
3822
|
-
timerId =
|
|
3822
|
+
timerId = setTimeout2(timerExpired, remainingWait(time));
|
|
3823
3823
|
}
|
|
3824
3824
|
function trailingEdge(time) {
|
|
3825
3825
|
timerId = undefined2;
|
|
@@ -3850,12 +3850,12 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
3850
3850
|
}
|
|
3851
3851
|
if (maxing) {
|
|
3852
3852
|
clearTimeout(timerId);
|
|
3853
|
-
timerId =
|
|
3853
|
+
timerId = setTimeout2(timerExpired, wait);
|
|
3854
3854
|
return invokeFunc(lastCallTime);
|
|
3855
3855
|
}
|
|
3856
3856
|
}
|
|
3857
3857
|
if (timerId === undefined2) {
|
|
3858
|
-
timerId =
|
|
3858
|
+
timerId = setTimeout2(timerExpired, wait);
|
|
3859
3859
|
}
|
|
3860
3860
|
return result2;
|
|
3861
3861
|
}
|
|
@@ -4062,7 +4062,7 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
4062
4062
|
var tag = baseGetTag(value);
|
|
4063
4063
|
return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject(value);
|
|
4064
4064
|
}
|
|
4065
|
-
function
|
|
4065
|
+
function isFinite2(value) {
|
|
4066
4066
|
return typeof value == "number" && nativeIsFinite(value);
|
|
4067
4067
|
}
|
|
4068
4068
|
function isFunction(value) {
|
|
@@ -4093,7 +4093,7 @@ var require_lodash = __commonJS((exports2, module2) => {
|
|
|
4093
4093
|
customizer = typeof customizer == "function" ? customizer : undefined2;
|
|
4094
4094
|
return baseIsMatch(object, source, getMatchData(source), customizer);
|
|
4095
4095
|
}
|
|
4096
|
-
function
|
|
4096
|
+
function isNaN2(value) {
|
|
4097
4097
|
return isNumber(value) && value != +value;
|
|
4098
4098
|
}
|
|
4099
4099
|
function isNative(value) {
|
|
@@ -4752,7 +4752,7 @@ __p += '`;
|
|
|
4752
4752
|
}
|
|
4753
4753
|
return result2 + omission;
|
|
4754
4754
|
}
|
|
4755
|
-
function
|
|
4755
|
+
function unescape2(string) {
|
|
4756
4756
|
string = toString(string);
|
|
4757
4757
|
return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar) : string;
|
|
4758
4758
|
}
|
|
@@ -5176,14 +5176,14 @@ __p += '`;
|
|
|
5176
5176
|
lodash.isEqual = isEqual;
|
|
5177
5177
|
lodash.isEqualWith = isEqualWith;
|
|
5178
5178
|
lodash.isError = isError;
|
|
5179
|
-
lodash.isFinite =
|
|
5179
|
+
lodash.isFinite = isFinite2;
|
|
5180
5180
|
lodash.isFunction = isFunction;
|
|
5181
5181
|
lodash.isInteger = isInteger;
|
|
5182
5182
|
lodash.isLength = isLength;
|
|
5183
5183
|
lodash.isMap = isMap;
|
|
5184
5184
|
lodash.isMatch = isMatch;
|
|
5185
5185
|
lodash.isMatchWith = isMatchWith;
|
|
5186
|
-
lodash.isNaN =
|
|
5186
|
+
lodash.isNaN = isNaN2;
|
|
5187
5187
|
lodash.isNative = isNative;
|
|
5188
5188
|
lodash.isNil = isNil;
|
|
5189
5189
|
lodash.isNull = isNull;
|
|
@@ -5265,7 +5265,7 @@ __p += '`;
|
|
|
5265
5265
|
lodash.trimEnd = trimEnd;
|
|
5266
5266
|
lodash.trimStart = trimStart;
|
|
5267
5267
|
lodash.truncate = truncate;
|
|
5268
|
-
lodash.unescape =
|
|
5268
|
+
lodash.unescape = unescape2;
|
|
5269
5269
|
lodash.uniqueId = uniqueId;
|
|
5270
5270
|
lodash.upperCase = upperCase;
|
|
5271
5271
|
lodash.upperFirst = upperFirst;
|
|
@@ -5460,6 +5460,7 @@ __p += '`;
|
|
|
5460
5460
|
var exports_node = {};
|
|
5461
5461
|
__export(exports_node, {
|
|
5462
5462
|
z: () => exports_external,
|
|
5463
|
+
watch: () => watch,
|
|
5463
5464
|
void: () => voidType,
|
|
5464
5465
|
util: () => util,
|
|
5465
5466
|
uploadFile: () => uploadFile,
|
|
@@ -5468,26 +5469,37 @@ __export(exports_node, {
|
|
|
5468
5469
|
undefined: () => undefinedType,
|
|
5469
5470
|
tuple: () => tupleType,
|
|
5470
5471
|
transformer: () => effectsType,
|
|
5472
|
+
toString: () => toString,
|
|
5471
5473
|
symbol: () => symbolType,
|
|
5472
5474
|
string: () => stringType,
|
|
5473
5475
|
strictObject: () => strictObjectType,
|
|
5476
|
+
shuffleArray: () => shuffleArray,
|
|
5474
5477
|
setErrorMap: () => setErrorMap,
|
|
5475
5478
|
setCookie: () => setCookie,
|
|
5476
5479
|
set: () => setType,
|
|
5477
5480
|
sendMail: () => sendMail,
|
|
5478
5481
|
schedule: () => schedule,
|
|
5482
|
+
retryPromise: () => retryPromise,
|
|
5479
5483
|
replaceContentInFile: () => replaceContentInFile,
|
|
5484
|
+
replaceByVariables: () => replaceByVariables,
|
|
5485
|
+
replaceByRules: () => replaceByRules,
|
|
5486
|
+
replaceAll: () => replaceAll,
|
|
5487
|
+
removeSimilarDuplicates: () => removeSimilarDuplicates,
|
|
5480
5488
|
record: () => recordType,
|
|
5481
5489
|
quotelessJson: () => quotelessJson,
|
|
5482
5490
|
promise: () => promiseType,
|
|
5491
|
+
printConsoleLog: () => printConsoleLog,
|
|
5483
5492
|
preprocess: () => preprocessType,
|
|
5484
5493
|
pipeline: () => pipelineType,
|
|
5494
|
+
performDecimalOperation: () => performDecimalOperation,
|
|
5485
5495
|
ostring: () => ostring,
|
|
5496
|
+
optionsToEnum: () => optionsToEnum,
|
|
5486
5497
|
optional: () => optionalType,
|
|
5487
5498
|
onumber: () => onumber,
|
|
5488
5499
|
oboolean: () => oboolean,
|
|
5489
5500
|
objectUtil: () => objectUtil,
|
|
5490
5501
|
object: () => objectType,
|
|
5502
|
+
numberWithCommas: () => numberWithCommas,
|
|
5491
5503
|
number: () => numberType,
|
|
5492
5504
|
nullable: () => nullableType,
|
|
5493
5505
|
null: () => nullType,
|
|
@@ -5497,10 +5509,15 @@ __export(exports_node, {
|
|
|
5497
5509
|
map: () => mapType,
|
|
5498
5510
|
makeIssue: () => makeIssue,
|
|
5499
5511
|
literal: () => literalType,
|
|
5512
|
+
limitDecimals: () => limitDecimals,
|
|
5513
|
+
levenshteinDistance: () => levenshteinDistance,
|
|
5500
5514
|
lazy: () => lazyType,
|
|
5501
5515
|
late: () => late,
|
|
5516
|
+
jsonParse: () => jsonParse,
|
|
5502
5517
|
json5: () => import_json52.default,
|
|
5518
|
+
isValidNumber: () => isValidNumber,
|
|
5503
5519
|
isValid: () => isValid,
|
|
5520
|
+
isJson: () => isJson,
|
|
5504
5521
|
isDirty: () => isDirty,
|
|
5505
5522
|
isAsync: () => isAsync,
|
|
5506
5523
|
isAborted: () => isAborted,
|
|
@@ -5510,14 +5527,33 @@ __export(exports_node, {
|
|
|
5510
5527
|
initChinaDayjs: () => initChinaDayjs,
|
|
5511
5528
|
imageToBase64: () => imageToBase64,
|
|
5512
5529
|
getVideoStatus: () => getVideoStatus,
|
|
5530
|
+
getType: () => getType,
|
|
5531
|
+
getTotal: () => getTotal,
|
|
5532
|
+
getStrLength: () => getStrLength,
|
|
5533
|
+
getSliceStr: () => getSliceStr,
|
|
5534
|
+
getRandomString: () => getRandomString,
|
|
5535
|
+
getRandomNum: () => getRandomNum,
|
|
5536
|
+
getRandomColor: () => getRandomColor,
|
|
5537
|
+
getProxyUrl: () => getProxyUrl,
|
|
5513
5538
|
getParsedType: () => getParsedType,
|
|
5539
|
+
getLength: () => getLength,
|
|
5540
|
+
getFileSize: () => getFileSize,
|
|
5514
5541
|
getErrorMap: () => getErrorMap,
|
|
5542
|
+
getCookie: () => getCookie,
|
|
5543
|
+
getChineseByStr: () => getChineseByStr,
|
|
5544
|
+
getChinese: () => getChinese,
|
|
5515
5545
|
generateVideo: () => generateVideo,
|
|
5546
|
+
generateUniqueFileName: () => generateUniqueFileName,
|
|
5547
|
+
generateAlphabetArray: () => generateAlphabetArray,
|
|
5516
5548
|
function: () => functionType,
|
|
5549
|
+
findItem: () => findItem,
|
|
5550
|
+
filterParams: () => filterParams,
|
|
5551
|
+
executePromise: () => executePromise,
|
|
5517
5552
|
enum: () => enumType,
|
|
5518
5553
|
effect: () => effectsType,
|
|
5519
5554
|
downloadFile: () => downloadFile,
|
|
5520
5555
|
discriminatedUnion: () => discriminatedUnionType,
|
|
5556
|
+
delay: () => delay,
|
|
5521
5557
|
defaultErrorMap: () => en_default,
|
|
5522
5558
|
dayjs: () => dayjs_default,
|
|
5523
5559
|
datetimeRegex: () => datetimeRegex,
|
|
@@ -5528,11 +5564,13 @@ __export(exports_node, {
|
|
|
5528
5564
|
chinaDayjs: () => chinaDayjs,
|
|
5529
5565
|
cheerio: () => cheerio,
|
|
5530
5566
|
chat: () => chat,
|
|
5567
|
+
calcJsText: () => calcJsText,
|
|
5531
5568
|
boolean: () => booleanType,
|
|
5532
5569
|
bigint: () => bigIntType,
|
|
5533
5570
|
axios: () => import_axios9.default,
|
|
5534
5571
|
array: () => arrayType,
|
|
5535
5572
|
any: () => anyType,
|
|
5573
|
+
amount: () => amount,
|
|
5536
5574
|
addIssueToContext: () => addIssueToContext,
|
|
5537
5575
|
_: () => import_lodash.default,
|
|
5538
5576
|
ZodVoid: () => ZodVoid,
|
|
@@ -5593,12 +5631,6 @@ __export(exports_node, {
|
|
|
5593
5631
|
BRAND: () => BRAND
|
|
5594
5632
|
});
|
|
5595
5633
|
module.exports = __toCommonJS(exports_node);
|
|
5596
|
-
var import_nedb = __toESM(require("nedb"));
|
|
5597
|
-
var cheerio = __toESM(require("cheerio"));
|
|
5598
|
-
var import_lodash = __toESM(require_lodash());
|
|
5599
|
-
var import_axios9 = __toESM(require("axios"));
|
|
5600
|
-
var import_json52 = __toESM(require("json5"));
|
|
5601
|
-
var import_consola = __toESM(require("consola"));
|
|
5602
5634
|
|
|
5603
5635
|
// ../../node_modules/zod/v3/external.js
|
|
5604
5636
|
var exports_external = {};
|
|
@@ -9573,6 +9605,14 @@ var coerce = {
|
|
|
9573
9605
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
9574
9606
|
};
|
|
9575
9607
|
var NEVER = INVALID;
|
|
9608
|
+
// src/node.ts
|
|
9609
|
+
var cheerio = __toESM(require("cheerio"));
|
|
9610
|
+
var import_lodash = __toESM(require_lodash());
|
|
9611
|
+
var import_axios9 = __toESM(require("axios"));
|
|
9612
|
+
var import_json52 = __toESM(require("json5"));
|
|
9613
|
+
var import_consola = __toESM(require("consola"));
|
|
9614
|
+
var import_nedb = __toESM(require("nedb"));
|
|
9615
|
+
|
|
9576
9616
|
// src/common/ai/302/axios.ts
|
|
9577
9617
|
var import_axios = __toESM(require("axios"));
|
|
9578
9618
|
var key = process.env.AI_302_KEY || process.env.NEXT_PUBLIC_AI_302_KEY;
|
|
@@ -9611,6 +9651,7 @@ var chat = async (message, model = "gpt-4.1", isParse = true) => {
|
|
|
9611
9651
|
throw new Error(error?.response?.statusText || error?.message || "未知原因");
|
|
9612
9652
|
}
|
|
9613
9653
|
};
|
|
9654
|
+
|
|
9614
9655
|
// src/common/ai/keling/utils.ts
|
|
9615
9656
|
var url = __toESM(require("url"));
|
|
9616
9657
|
var path = __toESM(require("path"));
|
|
@@ -9824,29 +9865,2694 @@ var generateVideo = async (imageUrl, prompt) => {
|
|
|
9824
9865
|
console.log(666, "任务 id", taskId);
|
|
9825
9866
|
return taskId;
|
|
9826
9867
|
};
|
|
9827
|
-
// src/common/
|
|
9828
|
-
var
|
|
9829
|
-
|
|
9868
|
+
// src/common/base/string.ts
|
|
9869
|
+
var getChineseByStr = (str) => {
|
|
9870
|
+
if (!str) {
|
|
9871
|
+
return "";
|
|
9872
|
+
}
|
|
9873
|
+
const match = str.match(/[\u4e00-\u9fa5]/g);
|
|
9874
|
+
if (!match) {
|
|
9875
|
+
return "";
|
|
9876
|
+
}
|
|
9877
|
+
return match.join("");
|
|
9878
|
+
};
|
|
9879
|
+
var getStrLength = (value) => {
|
|
9880
|
+
if (!value) {
|
|
9881
|
+
return 0;
|
|
9882
|
+
}
|
|
9883
|
+
const chineseLength = getChineseByStr(value).length;
|
|
9884
|
+
return value.length - chineseLength + chineseLength * 2;
|
|
9885
|
+
};
|
|
9886
|
+
var replaceAll = (str, searchValue, replaceValue) => {
|
|
9887
|
+
if (!str || !searchValue || !replaceValue) {
|
|
9888
|
+
return str || "";
|
|
9889
|
+
}
|
|
9890
|
+
str = str.replace(searchValue, replaceValue);
|
|
9891
|
+
if (!str.includes(searchValue)) {
|
|
9892
|
+
return str;
|
|
9893
|
+
}
|
|
9894
|
+
return replaceAll(str, searchValue, replaceValue);
|
|
9895
|
+
};
|
|
9896
|
+
var replaceByRules = (str, rules) => {
|
|
9897
|
+
rules.forEach(([searchValue, replaceValue]) => {
|
|
9898
|
+
str = str.replaceAll(searchValue, replaceValue);
|
|
9899
|
+
});
|
|
9900
|
+
return str;
|
|
9901
|
+
};
|
|
9902
|
+
var replaceByVariables = (prompt, variables) => {
|
|
9903
|
+
if (!variables || Object.keys(variables).length === 0) {
|
|
9904
|
+
return prompt;
|
|
9905
|
+
}
|
|
9906
|
+
const regex = /\{\{\s*(\w+)\s*\}\}/g;
|
|
9907
|
+
return prompt.replace(regex, (match, p1) => {
|
|
9908
|
+
return variables[p1] ?? match;
|
|
9909
|
+
});
|
|
9910
|
+
};
|
|
9911
|
+
var getType = (value) => {
|
|
9912
|
+
return Object.prototype.toString.call(value).slice(8, -1);
|
|
9913
|
+
};
|
|
9914
|
+
var amount = (str) => {
|
|
9915
|
+
const reg = /(?=(?!\b)(\d{3})+$)/g;
|
|
9916
|
+
return str.replace(reg, ",");
|
|
9917
|
+
};
|
|
9918
|
+
var jsonParse = (value) => {
|
|
9919
|
+
if (typeof value === "object") {
|
|
9920
|
+
return value;
|
|
9921
|
+
}
|
|
9830
9922
|
try {
|
|
9831
|
-
|
|
9832
|
-
|
|
9923
|
+
return JSON.parse(value);
|
|
9924
|
+
} catch (err) {
|
|
9925
|
+
return {};
|
|
9926
|
+
}
|
|
9927
|
+
};
|
|
9928
|
+
var isJson = (str) => {
|
|
9929
|
+
try {
|
|
9930
|
+
if (getType(JSON.parse(str)) === "Object") {
|
|
9931
|
+
return true;
|
|
9932
|
+
}
|
|
9933
|
+
} catch (e) {}
|
|
9934
|
+
return false;
|
|
9935
|
+
};
|
|
9936
|
+
var toString = (value) => {
|
|
9937
|
+
return Object.prototype.toString.call(value).slice(8, -1) === "object" ? JSON.stringify(value) : String(value);
|
|
9938
|
+
};
|
|
9939
|
+
var getRandomColor = () => {
|
|
9940
|
+
const color = Math.floor(Math.random() * 16777215).toString(16);
|
|
9941
|
+
if (color.length === 6) {
|
|
9942
|
+
return color;
|
|
9943
|
+
} else {
|
|
9944
|
+
return getRandomColor();
|
|
9945
|
+
}
|
|
9946
|
+
};
|
|
9947
|
+
var getRandomString = (length = 4) => {
|
|
9948
|
+
return Math.random().toString(36).substr(2, length);
|
|
9949
|
+
};
|
|
9950
|
+
var getChinese = (str) => {
|
|
9951
|
+
if (str == null || str === "") {
|
|
9952
|
+
return "";
|
|
9953
|
+
}
|
|
9954
|
+
const res = str.match(/[\u4e00-\u9fa5]/g);
|
|
9955
|
+
if (!res) {
|
|
9956
|
+
return "";
|
|
9957
|
+
}
|
|
9958
|
+
return res.join("");
|
|
9959
|
+
};
|
|
9960
|
+
var getSliceStr = (str, before, after) => {
|
|
9961
|
+
return str.slice(str.indexOf(before) + before.length, str.lastIndexOf(after));
|
|
9962
|
+
};
|
|
9963
|
+
var getProxyUrl = (url2) => {
|
|
9964
|
+
const beforeUrl = "https://1141871752167714.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/a.LATEST/proxy/?url=";
|
|
9965
|
+
return beforeUrl + url2;
|
|
9966
|
+
};
|
|
9967
|
+
var getLength = (value) => {
|
|
9968
|
+
const chineseLength = getChinese(value).length;
|
|
9969
|
+
return value.length - chineseLength + chineseLength * 2;
|
|
9970
|
+
};
|
|
9971
|
+
var getCookie = (name) => {
|
|
9972
|
+
const reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
|
|
9973
|
+
const arr = document.cookie.match(reg);
|
|
9974
|
+
return arr ? unescape(arr[2]) : null;
|
|
9975
|
+
};
|
|
9976
|
+
var generateAlphabetArray = (n) => {
|
|
9977
|
+
return Array.from({ length: n }, (_, i) => String.fromCharCode(97 + i));
|
|
9978
|
+
};
|
|
9979
|
+
var levenshteinDistance = (a, b) => {
|
|
9980
|
+
const matrix = [];
|
|
9981
|
+
for (let i = 0;i <= b.length; i++) {
|
|
9982
|
+
matrix[i] = [i];
|
|
9983
|
+
}
|
|
9984
|
+
for (let j = 0;j <= a.length; j++) {
|
|
9985
|
+
matrix[0][j] = j;
|
|
9986
|
+
}
|
|
9987
|
+
for (let i = 1;i <= b.length; i++) {
|
|
9988
|
+
for (let j = 1;j <= a.length; j++) {
|
|
9989
|
+
if (b[i - 1] === a[j - 1]) {
|
|
9990
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
9991
|
+
} else {
|
|
9992
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
|
|
9993
|
+
}
|
|
9994
|
+
}
|
|
9995
|
+
}
|
|
9996
|
+
return matrix[b.length][a.length];
|
|
9997
|
+
};
|
|
9998
|
+
var generateUniqueFileName = (name) => {
|
|
9999
|
+
const match = name.match(/^(.*?)(\.[^.]*$|$)/);
|
|
10000
|
+
if (match) {
|
|
10001
|
+
const namePart = match[1];
|
|
10002
|
+
const extensionPart = match[2];
|
|
10003
|
+
if (extensionPart) {
|
|
10004
|
+
return `${namePart}_${Date.now()}${extensionPart}`;
|
|
10005
|
+
} else {
|
|
10006
|
+
return `${namePart}_${Date.now()}.dat`;
|
|
10007
|
+
}
|
|
10008
|
+
}
|
|
10009
|
+
throw new Error("Invalid filename format.");
|
|
10010
|
+
};
|
|
10011
|
+
|
|
10012
|
+
// ../../node_modules/decimal.js/decimal.mjs
|
|
10013
|
+
/*!
|
|
10014
|
+
* decimal.js v10.6.0
|
|
10015
|
+
* An arbitrary-precision Decimal type for JavaScript.
|
|
10016
|
+
* https://github.com/MikeMcl/decimal.js
|
|
10017
|
+
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
10018
|
+
* MIT Licence
|
|
10019
|
+
*/
|
|
10020
|
+
var EXP_LIMIT = 9000000000000000;
|
|
10021
|
+
var MAX_DIGITS = 1e9;
|
|
10022
|
+
var NUMERALS = "0123456789abcdef";
|
|
10023
|
+
var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
|
|
10024
|
+
var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
|
|
10025
|
+
var DEFAULTS = {
|
|
10026
|
+
precision: 20,
|
|
10027
|
+
rounding: 4,
|
|
10028
|
+
modulo: 1,
|
|
10029
|
+
toExpNeg: -7,
|
|
10030
|
+
toExpPos: 21,
|
|
10031
|
+
minE: -EXP_LIMIT,
|
|
10032
|
+
maxE: EXP_LIMIT,
|
|
10033
|
+
crypto: false
|
|
10034
|
+
};
|
|
10035
|
+
var inexact;
|
|
10036
|
+
var quadrant;
|
|
10037
|
+
var external2 = true;
|
|
10038
|
+
var decimalError = "[DecimalError] ";
|
|
10039
|
+
var invalidArgument = decimalError + "Invalid argument: ";
|
|
10040
|
+
var precisionLimitExceeded = decimalError + "Precision limit exceeded";
|
|
10041
|
+
var cryptoUnavailable = decimalError + "crypto unavailable";
|
|
10042
|
+
var tag = "[object Decimal]";
|
|
10043
|
+
var mathfloor = Math.floor;
|
|
10044
|
+
var mathpow = Math.pow;
|
|
10045
|
+
var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
|
|
10046
|
+
var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
|
|
10047
|
+
var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
|
|
10048
|
+
var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
10049
|
+
var BASE = 1e7;
|
|
10050
|
+
var LOG_BASE = 7;
|
|
10051
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
10052
|
+
var LN10_PRECISION = LN10.length - 1;
|
|
10053
|
+
var PI_PRECISION = PI.length - 1;
|
|
10054
|
+
var P = { toStringTag: tag };
|
|
10055
|
+
P.absoluteValue = P.abs = function() {
|
|
10056
|
+
var x = new this.constructor(this);
|
|
10057
|
+
if (x.s < 0)
|
|
10058
|
+
x.s = 1;
|
|
10059
|
+
return finalise(x);
|
|
10060
|
+
};
|
|
10061
|
+
P.ceil = function() {
|
|
10062
|
+
return finalise(new this.constructor(this), this.e + 1, 2);
|
|
10063
|
+
};
|
|
10064
|
+
P.clampedTo = P.clamp = function(min, max) {
|
|
10065
|
+
var k, x = this, Ctor = x.constructor;
|
|
10066
|
+
min = new Ctor(min);
|
|
10067
|
+
max = new Ctor(max);
|
|
10068
|
+
if (!min.s || !max.s)
|
|
10069
|
+
return new Ctor(NaN);
|
|
10070
|
+
if (min.gt(max))
|
|
10071
|
+
throw Error(invalidArgument + max);
|
|
10072
|
+
k = x.cmp(min);
|
|
10073
|
+
return k < 0 ? min : x.cmp(max) > 0 ? max : new Ctor(x);
|
|
10074
|
+
};
|
|
10075
|
+
P.comparedTo = P.cmp = function(y) {
|
|
10076
|
+
var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
|
|
10077
|
+
if (!xd || !yd) {
|
|
10078
|
+
return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
|
|
10079
|
+
}
|
|
10080
|
+
if (!xd[0] || !yd[0])
|
|
10081
|
+
return xd[0] ? xs : yd[0] ? -ys : 0;
|
|
10082
|
+
if (xs !== ys)
|
|
10083
|
+
return xs;
|
|
10084
|
+
if (x.e !== y.e)
|
|
10085
|
+
return x.e > y.e ^ xs < 0 ? 1 : -1;
|
|
10086
|
+
xdL = xd.length;
|
|
10087
|
+
ydL = yd.length;
|
|
10088
|
+
for (i = 0, j = xdL < ydL ? xdL : ydL;i < j; ++i) {
|
|
10089
|
+
if (xd[i] !== yd[i])
|
|
10090
|
+
return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
|
|
10091
|
+
}
|
|
10092
|
+
return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
|
|
10093
|
+
};
|
|
10094
|
+
P.cosine = P.cos = function() {
|
|
10095
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
10096
|
+
if (!x.d)
|
|
10097
|
+
return new Ctor(NaN);
|
|
10098
|
+
if (!x.d[0])
|
|
10099
|
+
return new Ctor(1);
|
|
10100
|
+
pr = Ctor.precision;
|
|
10101
|
+
rm = Ctor.rounding;
|
|
10102
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
10103
|
+
Ctor.rounding = 1;
|
|
10104
|
+
x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
10105
|
+
Ctor.precision = pr;
|
|
10106
|
+
Ctor.rounding = rm;
|
|
10107
|
+
return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
|
|
10108
|
+
};
|
|
10109
|
+
P.cubeRoot = P.cbrt = function() {
|
|
10110
|
+
var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
|
|
10111
|
+
if (!x.isFinite() || x.isZero())
|
|
10112
|
+
return new Ctor(x);
|
|
10113
|
+
external2 = false;
|
|
10114
|
+
s = x.s * mathpow(x.s * x, 1 / 3);
|
|
10115
|
+
if (!s || Math.abs(s) == 1 / 0) {
|
|
10116
|
+
n = digitsToString(x.d);
|
|
10117
|
+
e = x.e;
|
|
10118
|
+
if (s = (e - n.length + 1) % 3)
|
|
10119
|
+
n += s == 1 || s == -2 ? "0" : "00";
|
|
10120
|
+
s = mathpow(n, 1 / 3);
|
|
10121
|
+
e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
|
|
10122
|
+
if (s == 1 / 0) {
|
|
10123
|
+
n = "5e" + e;
|
|
10124
|
+
} else {
|
|
10125
|
+
n = s.toExponential();
|
|
10126
|
+
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
10127
|
+
}
|
|
10128
|
+
r = new Ctor(n);
|
|
10129
|
+
r.s = x.s;
|
|
10130
|
+
} else {
|
|
10131
|
+
r = new Ctor(s.toString());
|
|
10132
|
+
}
|
|
10133
|
+
sd = (e = Ctor.precision) + 3;
|
|
10134
|
+
for (;; ) {
|
|
10135
|
+
t = r;
|
|
10136
|
+
t3 = t.times(t).times(t);
|
|
10137
|
+
t3plusx = t3.plus(x);
|
|
10138
|
+
r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
|
|
10139
|
+
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
10140
|
+
n = n.slice(sd - 3, sd + 1);
|
|
10141
|
+
if (n == "9999" || !rep && n == "4999") {
|
|
10142
|
+
if (!rep) {
|
|
10143
|
+
finalise(t, e + 1, 0);
|
|
10144
|
+
if (t.times(t).times(t).eq(x)) {
|
|
10145
|
+
r = t;
|
|
10146
|
+
break;
|
|
10147
|
+
}
|
|
10148
|
+
}
|
|
10149
|
+
sd += 4;
|
|
10150
|
+
rep = 1;
|
|
10151
|
+
} else {
|
|
10152
|
+
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
10153
|
+
finalise(r, e + 1, 1);
|
|
10154
|
+
m = !r.times(r).times(r).eq(x);
|
|
10155
|
+
}
|
|
10156
|
+
break;
|
|
10157
|
+
}
|
|
10158
|
+
}
|
|
10159
|
+
}
|
|
10160
|
+
external2 = true;
|
|
10161
|
+
return finalise(r, e, Ctor.rounding, m);
|
|
10162
|
+
};
|
|
10163
|
+
P.decimalPlaces = P.dp = function() {
|
|
10164
|
+
var w, d = this.d, n = NaN;
|
|
10165
|
+
if (d) {
|
|
10166
|
+
w = d.length - 1;
|
|
10167
|
+
n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
|
10168
|
+
w = d[w];
|
|
10169
|
+
if (w)
|
|
10170
|
+
for (;w % 10 == 0; w /= 10)
|
|
10171
|
+
n--;
|
|
10172
|
+
if (n < 0)
|
|
10173
|
+
n = 0;
|
|
10174
|
+
}
|
|
10175
|
+
return n;
|
|
10176
|
+
};
|
|
10177
|
+
P.dividedBy = P.div = function(y) {
|
|
10178
|
+
return divide(this, new this.constructor(y));
|
|
10179
|
+
};
|
|
10180
|
+
P.dividedToIntegerBy = P.divToInt = function(y) {
|
|
10181
|
+
var x = this, Ctor = x.constructor;
|
|
10182
|
+
return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
|
|
10183
|
+
};
|
|
10184
|
+
P.equals = P.eq = function(y) {
|
|
10185
|
+
return this.cmp(y) === 0;
|
|
10186
|
+
};
|
|
10187
|
+
P.floor = function() {
|
|
10188
|
+
return finalise(new this.constructor(this), this.e + 1, 3);
|
|
10189
|
+
};
|
|
10190
|
+
P.greaterThan = P.gt = function(y) {
|
|
10191
|
+
return this.cmp(y) > 0;
|
|
10192
|
+
};
|
|
10193
|
+
P.greaterThanOrEqualTo = P.gte = function(y) {
|
|
10194
|
+
var k = this.cmp(y);
|
|
10195
|
+
return k == 1 || k === 0;
|
|
10196
|
+
};
|
|
10197
|
+
P.hyperbolicCosine = P.cosh = function() {
|
|
10198
|
+
var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
|
|
10199
|
+
if (!x.isFinite())
|
|
10200
|
+
return new Ctor(x.s ? 1 / 0 : NaN);
|
|
10201
|
+
if (x.isZero())
|
|
10202
|
+
return one;
|
|
10203
|
+
pr = Ctor.precision;
|
|
10204
|
+
rm = Ctor.rounding;
|
|
10205
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
10206
|
+
Ctor.rounding = 1;
|
|
10207
|
+
len = x.d.length;
|
|
10208
|
+
if (len < 32) {
|
|
10209
|
+
k = Math.ceil(len / 3);
|
|
10210
|
+
n = (1 / tinyPow(4, k)).toString();
|
|
10211
|
+
} else {
|
|
10212
|
+
k = 16;
|
|
10213
|
+
n = "2.3283064365386962890625e-10";
|
|
10214
|
+
}
|
|
10215
|
+
x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
|
|
10216
|
+
var cosh2_x, i = k, d8 = new Ctor(8);
|
|
10217
|
+
for (;i--; ) {
|
|
10218
|
+
cosh2_x = x.times(x);
|
|
10219
|
+
x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
|
|
10220
|
+
}
|
|
10221
|
+
return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
10222
|
+
};
|
|
10223
|
+
P.hyperbolicSine = P.sinh = function() {
|
|
10224
|
+
var k, pr, rm, len, x = this, Ctor = x.constructor;
|
|
10225
|
+
if (!x.isFinite() || x.isZero())
|
|
10226
|
+
return new Ctor(x);
|
|
10227
|
+
pr = Ctor.precision;
|
|
10228
|
+
rm = Ctor.rounding;
|
|
10229
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
10230
|
+
Ctor.rounding = 1;
|
|
10231
|
+
len = x.d.length;
|
|
10232
|
+
if (len < 3) {
|
|
10233
|
+
x = taylorSeries(Ctor, 2, x, x, true);
|
|
10234
|
+
} else {
|
|
10235
|
+
k = 1.4 * Math.sqrt(len);
|
|
10236
|
+
k = k > 16 ? 16 : k | 0;
|
|
10237
|
+
x = x.times(1 / tinyPow(5, k));
|
|
10238
|
+
x = taylorSeries(Ctor, 2, x, x, true);
|
|
10239
|
+
var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
10240
|
+
for (;k--; ) {
|
|
10241
|
+
sinh2_x = x.times(x);
|
|
10242
|
+
x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
|
|
10243
|
+
}
|
|
10244
|
+
}
|
|
10245
|
+
Ctor.precision = pr;
|
|
10246
|
+
Ctor.rounding = rm;
|
|
10247
|
+
return finalise(x, pr, rm, true);
|
|
10248
|
+
};
|
|
10249
|
+
P.hyperbolicTangent = P.tanh = function() {
|
|
10250
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
10251
|
+
if (!x.isFinite())
|
|
10252
|
+
return new Ctor(x.s);
|
|
10253
|
+
if (x.isZero())
|
|
10254
|
+
return new Ctor(x);
|
|
10255
|
+
pr = Ctor.precision;
|
|
10256
|
+
rm = Ctor.rounding;
|
|
10257
|
+
Ctor.precision = pr + 7;
|
|
10258
|
+
Ctor.rounding = 1;
|
|
10259
|
+
return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
|
|
10260
|
+
};
|
|
10261
|
+
P.inverseCosine = P.acos = function() {
|
|
10262
|
+
var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
|
|
10263
|
+
if (k !== -1) {
|
|
10264
|
+
return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
|
|
10265
|
+
}
|
|
10266
|
+
if (x.isZero())
|
|
10267
|
+
return getPi(Ctor, pr + 4, rm).times(0.5);
|
|
10268
|
+
Ctor.precision = pr + 6;
|
|
10269
|
+
Ctor.rounding = 1;
|
|
10270
|
+
x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
|
|
10271
|
+
Ctor.precision = pr;
|
|
10272
|
+
Ctor.rounding = rm;
|
|
10273
|
+
return x.times(2);
|
|
10274
|
+
};
|
|
10275
|
+
P.inverseHyperbolicCosine = P.acosh = function() {
|
|
10276
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
10277
|
+
if (x.lte(1))
|
|
10278
|
+
return new Ctor(x.eq(1) ? 0 : NaN);
|
|
10279
|
+
if (!x.isFinite())
|
|
10280
|
+
return new Ctor(x);
|
|
10281
|
+
pr = Ctor.precision;
|
|
10282
|
+
rm = Ctor.rounding;
|
|
10283
|
+
Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
|
|
10284
|
+
Ctor.rounding = 1;
|
|
10285
|
+
external2 = false;
|
|
10286
|
+
x = x.times(x).minus(1).sqrt().plus(x);
|
|
10287
|
+
external2 = true;
|
|
10288
|
+
Ctor.precision = pr;
|
|
10289
|
+
Ctor.rounding = rm;
|
|
10290
|
+
return x.ln();
|
|
10291
|
+
};
|
|
10292
|
+
P.inverseHyperbolicSine = P.asinh = function() {
|
|
10293
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
10294
|
+
if (!x.isFinite() || x.isZero())
|
|
10295
|
+
return new Ctor(x);
|
|
10296
|
+
pr = Ctor.precision;
|
|
10297
|
+
rm = Ctor.rounding;
|
|
10298
|
+
Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
|
|
10299
|
+
Ctor.rounding = 1;
|
|
10300
|
+
external2 = false;
|
|
10301
|
+
x = x.times(x).plus(1).sqrt().plus(x);
|
|
10302
|
+
external2 = true;
|
|
10303
|
+
Ctor.precision = pr;
|
|
10304
|
+
Ctor.rounding = rm;
|
|
10305
|
+
return x.ln();
|
|
10306
|
+
};
|
|
10307
|
+
P.inverseHyperbolicTangent = P.atanh = function() {
|
|
10308
|
+
var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
|
|
10309
|
+
if (!x.isFinite())
|
|
10310
|
+
return new Ctor(NaN);
|
|
10311
|
+
if (x.e >= 0)
|
|
10312
|
+
return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
|
|
10313
|
+
pr = Ctor.precision;
|
|
10314
|
+
rm = Ctor.rounding;
|
|
10315
|
+
xsd = x.sd();
|
|
10316
|
+
if (Math.max(xsd, pr) < 2 * -x.e - 1)
|
|
10317
|
+
return finalise(new Ctor(x), pr, rm, true);
|
|
10318
|
+
Ctor.precision = wpr = xsd - x.e;
|
|
10319
|
+
x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
|
|
10320
|
+
Ctor.precision = pr + 4;
|
|
10321
|
+
Ctor.rounding = 1;
|
|
10322
|
+
x = x.ln();
|
|
10323
|
+
Ctor.precision = pr;
|
|
10324
|
+
Ctor.rounding = rm;
|
|
10325
|
+
return x.times(0.5);
|
|
10326
|
+
};
|
|
10327
|
+
P.inverseSine = P.asin = function() {
|
|
10328
|
+
var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
|
|
10329
|
+
if (x.isZero())
|
|
10330
|
+
return new Ctor(x);
|
|
10331
|
+
k = x.abs().cmp(1);
|
|
10332
|
+
pr = Ctor.precision;
|
|
10333
|
+
rm = Ctor.rounding;
|
|
10334
|
+
if (k !== -1) {
|
|
10335
|
+
if (k === 0) {
|
|
10336
|
+
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
10337
|
+
halfPi.s = x.s;
|
|
10338
|
+
return halfPi;
|
|
10339
|
+
}
|
|
10340
|
+
return new Ctor(NaN);
|
|
10341
|
+
}
|
|
10342
|
+
Ctor.precision = pr + 6;
|
|
10343
|
+
Ctor.rounding = 1;
|
|
10344
|
+
x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
|
|
10345
|
+
Ctor.precision = pr;
|
|
10346
|
+
Ctor.rounding = rm;
|
|
10347
|
+
return x.times(2);
|
|
10348
|
+
};
|
|
10349
|
+
P.inverseTangent = P.atan = function() {
|
|
10350
|
+
var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
|
|
10351
|
+
if (!x.isFinite()) {
|
|
10352
|
+
if (!x.s)
|
|
10353
|
+
return new Ctor(NaN);
|
|
10354
|
+
if (pr + 4 <= PI_PRECISION) {
|
|
10355
|
+
r = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
10356
|
+
r.s = x.s;
|
|
10357
|
+
return r;
|
|
10358
|
+
}
|
|
10359
|
+
} else if (x.isZero()) {
|
|
10360
|
+
return new Ctor(x);
|
|
10361
|
+
} else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
|
|
10362
|
+
r = getPi(Ctor, pr + 4, rm).times(0.25);
|
|
10363
|
+
r.s = x.s;
|
|
10364
|
+
return r;
|
|
10365
|
+
}
|
|
10366
|
+
Ctor.precision = wpr = pr + 10;
|
|
10367
|
+
Ctor.rounding = 1;
|
|
10368
|
+
k = Math.min(28, wpr / LOG_BASE + 2 | 0);
|
|
10369
|
+
for (i = k;i; --i)
|
|
10370
|
+
x = x.div(x.times(x).plus(1).sqrt().plus(1));
|
|
10371
|
+
external2 = false;
|
|
10372
|
+
j = Math.ceil(wpr / LOG_BASE);
|
|
10373
|
+
n = 1;
|
|
10374
|
+
x2 = x.times(x);
|
|
10375
|
+
r = new Ctor(x);
|
|
10376
|
+
px = x;
|
|
10377
|
+
for (;i !== -1; ) {
|
|
10378
|
+
px = px.times(x2);
|
|
10379
|
+
t = r.minus(px.div(n += 2));
|
|
10380
|
+
px = px.times(x2);
|
|
10381
|
+
r = t.plus(px.div(n += 2));
|
|
10382
|
+
if (r.d[j] !== undefined)
|
|
10383
|
+
for (i = j;r.d[i] === t.d[i] && i--; )
|
|
10384
|
+
;
|
|
10385
|
+
}
|
|
10386
|
+
if (k)
|
|
10387
|
+
r = r.times(2 << k - 1);
|
|
10388
|
+
external2 = true;
|
|
10389
|
+
return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
10390
|
+
};
|
|
10391
|
+
P.isFinite = function() {
|
|
10392
|
+
return !!this.d;
|
|
10393
|
+
};
|
|
10394
|
+
P.isInteger = P.isInt = function() {
|
|
10395
|
+
return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
|
|
10396
|
+
};
|
|
10397
|
+
P.isNaN = function() {
|
|
10398
|
+
return !this.s;
|
|
10399
|
+
};
|
|
10400
|
+
P.isNegative = P.isNeg = function() {
|
|
10401
|
+
return this.s < 0;
|
|
10402
|
+
};
|
|
10403
|
+
P.isPositive = P.isPos = function() {
|
|
10404
|
+
return this.s > 0;
|
|
10405
|
+
};
|
|
10406
|
+
P.isZero = function() {
|
|
10407
|
+
return !!this.d && this.d[0] === 0;
|
|
10408
|
+
};
|
|
10409
|
+
P.lessThan = P.lt = function(y) {
|
|
10410
|
+
return this.cmp(y) < 0;
|
|
10411
|
+
};
|
|
10412
|
+
P.lessThanOrEqualTo = P.lte = function(y) {
|
|
10413
|
+
return this.cmp(y) < 1;
|
|
10414
|
+
};
|
|
10415
|
+
P.logarithm = P.log = function(base) {
|
|
10416
|
+
var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
|
|
10417
|
+
if (base == null) {
|
|
10418
|
+
base = new Ctor(10);
|
|
10419
|
+
isBase10 = true;
|
|
10420
|
+
} else {
|
|
10421
|
+
base = new Ctor(base);
|
|
10422
|
+
d = base.d;
|
|
10423
|
+
if (base.s < 0 || !d || !d[0] || base.eq(1))
|
|
10424
|
+
return new Ctor(NaN);
|
|
10425
|
+
isBase10 = base.eq(10);
|
|
10426
|
+
}
|
|
10427
|
+
d = arg.d;
|
|
10428
|
+
if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
|
|
10429
|
+
return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
|
|
10430
|
+
}
|
|
10431
|
+
if (isBase10) {
|
|
10432
|
+
if (d.length > 1) {
|
|
10433
|
+
inf = true;
|
|
10434
|
+
} else {
|
|
10435
|
+
for (k = d[0];k % 10 === 0; )
|
|
10436
|
+
k /= 10;
|
|
10437
|
+
inf = k !== 1;
|
|
10438
|
+
}
|
|
10439
|
+
}
|
|
10440
|
+
external2 = false;
|
|
10441
|
+
sd = pr + guard;
|
|
10442
|
+
num = naturalLogarithm(arg, sd);
|
|
10443
|
+
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
10444
|
+
r = divide(num, denominator, sd, 1);
|
|
10445
|
+
if (checkRoundingDigits(r.d, k = pr, rm)) {
|
|
10446
|
+
do {
|
|
10447
|
+
sd += 10;
|
|
10448
|
+
num = naturalLogarithm(arg, sd);
|
|
10449
|
+
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
10450
|
+
r = divide(num, denominator, sd, 1);
|
|
10451
|
+
if (!inf) {
|
|
10452
|
+
if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 100000000000000) {
|
|
10453
|
+
r = finalise(r, pr + 1, 0);
|
|
10454
|
+
}
|
|
10455
|
+
break;
|
|
10456
|
+
}
|
|
10457
|
+
} while (checkRoundingDigits(r.d, k += 10, rm));
|
|
10458
|
+
}
|
|
10459
|
+
external2 = true;
|
|
10460
|
+
return finalise(r, pr, rm);
|
|
10461
|
+
};
|
|
10462
|
+
P.minus = P.sub = function(y) {
|
|
10463
|
+
var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
|
|
10464
|
+
y = new Ctor(y);
|
|
10465
|
+
if (!x.d || !y.d) {
|
|
10466
|
+
if (!x.s || !y.s)
|
|
10467
|
+
y = new Ctor(NaN);
|
|
10468
|
+
else if (x.d)
|
|
10469
|
+
y.s = -y.s;
|
|
10470
|
+
else
|
|
10471
|
+
y = new Ctor(y.d || x.s !== y.s ? x : NaN);
|
|
10472
|
+
return y;
|
|
10473
|
+
}
|
|
10474
|
+
if (x.s != y.s) {
|
|
10475
|
+
y.s = -y.s;
|
|
10476
|
+
return x.plus(y);
|
|
10477
|
+
}
|
|
10478
|
+
xd = x.d;
|
|
10479
|
+
yd = y.d;
|
|
10480
|
+
pr = Ctor.precision;
|
|
10481
|
+
rm = Ctor.rounding;
|
|
10482
|
+
if (!xd[0] || !yd[0]) {
|
|
10483
|
+
if (yd[0])
|
|
10484
|
+
y.s = -y.s;
|
|
10485
|
+
else if (xd[0])
|
|
10486
|
+
y = new Ctor(x);
|
|
10487
|
+
else
|
|
10488
|
+
return new Ctor(rm === 3 ? -0 : 0);
|
|
10489
|
+
return external2 ? finalise(y, pr, rm) : y;
|
|
10490
|
+
}
|
|
10491
|
+
e = mathfloor(y.e / LOG_BASE);
|
|
10492
|
+
xe = mathfloor(x.e / LOG_BASE);
|
|
10493
|
+
xd = xd.slice();
|
|
10494
|
+
k = xe - e;
|
|
10495
|
+
if (k) {
|
|
10496
|
+
xLTy = k < 0;
|
|
10497
|
+
if (xLTy) {
|
|
10498
|
+
d = xd;
|
|
10499
|
+
k = -k;
|
|
10500
|
+
len = yd.length;
|
|
10501
|
+
} else {
|
|
10502
|
+
d = yd;
|
|
10503
|
+
e = xe;
|
|
10504
|
+
len = xd.length;
|
|
10505
|
+
}
|
|
10506
|
+
i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
|
|
10507
|
+
if (k > i) {
|
|
10508
|
+
k = i;
|
|
10509
|
+
d.length = 1;
|
|
10510
|
+
}
|
|
10511
|
+
d.reverse();
|
|
10512
|
+
for (i = k;i--; )
|
|
10513
|
+
d.push(0);
|
|
10514
|
+
d.reverse();
|
|
10515
|
+
} else {
|
|
10516
|
+
i = xd.length;
|
|
10517
|
+
len = yd.length;
|
|
10518
|
+
xLTy = i < len;
|
|
10519
|
+
if (xLTy)
|
|
10520
|
+
len = i;
|
|
10521
|
+
for (i = 0;i < len; i++) {
|
|
10522
|
+
if (xd[i] != yd[i]) {
|
|
10523
|
+
xLTy = xd[i] < yd[i];
|
|
10524
|
+
break;
|
|
10525
|
+
}
|
|
10526
|
+
}
|
|
10527
|
+
k = 0;
|
|
10528
|
+
}
|
|
10529
|
+
if (xLTy) {
|
|
10530
|
+
d = xd;
|
|
10531
|
+
xd = yd;
|
|
10532
|
+
yd = d;
|
|
10533
|
+
y.s = -y.s;
|
|
10534
|
+
}
|
|
10535
|
+
len = xd.length;
|
|
10536
|
+
for (i = yd.length - len;i > 0; --i)
|
|
10537
|
+
xd[len++] = 0;
|
|
10538
|
+
for (i = yd.length;i > k; ) {
|
|
10539
|
+
if (xd[--i] < yd[i]) {
|
|
10540
|
+
for (j = i;j && xd[--j] === 0; )
|
|
10541
|
+
xd[j] = BASE - 1;
|
|
10542
|
+
--xd[j];
|
|
10543
|
+
xd[i] += BASE;
|
|
10544
|
+
}
|
|
10545
|
+
xd[i] -= yd[i];
|
|
10546
|
+
}
|
|
10547
|
+
for (;xd[--len] === 0; )
|
|
10548
|
+
xd.pop();
|
|
10549
|
+
for (;xd[0] === 0; xd.shift())
|
|
10550
|
+
--e;
|
|
10551
|
+
if (!xd[0])
|
|
10552
|
+
return new Ctor(rm === 3 ? -0 : 0);
|
|
10553
|
+
y.d = xd;
|
|
10554
|
+
y.e = getBase10Exponent(xd, e);
|
|
10555
|
+
return external2 ? finalise(y, pr, rm) : y;
|
|
10556
|
+
};
|
|
10557
|
+
P.modulo = P.mod = function(y) {
|
|
10558
|
+
var q, x = this, Ctor = x.constructor;
|
|
10559
|
+
y = new Ctor(y);
|
|
10560
|
+
if (!x.d || !y.s || y.d && !y.d[0])
|
|
10561
|
+
return new Ctor(NaN);
|
|
10562
|
+
if (!y.d || x.d && !x.d[0]) {
|
|
10563
|
+
return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
|
|
10564
|
+
}
|
|
10565
|
+
external2 = false;
|
|
10566
|
+
if (Ctor.modulo == 9) {
|
|
10567
|
+
q = divide(x, y.abs(), 0, 3, 1);
|
|
10568
|
+
q.s *= y.s;
|
|
10569
|
+
} else {
|
|
10570
|
+
q = divide(x, y, 0, Ctor.modulo, 1);
|
|
10571
|
+
}
|
|
10572
|
+
q = q.times(y);
|
|
10573
|
+
external2 = true;
|
|
10574
|
+
return x.minus(q);
|
|
10575
|
+
};
|
|
10576
|
+
P.naturalExponential = P.exp = function() {
|
|
10577
|
+
return naturalExponential(this);
|
|
10578
|
+
};
|
|
10579
|
+
P.naturalLogarithm = P.ln = function() {
|
|
10580
|
+
return naturalLogarithm(this);
|
|
10581
|
+
};
|
|
10582
|
+
P.negated = P.neg = function() {
|
|
10583
|
+
var x = new this.constructor(this);
|
|
10584
|
+
x.s = -x.s;
|
|
10585
|
+
return finalise(x);
|
|
10586
|
+
};
|
|
10587
|
+
P.plus = P.add = function(y) {
|
|
10588
|
+
var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
|
|
10589
|
+
y = new Ctor(y);
|
|
10590
|
+
if (!x.d || !y.d) {
|
|
10591
|
+
if (!x.s || !y.s)
|
|
10592
|
+
y = new Ctor(NaN);
|
|
10593
|
+
else if (!x.d)
|
|
10594
|
+
y = new Ctor(y.d || x.s === y.s ? x : NaN);
|
|
10595
|
+
return y;
|
|
10596
|
+
}
|
|
10597
|
+
if (x.s != y.s) {
|
|
10598
|
+
y.s = -y.s;
|
|
10599
|
+
return x.minus(y);
|
|
10600
|
+
}
|
|
10601
|
+
xd = x.d;
|
|
10602
|
+
yd = y.d;
|
|
10603
|
+
pr = Ctor.precision;
|
|
10604
|
+
rm = Ctor.rounding;
|
|
10605
|
+
if (!xd[0] || !yd[0]) {
|
|
10606
|
+
if (!yd[0])
|
|
10607
|
+
y = new Ctor(x);
|
|
10608
|
+
return external2 ? finalise(y, pr, rm) : y;
|
|
10609
|
+
}
|
|
10610
|
+
k = mathfloor(x.e / LOG_BASE);
|
|
10611
|
+
e = mathfloor(y.e / LOG_BASE);
|
|
10612
|
+
xd = xd.slice();
|
|
10613
|
+
i = k - e;
|
|
10614
|
+
if (i) {
|
|
10615
|
+
if (i < 0) {
|
|
10616
|
+
d = xd;
|
|
10617
|
+
i = -i;
|
|
10618
|
+
len = yd.length;
|
|
10619
|
+
} else {
|
|
10620
|
+
d = yd;
|
|
10621
|
+
e = k;
|
|
10622
|
+
len = xd.length;
|
|
10623
|
+
}
|
|
10624
|
+
k = Math.ceil(pr / LOG_BASE);
|
|
10625
|
+
len = k > len ? k + 1 : len + 1;
|
|
10626
|
+
if (i > len) {
|
|
10627
|
+
i = len;
|
|
10628
|
+
d.length = 1;
|
|
10629
|
+
}
|
|
10630
|
+
d.reverse();
|
|
10631
|
+
for (;i--; )
|
|
10632
|
+
d.push(0);
|
|
10633
|
+
d.reverse();
|
|
10634
|
+
}
|
|
10635
|
+
len = xd.length;
|
|
10636
|
+
i = yd.length;
|
|
10637
|
+
if (len - i < 0) {
|
|
10638
|
+
i = len;
|
|
10639
|
+
d = yd;
|
|
10640
|
+
yd = xd;
|
|
10641
|
+
xd = d;
|
|
10642
|
+
}
|
|
10643
|
+
for (carry = 0;i; ) {
|
|
10644
|
+
carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
|
|
10645
|
+
xd[i] %= BASE;
|
|
10646
|
+
}
|
|
10647
|
+
if (carry) {
|
|
10648
|
+
xd.unshift(carry);
|
|
10649
|
+
++e;
|
|
10650
|
+
}
|
|
10651
|
+
for (len = xd.length;xd[--len] == 0; )
|
|
10652
|
+
xd.pop();
|
|
10653
|
+
y.d = xd;
|
|
10654
|
+
y.e = getBase10Exponent(xd, e);
|
|
10655
|
+
return external2 ? finalise(y, pr, rm) : y;
|
|
10656
|
+
};
|
|
10657
|
+
P.precision = P.sd = function(z) {
|
|
10658
|
+
var k, x = this;
|
|
10659
|
+
if (z !== undefined && z !== !!z && z !== 1 && z !== 0)
|
|
10660
|
+
throw Error(invalidArgument + z);
|
|
10661
|
+
if (x.d) {
|
|
10662
|
+
k = getPrecision(x.d);
|
|
10663
|
+
if (z && x.e + 1 > k)
|
|
10664
|
+
k = x.e + 1;
|
|
10665
|
+
} else {
|
|
10666
|
+
k = NaN;
|
|
10667
|
+
}
|
|
10668
|
+
return k;
|
|
10669
|
+
};
|
|
10670
|
+
P.round = function() {
|
|
10671
|
+
var x = this, Ctor = x.constructor;
|
|
10672
|
+
return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
|
|
10673
|
+
};
|
|
10674
|
+
P.sine = P.sin = function() {
|
|
10675
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
10676
|
+
if (!x.isFinite())
|
|
10677
|
+
return new Ctor(NaN);
|
|
10678
|
+
if (x.isZero())
|
|
10679
|
+
return new Ctor(x);
|
|
10680
|
+
pr = Ctor.precision;
|
|
10681
|
+
rm = Ctor.rounding;
|
|
10682
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
10683
|
+
Ctor.rounding = 1;
|
|
10684
|
+
x = sine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
10685
|
+
Ctor.precision = pr;
|
|
10686
|
+
Ctor.rounding = rm;
|
|
10687
|
+
return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
|
|
10688
|
+
};
|
|
10689
|
+
P.squareRoot = P.sqrt = function() {
|
|
10690
|
+
var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
|
|
10691
|
+
if (s !== 1 || !d || !d[0]) {
|
|
10692
|
+
return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
|
|
10693
|
+
}
|
|
10694
|
+
external2 = false;
|
|
10695
|
+
s = Math.sqrt(+x);
|
|
10696
|
+
if (s == 0 || s == 1 / 0) {
|
|
10697
|
+
n = digitsToString(d);
|
|
10698
|
+
if ((n.length + e) % 2 == 0)
|
|
10699
|
+
n += "0";
|
|
10700
|
+
s = Math.sqrt(n);
|
|
10701
|
+
e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
|
|
10702
|
+
if (s == 1 / 0) {
|
|
10703
|
+
n = "5e" + e;
|
|
10704
|
+
} else {
|
|
10705
|
+
n = s.toExponential();
|
|
10706
|
+
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
10707
|
+
}
|
|
10708
|
+
r = new Ctor(n);
|
|
10709
|
+
} else {
|
|
10710
|
+
r = new Ctor(s.toString());
|
|
10711
|
+
}
|
|
10712
|
+
sd = (e = Ctor.precision) + 3;
|
|
10713
|
+
for (;; ) {
|
|
10714
|
+
t = r;
|
|
10715
|
+
r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
|
|
10716
|
+
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
10717
|
+
n = n.slice(sd - 3, sd + 1);
|
|
10718
|
+
if (n == "9999" || !rep && n == "4999") {
|
|
10719
|
+
if (!rep) {
|
|
10720
|
+
finalise(t, e + 1, 0);
|
|
10721
|
+
if (t.times(t).eq(x)) {
|
|
10722
|
+
r = t;
|
|
10723
|
+
break;
|
|
10724
|
+
}
|
|
10725
|
+
}
|
|
10726
|
+
sd += 4;
|
|
10727
|
+
rep = 1;
|
|
10728
|
+
} else {
|
|
10729
|
+
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
10730
|
+
finalise(r, e + 1, 1);
|
|
10731
|
+
m = !r.times(r).eq(x);
|
|
10732
|
+
}
|
|
10733
|
+
break;
|
|
10734
|
+
}
|
|
10735
|
+
}
|
|
10736
|
+
}
|
|
10737
|
+
external2 = true;
|
|
10738
|
+
return finalise(r, e, Ctor.rounding, m);
|
|
10739
|
+
};
|
|
10740
|
+
P.tangent = P.tan = function() {
|
|
10741
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
10742
|
+
if (!x.isFinite())
|
|
10743
|
+
return new Ctor(NaN);
|
|
10744
|
+
if (x.isZero())
|
|
10745
|
+
return new Ctor(x);
|
|
10746
|
+
pr = Ctor.precision;
|
|
10747
|
+
rm = Ctor.rounding;
|
|
10748
|
+
Ctor.precision = pr + 10;
|
|
10749
|
+
Ctor.rounding = 1;
|
|
10750
|
+
x = x.sin();
|
|
10751
|
+
x.s = 1;
|
|
10752
|
+
x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
|
|
10753
|
+
Ctor.precision = pr;
|
|
10754
|
+
Ctor.rounding = rm;
|
|
10755
|
+
return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
|
|
10756
|
+
};
|
|
10757
|
+
P.times = P.mul = function(y) {
|
|
10758
|
+
var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
|
|
10759
|
+
y.s *= x.s;
|
|
10760
|
+
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
10761
|
+
return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
|
|
10762
|
+
}
|
|
10763
|
+
e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
|
|
10764
|
+
xdL = xd.length;
|
|
10765
|
+
ydL = yd.length;
|
|
10766
|
+
if (xdL < ydL) {
|
|
10767
|
+
r = xd;
|
|
10768
|
+
xd = yd;
|
|
10769
|
+
yd = r;
|
|
10770
|
+
rL = xdL;
|
|
10771
|
+
xdL = ydL;
|
|
10772
|
+
ydL = rL;
|
|
10773
|
+
}
|
|
10774
|
+
r = [];
|
|
10775
|
+
rL = xdL + ydL;
|
|
10776
|
+
for (i = rL;i--; )
|
|
10777
|
+
r.push(0);
|
|
10778
|
+
for (i = ydL;--i >= 0; ) {
|
|
10779
|
+
carry = 0;
|
|
10780
|
+
for (k = xdL + i;k > i; ) {
|
|
10781
|
+
t = r[k] + yd[i] * xd[k - i - 1] + carry;
|
|
10782
|
+
r[k--] = t % BASE | 0;
|
|
10783
|
+
carry = t / BASE | 0;
|
|
10784
|
+
}
|
|
10785
|
+
r[k] = (r[k] + carry) % BASE | 0;
|
|
10786
|
+
}
|
|
10787
|
+
for (;!r[--rL]; )
|
|
10788
|
+
r.pop();
|
|
10789
|
+
if (carry)
|
|
10790
|
+
++e;
|
|
10791
|
+
else
|
|
10792
|
+
r.shift();
|
|
10793
|
+
y.d = r;
|
|
10794
|
+
y.e = getBase10Exponent(r, e);
|
|
10795
|
+
return external2 ? finalise(y, Ctor.precision, Ctor.rounding) : y;
|
|
10796
|
+
};
|
|
10797
|
+
P.toBinary = function(sd, rm) {
|
|
10798
|
+
return toStringBinary(this, 2, sd, rm);
|
|
10799
|
+
};
|
|
10800
|
+
P.toDecimalPlaces = P.toDP = function(dp, rm) {
|
|
10801
|
+
var x = this, Ctor = x.constructor;
|
|
10802
|
+
x = new Ctor(x);
|
|
10803
|
+
if (dp === undefined)
|
|
10804
|
+
return x;
|
|
10805
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
10806
|
+
if (rm === undefined)
|
|
10807
|
+
rm = Ctor.rounding;
|
|
10808
|
+
else
|
|
10809
|
+
checkInt32(rm, 0, 8);
|
|
10810
|
+
return finalise(x, dp + x.e + 1, rm);
|
|
10811
|
+
};
|
|
10812
|
+
P.toExponential = function(dp, rm) {
|
|
10813
|
+
var str, x = this, Ctor = x.constructor;
|
|
10814
|
+
if (dp === undefined) {
|
|
10815
|
+
str = finiteToString(x, true);
|
|
10816
|
+
} else {
|
|
10817
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
10818
|
+
if (rm === undefined)
|
|
10819
|
+
rm = Ctor.rounding;
|
|
10820
|
+
else
|
|
10821
|
+
checkInt32(rm, 0, 8);
|
|
10822
|
+
x = finalise(new Ctor(x), dp + 1, rm);
|
|
10823
|
+
str = finiteToString(x, true, dp + 1);
|
|
10824
|
+
}
|
|
10825
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
10826
|
+
};
|
|
10827
|
+
P.toFixed = function(dp, rm) {
|
|
10828
|
+
var str, y, x = this, Ctor = x.constructor;
|
|
10829
|
+
if (dp === undefined) {
|
|
10830
|
+
str = finiteToString(x);
|
|
10831
|
+
} else {
|
|
10832
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
10833
|
+
if (rm === undefined)
|
|
10834
|
+
rm = Ctor.rounding;
|
|
10835
|
+
else
|
|
10836
|
+
checkInt32(rm, 0, 8);
|
|
10837
|
+
y = finalise(new Ctor(x), dp + x.e + 1, rm);
|
|
10838
|
+
str = finiteToString(y, false, dp + y.e + 1);
|
|
10839
|
+
}
|
|
10840
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
10841
|
+
};
|
|
10842
|
+
P.toFraction = function(maxD) {
|
|
10843
|
+
var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
|
|
10844
|
+
if (!xd)
|
|
10845
|
+
return new Ctor(x);
|
|
10846
|
+
n1 = d0 = new Ctor(1);
|
|
10847
|
+
d1 = n0 = new Ctor(0);
|
|
10848
|
+
d = new Ctor(d1);
|
|
10849
|
+
e = d.e = getPrecision(xd) - x.e - 1;
|
|
10850
|
+
k = e % LOG_BASE;
|
|
10851
|
+
d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
|
|
10852
|
+
if (maxD == null) {
|
|
10853
|
+
maxD = e > 0 ? d : n1;
|
|
10854
|
+
} else {
|
|
10855
|
+
n = new Ctor(maxD);
|
|
10856
|
+
if (!n.isInt() || n.lt(n1))
|
|
10857
|
+
throw Error(invalidArgument + n);
|
|
10858
|
+
maxD = n.gt(d) ? e > 0 ? d : n1 : n;
|
|
10859
|
+
}
|
|
10860
|
+
external2 = false;
|
|
10861
|
+
n = new Ctor(digitsToString(xd));
|
|
10862
|
+
pr = Ctor.precision;
|
|
10863
|
+
Ctor.precision = e = xd.length * LOG_BASE * 2;
|
|
10864
|
+
for (;; ) {
|
|
10865
|
+
q = divide(n, d, 0, 1, 1);
|
|
10866
|
+
d2 = d0.plus(q.times(d1));
|
|
10867
|
+
if (d2.cmp(maxD) == 1)
|
|
10868
|
+
break;
|
|
10869
|
+
d0 = d1;
|
|
10870
|
+
d1 = d2;
|
|
10871
|
+
d2 = n1;
|
|
10872
|
+
n1 = n0.plus(q.times(d2));
|
|
10873
|
+
n0 = d2;
|
|
10874
|
+
d2 = d;
|
|
10875
|
+
d = n.minus(q.times(d2));
|
|
10876
|
+
n = d2;
|
|
10877
|
+
}
|
|
10878
|
+
d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
|
|
10879
|
+
n0 = n0.plus(d2.times(n1));
|
|
10880
|
+
d0 = d0.plus(d2.times(d1));
|
|
10881
|
+
n0.s = n1.s = x.s;
|
|
10882
|
+
r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
|
|
10883
|
+
Ctor.precision = pr;
|
|
10884
|
+
external2 = true;
|
|
10885
|
+
return r;
|
|
10886
|
+
};
|
|
10887
|
+
P.toHexadecimal = P.toHex = function(sd, rm) {
|
|
10888
|
+
return toStringBinary(this, 16, sd, rm);
|
|
10889
|
+
};
|
|
10890
|
+
P.toNearest = function(y, rm) {
|
|
10891
|
+
var x = this, Ctor = x.constructor;
|
|
10892
|
+
x = new Ctor(x);
|
|
10893
|
+
if (y == null) {
|
|
10894
|
+
if (!x.d)
|
|
10895
|
+
return x;
|
|
10896
|
+
y = new Ctor(1);
|
|
10897
|
+
rm = Ctor.rounding;
|
|
10898
|
+
} else {
|
|
10899
|
+
y = new Ctor(y);
|
|
10900
|
+
if (rm === undefined) {
|
|
10901
|
+
rm = Ctor.rounding;
|
|
10902
|
+
} else {
|
|
10903
|
+
checkInt32(rm, 0, 8);
|
|
10904
|
+
}
|
|
10905
|
+
if (!x.d)
|
|
10906
|
+
return y.s ? x : y;
|
|
10907
|
+
if (!y.d) {
|
|
10908
|
+
if (y.s)
|
|
10909
|
+
y.s = x.s;
|
|
10910
|
+
return y;
|
|
10911
|
+
}
|
|
10912
|
+
}
|
|
10913
|
+
if (y.d[0]) {
|
|
10914
|
+
external2 = false;
|
|
10915
|
+
x = divide(x, y, 0, rm, 1).times(y);
|
|
10916
|
+
external2 = true;
|
|
10917
|
+
finalise(x);
|
|
10918
|
+
} else {
|
|
10919
|
+
y.s = x.s;
|
|
10920
|
+
x = y;
|
|
10921
|
+
}
|
|
10922
|
+
return x;
|
|
10923
|
+
};
|
|
10924
|
+
P.toNumber = function() {
|
|
10925
|
+
return +this;
|
|
10926
|
+
};
|
|
10927
|
+
P.toOctal = function(sd, rm) {
|
|
10928
|
+
return toStringBinary(this, 8, sd, rm);
|
|
10929
|
+
};
|
|
10930
|
+
P.toPower = P.pow = function(y) {
|
|
10931
|
+
var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
|
|
10932
|
+
if (!x.d || !y.d || !x.d[0] || !y.d[0])
|
|
10933
|
+
return new Ctor(mathpow(+x, yn));
|
|
10934
|
+
x = new Ctor(x);
|
|
10935
|
+
if (x.eq(1))
|
|
10936
|
+
return x;
|
|
10937
|
+
pr = Ctor.precision;
|
|
10938
|
+
rm = Ctor.rounding;
|
|
10939
|
+
if (y.eq(1))
|
|
10940
|
+
return finalise(x, pr, rm);
|
|
10941
|
+
e = mathfloor(y.e / LOG_BASE);
|
|
10942
|
+
if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
|
|
10943
|
+
r = intPow(Ctor, x, k, pr);
|
|
10944
|
+
return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
|
|
10945
|
+
}
|
|
10946
|
+
s = x.s;
|
|
10947
|
+
if (s < 0) {
|
|
10948
|
+
if (e < y.d.length - 1)
|
|
10949
|
+
return new Ctor(NaN);
|
|
10950
|
+
if ((y.d[e] & 1) == 0)
|
|
10951
|
+
s = 1;
|
|
10952
|
+
if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
|
|
10953
|
+
x.s = s;
|
|
10954
|
+
return x;
|
|
10955
|
+
}
|
|
10956
|
+
}
|
|
10957
|
+
k = mathpow(+x, yn);
|
|
10958
|
+
e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
|
|
10959
|
+
if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
|
|
10960
|
+
return new Ctor(e > 0 ? s / 0 : 0);
|
|
10961
|
+
external2 = false;
|
|
10962
|
+
Ctor.rounding = x.s = 1;
|
|
10963
|
+
k = Math.min(12, (e + "").length);
|
|
10964
|
+
r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
|
|
10965
|
+
if (r.d) {
|
|
10966
|
+
r = finalise(r, pr + 5, 1);
|
|
10967
|
+
if (checkRoundingDigits(r.d, pr, rm)) {
|
|
10968
|
+
e = pr + 10;
|
|
10969
|
+
r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
|
|
10970
|
+
if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 100000000000000) {
|
|
10971
|
+
r = finalise(r, pr + 1, 0);
|
|
10972
|
+
}
|
|
10973
|
+
}
|
|
10974
|
+
}
|
|
10975
|
+
r.s = s;
|
|
10976
|
+
external2 = true;
|
|
10977
|
+
Ctor.rounding = rm;
|
|
10978
|
+
return finalise(r, pr, rm);
|
|
10979
|
+
};
|
|
10980
|
+
P.toPrecision = function(sd, rm) {
|
|
10981
|
+
var str, x = this, Ctor = x.constructor;
|
|
10982
|
+
if (sd === undefined) {
|
|
10983
|
+
str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
10984
|
+
} else {
|
|
10985
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
10986
|
+
if (rm === undefined)
|
|
10987
|
+
rm = Ctor.rounding;
|
|
10988
|
+
else
|
|
10989
|
+
checkInt32(rm, 0, 8);
|
|
10990
|
+
x = finalise(new Ctor(x), sd, rm);
|
|
10991
|
+
str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
|
|
10992
|
+
}
|
|
10993
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
10994
|
+
};
|
|
10995
|
+
P.toSignificantDigits = P.toSD = function(sd, rm) {
|
|
10996
|
+
var x = this, Ctor = x.constructor;
|
|
10997
|
+
if (sd === undefined) {
|
|
10998
|
+
sd = Ctor.precision;
|
|
10999
|
+
rm = Ctor.rounding;
|
|
11000
|
+
} else {
|
|
11001
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
11002
|
+
if (rm === undefined)
|
|
11003
|
+
rm = Ctor.rounding;
|
|
11004
|
+
else
|
|
11005
|
+
checkInt32(rm, 0, 8);
|
|
11006
|
+
}
|
|
11007
|
+
return finalise(new Ctor(x), sd, rm);
|
|
11008
|
+
};
|
|
11009
|
+
P.toString = function() {
|
|
11010
|
+
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
11011
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
11012
|
+
};
|
|
11013
|
+
P.truncated = P.trunc = function() {
|
|
11014
|
+
return finalise(new this.constructor(this), this.e + 1, 1);
|
|
11015
|
+
};
|
|
11016
|
+
P.valueOf = P.toJSON = function() {
|
|
11017
|
+
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
11018
|
+
return x.isNeg() ? "-" + str : str;
|
|
11019
|
+
};
|
|
11020
|
+
function digitsToString(d) {
|
|
11021
|
+
var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
|
|
11022
|
+
if (indexOfLastWord > 0) {
|
|
11023
|
+
str += w;
|
|
11024
|
+
for (i = 1;i < indexOfLastWord; i++) {
|
|
11025
|
+
ws = d[i] + "";
|
|
11026
|
+
k = LOG_BASE - ws.length;
|
|
11027
|
+
if (k)
|
|
11028
|
+
str += getZeroString(k);
|
|
11029
|
+
str += ws;
|
|
11030
|
+
}
|
|
11031
|
+
w = d[i];
|
|
11032
|
+
ws = w + "";
|
|
11033
|
+
k = LOG_BASE - ws.length;
|
|
11034
|
+
if (k)
|
|
11035
|
+
str += getZeroString(k);
|
|
11036
|
+
} else if (w === 0) {
|
|
11037
|
+
return "0";
|
|
11038
|
+
}
|
|
11039
|
+
for (;w % 10 === 0; )
|
|
11040
|
+
w /= 10;
|
|
11041
|
+
return str + w;
|
|
11042
|
+
}
|
|
11043
|
+
function checkInt32(i, min, max) {
|
|
11044
|
+
if (i !== ~~i || i < min || i > max) {
|
|
11045
|
+
throw Error(invalidArgument + i);
|
|
11046
|
+
}
|
|
11047
|
+
}
|
|
11048
|
+
function checkRoundingDigits(d, i, rm, repeating) {
|
|
11049
|
+
var di, k, r, rd;
|
|
11050
|
+
for (k = d[0];k >= 10; k /= 10)
|
|
11051
|
+
--i;
|
|
11052
|
+
if (--i < 0) {
|
|
11053
|
+
i += LOG_BASE;
|
|
11054
|
+
di = 0;
|
|
11055
|
+
} else {
|
|
11056
|
+
di = Math.ceil((i + 1) / LOG_BASE);
|
|
11057
|
+
i %= LOG_BASE;
|
|
11058
|
+
}
|
|
11059
|
+
k = mathpow(10, LOG_BASE - i);
|
|
11060
|
+
rd = d[di] % k | 0;
|
|
11061
|
+
if (repeating == null) {
|
|
11062
|
+
if (i < 3) {
|
|
11063
|
+
if (i == 0)
|
|
11064
|
+
rd = rd / 100 | 0;
|
|
11065
|
+
else if (i == 1)
|
|
11066
|
+
rd = rd / 10 | 0;
|
|
11067
|
+
r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
|
|
11068
|
+
} else {
|
|
11069
|
+
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;
|
|
11070
|
+
}
|
|
11071
|
+
} else {
|
|
11072
|
+
if (i < 4) {
|
|
11073
|
+
if (i == 0)
|
|
11074
|
+
rd = rd / 1000 | 0;
|
|
11075
|
+
else if (i == 1)
|
|
11076
|
+
rd = rd / 100 | 0;
|
|
11077
|
+
else if (i == 2)
|
|
11078
|
+
rd = rd / 10 | 0;
|
|
11079
|
+
r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
|
|
11080
|
+
} else {
|
|
11081
|
+
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;
|
|
11082
|
+
}
|
|
11083
|
+
}
|
|
11084
|
+
return r;
|
|
11085
|
+
}
|
|
11086
|
+
function convertBase(str, baseIn, baseOut) {
|
|
11087
|
+
var j, arr = [0], arrL, i = 0, strL = str.length;
|
|
11088
|
+
for (;i < strL; ) {
|
|
11089
|
+
for (arrL = arr.length;arrL--; )
|
|
11090
|
+
arr[arrL] *= baseIn;
|
|
11091
|
+
arr[0] += NUMERALS.indexOf(str.charAt(i++));
|
|
11092
|
+
for (j = 0;j < arr.length; j++) {
|
|
11093
|
+
if (arr[j] > baseOut - 1) {
|
|
11094
|
+
if (arr[j + 1] === undefined)
|
|
11095
|
+
arr[j + 1] = 0;
|
|
11096
|
+
arr[j + 1] += arr[j] / baseOut | 0;
|
|
11097
|
+
arr[j] %= baseOut;
|
|
11098
|
+
}
|
|
11099
|
+
}
|
|
11100
|
+
}
|
|
11101
|
+
return arr.reverse();
|
|
11102
|
+
}
|
|
11103
|
+
function cosine(Ctor, x) {
|
|
11104
|
+
var k, len, y;
|
|
11105
|
+
if (x.isZero())
|
|
11106
|
+
return x;
|
|
11107
|
+
len = x.d.length;
|
|
11108
|
+
if (len < 32) {
|
|
11109
|
+
k = Math.ceil(len / 3);
|
|
11110
|
+
y = (1 / tinyPow(4, k)).toString();
|
|
11111
|
+
} else {
|
|
11112
|
+
k = 16;
|
|
11113
|
+
y = "2.3283064365386962890625e-10";
|
|
11114
|
+
}
|
|
11115
|
+
Ctor.precision += k;
|
|
11116
|
+
x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
|
|
11117
|
+
for (var i = k;i--; ) {
|
|
11118
|
+
var cos2x = x.times(x);
|
|
11119
|
+
x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
|
|
11120
|
+
}
|
|
11121
|
+
Ctor.precision -= k;
|
|
11122
|
+
return x;
|
|
11123
|
+
}
|
|
11124
|
+
var divide = function() {
|
|
11125
|
+
function multiplyInteger(x, k, base) {
|
|
11126
|
+
var temp, carry = 0, i = x.length;
|
|
11127
|
+
for (x = x.slice();i--; ) {
|
|
11128
|
+
temp = x[i] * k + carry;
|
|
11129
|
+
x[i] = temp % base | 0;
|
|
11130
|
+
carry = temp / base | 0;
|
|
11131
|
+
}
|
|
11132
|
+
if (carry)
|
|
11133
|
+
x.unshift(carry);
|
|
11134
|
+
return x;
|
|
11135
|
+
}
|
|
11136
|
+
function compare(a, b, aL, bL) {
|
|
11137
|
+
var i, r;
|
|
11138
|
+
if (aL != bL) {
|
|
11139
|
+
r = aL > bL ? 1 : -1;
|
|
11140
|
+
} else {
|
|
11141
|
+
for (i = r = 0;i < aL; i++) {
|
|
11142
|
+
if (a[i] != b[i]) {
|
|
11143
|
+
r = a[i] > b[i] ? 1 : -1;
|
|
11144
|
+
break;
|
|
11145
|
+
}
|
|
11146
|
+
}
|
|
11147
|
+
}
|
|
11148
|
+
return r;
|
|
11149
|
+
}
|
|
11150
|
+
function subtract(a, b, aL, base) {
|
|
11151
|
+
var i = 0;
|
|
11152
|
+
for (;aL--; ) {
|
|
11153
|
+
a[aL] -= i;
|
|
11154
|
+
i = a[aL] < b[aL] ? 1 : 0;
|
|
11155
|
+
a[aL] = i * base + a[aL] - b[aL];
|
|
11156
|
+
}
|
|
11157
|
+
for (;!a[0] && a.length > 1; )
|
|
11158
|
+
a.shift();
|
|
11159
|
+
}
|
|
11160
|
+
return function(x, y, pr, rm, dp, base) {
|
|
11161
|
+
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;
|
|
11162
|
+
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
11163
|
+
return new Ctor(!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
|
|
11164
|
+
}
|
|
11165
|
+
if (base) {
|
|
11166
|
+
logBase = 1;
|
|
11167
|
+
e = x.e - y.e;
|
|
11168
|
+
} else {
|
|
11169
|
+
base = BASE;
|
|
11170
|
+
logBase = LOG_BASE;
|
|
11171
|
+
e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
|
|
11172
|
+
}
|
|
11173
|
+
yL = yd.length;
|
|
11174
|
+
xL = xd.length;
|
|
11175
|
+
q = new Ctor(sign);
|
|
11176
|
+
qd = q.d = [];
|
|
11177
|
+
for (i = 0;yd[i] == (xd[i] || 0); i++)
|
|
11178
|
+
;
|
|
11179
|
+
if (yd[i] > (xd[i] || 0))
|
|
11180
|
+
e--;
|
|
11181
|
+
if (pr == null) {
|
|
11182
|
+
sd = pr = Ctor.precision;
|
|
11183
|
+
rm = Ctor.rounding;
|
|
11184
|
+
} else if (dp) {
|
|
11185
|
+
sd = pr + (x.e - y.e) + 1;
|
|
11186
|
+
} else {
|
|
11187
|
+
sd = pr;
|
|
11188
|
+
}
|
|
11189
|
+
if (sd < 0) {
|
|
11190
|
+
qd.push(1);
|
|
11191
|
+
more = true;
|
|
11192
|
+
} else {
|
|
11193
|
+
sd = sd / logBase + 2 | 0;
|
|
11194
|
+
i = 0;
|
|
11195
|
+
if (yL == 1) {
|
|
11196
|
+
k = 0;
|
|
11197
|
+
yd = yd[0];
|
|
11198
|
+
sd++;
|
|
11199
|
+
for (;(i < xL || k) && sd--; i++) {
|
|
11200
|
+
t = k * base + (xd[i] || 0);
|
|
11201
|
+
qd[i] = t / yd | 0;
|
|
11202
|
+
k = t % yd | 0;
|
|
11203
|
+
}
|
|
11204
|
+
more = k || i < xL;
|
|
11205
|
+
} else {
|
|
11206
|
+
k = base / (yd[0] + 1) | 0;
|
|
11207
|
+
if (k > 1) {
|
|
11208
|
+
yd = multiplyInteger(yd, k, base);
|
|
11209
|
+
xd = multiplyInteger(xd, k, base);
|
|
11210
|
+
yL = yd.length;
|
|
11211
|
+
xL = xd.length;
|
|
11212
|
+
}
|
|
11213
|
+
xi = yL;
|
|
11214
|
+
rem = xd.slice(0, yL);
|
|
11215
|
+
remL = rem.length;
|
|
11216
|
+
for (;remL < yL; )
|
|
11217
|
+
rem[remL++] = 0;
|
|
11218
|
+
yz = yd.slice();
|
|
11219
|
+
yz.unshift(0);
|
|
11220
|
+
yd0 = yd[0];
|
|
11221
|
+
if (yd[1] >= base / 2)
|
|
11222
|
+
++yd0;
|
|
11223
|
+
do {
|
|
11224
|
+
k = 0;
|
|
11225
|
+
cmp = compare(yd, rem, yL, remL);
|
|
11226
|
+
if (cmp < 0) {
|
|
11227
|
+
rem0 = rem[0];
|
|
11228
|
+
if (yL != remL)
|
|
11229
|
+
rem0 = rem0 * base + (rem[1] || 0);
|
|
11230
|
+
k = rem0 / yd0 | 0;
|
|
11231
|
+
if (k > 1) {
|
|
11232
|
+
if (k >= base)
|
|
11233
|
+
k = base - 1;
|
|
11234
|
+
prod = multiplyInteger(yd, k, base);
|
|
11235
|
+
prodL = prod.length;
|
|
11236
|
+
remL = rem.length;
|
|
11237
|
+
cmp = compare(prod, rem, prodL, remL);
|
|
11238
|
+
if (cmp == 1) {
|
|
11239
|
+
k--;
|
|
11240
|
+
subtract(prod, yL < prodL ? yz : yd, prodL, base);
|
|
11241
|
+
}
|
|
11242
|
+
} else {
|
|
11243
|
+
if (k == 0)
|
|
11244
|
+
cmp = k = 1;
|
|
11245
|
+
prod = yd.slice();
|
|
11246
|
+
}
|
|
11247
|
+
prodL = prod.length;
|
|
11248
|
+
if (prodL < remL)
|
|
11249
|
+
prod.unshift(0);
|
|
11250
|
+
subtract(rem, prod, remL, base);
|
|
11251
|
+
if (cmp == -1) {
|
|
11252
|
+
remL = rem.length;
|
|
11253
|
+
cmp = compare(yd, rem, yL, remL);
|
|
11254
|
+
if (cmp < 1) {
|
|
11255
|
+
k++;
|
|
11256
|
+
subtract(rem, yL < remL ? yz : yd, remL, base);
|
|
11257
|
+
}
|
|
11258
|
+
}
|
|
11259
|
+
remL = rem.length;
|
|
11260
|
+
} else if (cmp === 0) {
|
|
11261
|
+
k++;
|
|
11262
|
+
rem = [0];
|
|
11263
|
+
}
|
|
11264
|
+
qd[i++] = k;
|
|
11265
|
+
if (cmp && rem[0]) {
|
|
11266
|
+
rem[remL++] = xd[xi] || 0;
|
|
11267
|
+
} else {
|
|
11268
|
+
rem = [xd[xi]];
|
|
11269
|
+
remL = 1;
|
|
11270
|
+
}
|
|
11271
|
+
} while ((xi++ < xL || rem[0] !== undefined) && sd--);
|
|
11272
|
+
more = rem[0] !== undefined;
|
|
11273
|
+
}
|
|
11274
|
+
if (!qd[0])
|
|
11275
|
+
qd.shift();
|
|
11276
|
+
}
|
|
11277
|
+
if (logBase == 1) {
|
|
11278
|
+
q.e = e;
|
|
11279
|
+
inexact = more;
|
|
11280
|
+
} else {
|
|
11281
|
+
for (i = 1, k = qd[0];k >= 10; k /= 10)
|
|
11282
|
+
i++;
|
|
11283
|
+
q.e = i + e * logBase - 1;
|
|
11284
|
+
finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
|
|
11285
|
+
}
|
|
11286
|
+
return q;
|
|
11287
|
+
};
|
|
11288
|
+
}();
|
|
11289
|
+
function finalise(x, sd, rm, isTruncated) {
|
|
11290
|
+
var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
|
|
11291
|
+
out:
|
|
11292
|
+
if (sd != null) {
|
|
11293
|
+
xd = x.d;
|
|
11294
|
+
if (!xd)
|
|
11295
|
+
return x;
|
|
11296
|
+
for (digits = 1, k = xd[0];k >= 10; k /= 10)
|
|
11297
|
+
digits++;
|
|
11298
|
+
i = sd - digits;
|
|
11299
|
+
if (i < 0) {
|
|
11300
|
+
i += LOG_BASE;
|
|
11301
|
+
j = sd;
|
|
11302
|
+
w = xd[xdi = 0];
|
|
11303
|
+
rd = w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
11304
|
+
} else {
|
|
11305
|
+
xdi = Math.ceil((i + 1) / LOG_BASE);
|
|
11306
|
+
k = xd.length;
|
|
11307
|
+
if (xdi >= k) {
|
|
11308
|
+
if (isTruncated) {
|
|
11309
|
+
for (;k++ <= xdi; )
|
|
11310
|
+
xd.push(0);
|
|
11311
|
+
w = rd = 0;
|
|
11312
|
+
digits = 1;
|
|
11313
|
+
i %= LOG_BASE;
|
|
11314
|
+
j = i - LOG_BASE + 1;
|
|
11315
|
+
} else {
|
|
11316
|
+
break out;
|
|
11317
|
+
}
|
|
11318
|
+
} else {
|
|
11319
|
+
w = k = xd[xdi];
|
|
11320
|
+
for (digits = 1;k >= 10; k /= 10)
|
|
11321
|
+
digits++;
|
|
11322
|
+
i %= LOG_BASE;
|
|
11323
|
+
j = i - LOG_BASE + digits;
|
|
11324
|
+
rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
11325
|
+
}
|
|
11326
|
+
}
|
|
11327
|
+
isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== undefined || (j < 0 ? w : w % mathpow(10, digits - j - 1));
|
|
11328
|
+
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));
|
|
11329
|
+
if (sd < 1 || !xd[0]) {
|
|
11330
|
+
xd.length = 0;
|
|
11331
|
+
if (roundUp) {
|
|
11332
|
+
sd -= x.e + 1;
|
|
11333
|
+
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
|
|
11334
|
+
x.e = -sd || 0;
|
|
11335
|
+
} else {
|
|
11336
|
+
xd[0] = x.e = 0;
|
|
11337
|
+
}
|
|
11338
|
+
return x;
|
|
11339
|
+
}
|
|
11340
|
+
if (i == 0) {
|
|
11341
|
+
xd.length = xdi;
|
|
11342
|
+
k = 1;
|
|
11343
|
+
xdi--;
|
|
11344
|
+
} else {
|
|
11345
|
+
xd.length = xdi + 1;
|
|
11346
|
+
k = mathpow(10, LOG_BASE - i);
|
|
11347
|
+
xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
|
|
11348
|
+
}
|
|
11349
|
+
if (roundUp) {
|
|
11350
|
+
for (;; ) {
|
|
11351
|
+
if (xdi == 0) {
|
|
11352
|
+
for (i = 1, j = xd[0];j >= 10; j /= 10)
|
|
11353
|
+
i++;
|
|
11354
|
+
j = xd[0] += k;
|
|
11355
|
+
for (k = 1;j >= 10; j /= 10)
|
|
11356
|
+
k++;
|
|
11357
|
+
if (i != k) {
|
|
11358
|
+
x.e++;
|
|
11359
|
+
if (xd[0] == BASE)
|
|
11360
|
+
xd[0] = 1;
|
|
11361
|
+
}
|
|
11362
|
+
break;
|
|
11363
|
+
} else {
|
|
11364
|
+
xd[xdi] += k;
|
|
11365
|
+
if (xd[xdi] != BASE)
|
|
11366
|
+
break;
|
|
11367
|
+
xd[xdi--] = 0;
|
|
11368
|
+
k = 1;
|
|
11369
|
+
}
|
|
11370
|
+
}
|
|
11371
|
+
}
|
|
11372
|
+
for (i = xd.length;xd[--i] === 0; )
|
|
11373
|
+
xd.pop();
|
|
11374
|
+
}
|
|
11375
|
+
if (external2) {
|
|
11376
|
+
if (x.e > Ctor.maxE) {
|
|
11377
|
+
x.d = null;
|
|
11378
|
+
x.e = NaN;
|
|
11379
|
+
} else if (x.e < Ctor.minE) {
|
|
11380
|
+
x.e = 0;
|
|
11381
|
+
x.d = [0];
|
|
11382
|
+
}
|
|
11383
|
+
}
|
|
11384
|
+
return x;
|
|
11385
|
+
}
|
|
11386
|
+
function finiteToString(x, isExp, sd) {
|
|
11387
|
+
if (!x.isFinite())
|
|
11388
|
+
return nonFiniteToString(x);
|
|
11389
|
+
var k, e = x.e, str = digitsToString(x.d), len = str.length;
|
|
11390
|
+
if (isExp) {
|
|
11391
|
+
if (sd && (k = sd - len) > 0) {
|
|
11392
|
+
str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
|
|
11393
|
+
} else if (len > 1) {
|
|
11394
|
+
str = str.charAt(0) + "." + str.slice(1);
|
|
11395
|
+
}
|
|
11396
|
+
str = str + (x.e < 0 ? "e" : "e+") + x.e;
|
|
11397
|
+
} else if (e < 0) {
|
|
11398
|
+
str = "0." + getZeroString(-e - 1) + str;
|
|
11399
|
+
if (sd && (k = sd - len) > 0)
|
|
11400
|
+
str += getZeroString(k);
|
|
11401
|
+
} else if (e >= len) {
|
|
11402
|
+
str += getZeroString(e + 1 - len);
|
|
11403
|
+
if (sd && (k = sd - e - 1) > 0)
|
|
11404
|
+
str = str + "." + getZeroString(k);
|
|
11405
|
+
} else {
|
|
11406
|
+
if ((k = e + 1) < len)
|
|
11407
|
+
str = str.slice(0, k) + "." + str.slice(k);
|
|
11408
|
+
if (sd && (k = sd - len) > 0) {
|
|
11409
|
+
if (e + 1 === len)
|
|
11410
|
+
str += ".";
|
|
11411
|
+
str += getZeroString(k);
|
|
11412
|
+
}
|
|
11413
|
+
}
|
|
11414
|
+
return str;
|
|
11415
|
+
}
|
|
11416
|
+
function getBase10Exponent(digits, e) {
|
|
11417
|
+
var w = digits[0];
|
|
11418
|
+
for (e *= LOG_BASE;w >= 10; w /= 10)
|
|
11419
|
+
e++;
|
|
11420
|
+
return e;
|
|
11421
|
+
}
|
|
11422
|
+
function getLn10(Ctor, sd, pr) {
|
|
11423
|
+
if (sd > LN10_PRECISION) {
|
|
11424
|
+
external2 = true;
|
|
11425
|
+
if (pr)
|
|
11426
|
+
Ctor.precision = pr;
|
|
11427
|
+
throw Error(precisionLimitExceeded);
|
|
11428
|
+
}
|
|
11429
|
+
return finalise(new Ctor(LN10), sd, 1, true);
|
|
11430
|
+
}
|
|
11431
|
+
function getPi(Ctor, sd, rm) {
|
|
11432
|
+
if (sd > PI_PRECISION)
|
|
11433
|
+
throw Error(precisionLimitExceeded);
|
|
11434
|
+
return finalise(new Ctor(PI), sd, rm, true);
|
|
11435
|
+
}
|
|
11436
|
+
function getPrecision(digits) {
|
|
11437
|
+
var w = digits.length - 1, len = w * LOG_BASE + 1;
|
|
11438
|
+
w = digits[w];
|
|
11439
|
+
if (w) {
|
|
11440
|
+
for (;w % 10 == 0; w /= 10)
|
|
11441
|
+
len--;
|
|
11442
|
+
for (w = digits[0];w >= 10; w /= 10)
|
|
11443
|
+
len++;
|
|
11444
|
+
}
|
|
11445
|
+
return len;
|
|
11446
|
+
}
|
|
11447
|
+
function getZeroString(k) {
|
|
11448
|
+
var zs = "";
|
|
11449
|
+
for (;k--; )
|
|
11450
|
+
zs += "0";
|
|
11451
|
+
return zs;
|
|
11452
|
+
}
|
|
11453
|
+
function intPow(Ctor, x, n, pr) {
|
|
11454
|
+
var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
|
|
11455
|
+
external2 = false;
|
|
11456
|
+
for (;; ) {
|
|
11457
|
+
if (n % 2) {
|
|
11458
|
+
r = r.times(x);
|
|
11459
|
+
if (truncate(r.d, k))
|
|
11460
|
+
isTruncated = true;
|
|
11461
|
+
}
|
|
11462
|
+
n = mathfloor(n / 2);
|
|
11463
|
+
if (n === 0) {
|
|
11464
|
+
n = r.d.length - 1;
|
|
11465
|
+
if (isTruncated && r.d[n] === 0)
|
|
11466
|
+
++r.d[n];
|
|
11467
|
+
break;
|
|
11468
|
+
}
|
|
11469
|
+
x = x.times(x);
|
|
11470
|
+
truncate(x.d, k);
|
|
11471
|
+
}
|
|
11472
|
+
external2 = true;
|
|
11473
|
+
return r;
|
|
11474
|
+
}
|
|
11475
|
+
function isOdd(n) {
|
|
11476
|
+
return n.d[n.d.length - 1] & 1;
|
|
11477
|
+
}
|
|
11478
|
+
function maxOrMin(Ctor, args, n) {
|
|
11479
|
+
var k, y, x = new Ctor(args[0]), i = 0;
|
|
11480
|
+
for (;++i < args.length; ) {
|
|
11481
|
+
y = new Ctor(args[i]);
|
|
11482
|
+
if (!y.s) {
|
|
11483
|
+
x = y;
|
|
11484
|
+
break;
|
|
11485
|
+
}
|
|
11486
|
+
k = x.cmp(y);
|
|
11487
|
+
if (k === n || k === 0 && x.s === n) {
|
|
11488
|
+
x = y;
|
|
11489
|
+
}
|
|
11490
|
+
}
|
|
11491
|
+
return x;
|
|
11492
|
+
}
|
|
11493
|
+
function naturalExponential(x, sd) {
|
|
11494
|
+
var denominator, guard, j, pow, sum, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
11495
|
+
if (!x.d || !x.d[0] || x.e > 17) {
|
|
11496
|
+
return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
|
|
11497
|
+
}
|
|
11498
|
+
if (sd == null) {
|
|
11499
|
+
external2 = false;
|
|
11500
|
+
wpr = pr;
|
|
11501
|
+
} else {
|
|
11502
|
+
wpr = sd;
|
|
11503
|
+
}
|
|
11504
|
+
t = new Ctor(0.03125);
|
|
11505
|
+
while (x.e > -2) {
|
|
11506
|
+
x = x.times(t);
|
|
11507
|
+
k += 5;
|
|
11508
|
+
}
|
|
11509
|
+
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
|
|
11510
|
+
wpr += guard;
|
|
11511
|
+
denominator = pow = sum = new Ctor(1);
|
|
11512
|
+
Ctor.precision = wpr;
|
|
11513
|
+
for (;; ) {
|
|
11514
|
+
pow = finalise(pow.times(x), wpr, 1);
|
|
11515
|
+
denominator = denominator.times(++i);
|
|
11516
|
+
t = sum.plus(divide(pow, denominator, wpr, 1));
|
|
11517
|
+
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
11518
|
+
j = k;
|
|
11519
|
+
while (j--)
|
|
11520
|
+
sum = finalise(sum.times(sum), wpr, 1);
|
|
11521
|
+
if (sd == null) {
|
|
11522
|
+
if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
|
|
11523
|
+
Ctor.precision = wpr += 10;
|
|
11524
|
+
denominator = pow = t = new Ctor(1);
|
|
11525
|
+
i = 0;
|
|
11526
|
+
rep++;
|
|
11527
|
+
} else {
|
|
11528
|
+
return finalise(sum, Ctor.precision = pr, rm, external2 = true);
|
|
11529
|
+
}
|
|
11530
|
+
} else {
|
|
11531
|
+
Ctor.precision = pr;
|
|
11532
|
+
return sum;
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
sum = t;
|
|
11536
|
+
}
|
|
11537
|
+
}
|
|
11538
|
+
function naturalLogarithm(y, sd) {
|
|
11539
|
+
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;
|
|
11540
|
+
if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
|
|
11541
|
+
return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
|
|
11542
|
+
}
|
|
11543
|
+
if (sd == null) {
|
|
11544
|
+
external2 = false;
|
|
11545
|
+
wpr = pr;
|
|
11546
|
+
} else {
|
|
11547
|
+
wpr = sd;
|
|
11548
|
+
}
|
|
11549
|
+
Ctor.precision = wpr += guard;
|
|
11550
|
+
c = digitsToString(xd);
|
|
11551
|
+
c0 = c.charAt(0);
|
|
11552
|
+
if (Math.abs(e = x.e) < 1500000000000000) {
|
|
11553
|
+
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
|
|
11554
|
+
x = x.times(y);
|
|
11555
|
+
c = digitsToString(x.d);
|
|
11556
|
+
c0 = c.charAt(0);
|
|
11557
|
+
n++;
|
|
11558
|
+
}
|
|
11559
|
+
e = x.e;
|
|
11560
|
+
if (c0 > 1) {
|
|
11561
|
+
x = new Ctor("0." + c);
|
|
11562
|
+
e++;
|
|
11563
|
+
} else {
|
|
11564
|
+
x = new Ctor(c0 + "." + c.slice(1));
|
|
11565
|
+
}
|
|
11566
|
+
} else {
|
|
11567
|
+
t = getLn10(Ctor, wpr + 2, pr).times(e + "");
|
|
11568
|
+
x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
|
|
11569
|
+
Ctor.precision = pr;
|
|
11570
|
+
return sd == null ? finalise(x, pr, rm, external2 = true) : x;
|
|
11571
|
+
}
|
|
11572
|
+
x1 = x;
|
|
11573
|
+
sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
|
|
11574
|
+
x2 = finalise(x.times(x), wpr, 1);
|
|
11575
|
+
denominator = 3;
|
|
11576
|
+
for (;; ) {
|
|
11577
|
+
numerator = finalise(numerator.times(x2), wpr, 1);
|
|
11578
|
+
t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
|
|
11579
|
+
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
|
|
11580
|
+
sum = sum.times(2);
|
|
11581
|
+
if (e !== 0)
|
|
11582
|
+
sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
|
|
11583
|
+
sum = divide(sum, new Ctor(n), wpr, 1);
|
|
11584
|
+
if (sd == null) {
|
|
11585
|
+
if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
|
|
11586
|
+
Ctor.precision = wpr += guard;
|
|
11587
|
+
t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
|
|
11588
|
+
x2 = finalise(x.times(x), wpr, 1);
|
|
11589
|
+
denominator = rep = 1;
|
|
11590
|
+
} else {
|
|
11591
|
+
return finalise(sum, Ctor.precision = pr, rm, external2 = true);
|
|
11592
|
+
}
|
|
11593
|
+
} else {
|
|
11594
|
+
Ctor.precision = pr;
|
|
11595
|
+
return sum;
|
|
11596
|
+
}
|
|
11597
|
+
}
|
|
11598
|
+
sum = t;
|
|
11599
|
+
denominator += 2;
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
function nonFiniteToString(x) {
|
|
11603
|
+
return String(x.s * x.s / 0);
|
|
11604
|
+
}
|
|
11605
|
+
function parseDecimal(x, str) {
|
|
11606
|
+
var e, i, len;
|
|
11607
|
+
if ((e = str.indexOf(".")) > -1)
|
|
11608
|
+
str = str.replace(".", "");
|
|
11609
|
+
if ((i = str.search(/e/i)) > 0) {
|
|
11610
|
+
if (e < 0)
|
|
11611
|
+
e = i;
|
|
11612
|
+
e += +str.slice(i + 1);
|
|
11613
|
+
str = str.substring(0, i);
|
|
11614
|
+
} else if (e < 0) {
|
|
11615
|
+
e = str.length;
|
|
11616
|
+
}
|
|
11617
|
+
for (i = 0;str.charCodeAt(i) === 48; i++)
|
|
11618
|
+
;
|
|
11619
|
+
for (len = str.length;str.charCodeAt(len - 1) === 48; --len)
|
|
11620
|
+
;
|
|
11621
|
+
str = str.slice(i, len);
|
|
11622
|
+
if (str) {
|
|
11623
|
+
len -= i;
|
|
11624
|
+
x.e = e = e - i - 1;
|
|
11625
|
+
x.d = [];
|
|
11626
|
+
i = (e + 1) % LOG_BASE;
|
|
11627
|
+
if (e < 0)
|
|
11628
|
+
i += LOG_BASE;
|
|
11629
|
+
if (i < len) {
|
|
11630
|
+
if (i)
|
|
11631
|
+
x.d.push(+str.slice(0, i));
|
|
11632
|
+
for (len -= LOG_BASE;i < len; )
|
|
11633
|
+
x.d.push(+str.slice(i, i += LOG_BASE));
|
|
11634
|
+
str = str.slice(i);
|
|
11635
|
+
i = LOG_BASE - str.length;
|
|
11636
|
+
} else {
|
|
11637
|
+
i -= len;
|
|
11638
|
+
}
|
|
11639
|
+
for (;i--; )
|
|
11640
|
+
str += "0";
|
|
11641
|
+
x.d.push(+str);
|
|
11642
|
+
if (external2) {
|
|
11643
|
+
if (x.e > x.constructor.maxE) {
|
|
11644
|
+
x.d = null;
|
|
11645
|
+
x.e = NaN;
|
|
11646
|
+
} else if (x.e < x.constructor.minE) {
|
|
11647
|
+
x.e = 0;
|
|
11648
|
+
x.d = [0];
|
|
11649
|
+
}
|
|
11650
|
+
}
|
|
11651
|
+
} else {
|
|
11652
|
+
x.e = 0;
|
|
11653
|
+
x.d = [0];
|
|
11654
|
+
}
|
|
11655
|
+
return x;
|
|
11656
|
+
}
|
|
11657
|
+
function parseOther(x, str) {
|
|
11658
|
+
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
|
11659
|
+
if (str.indexOf("_") > -1) {
|
|
11660
|
+
str = str.replace(/(\d)_(?=\d)/g, "$1");
|
|
11661
|
+
if (isDecimal.test(str))
|
|
11662
|
+
return parseDecimal(x, str);
|
|
11663
|
+
} else if (str === "Infinity" || str === "NaN") {
|
|
11664
|
+
if (!+str)
|
|
11665
|
+
x.s = NaN;
|
|
11666
|
+
x.e = NaN;
|
|
11667
|
+
x.d = null;
|
|
11668
|
+
return x;
|
|
11669
|
+
}
|
|
11670
|
+
if (isHex.test(str)) {
|
|
11671
|
+
base = 16;
|
|
11672
|
+
str = str.toLowerCase();
|
|
11673
|
+
} else if (isBinary.test(str)) {
|
|
11674
|
+
base = 2;
|
|
11675
|
+
} else if (isOctal.test(str)) {
|
|
11676
|
+
base = 8;
|
|
11677
|
+
} else {
|
|
11678
|
+
throw Error(invalidArgument + str);
|
|
11679
|
+
}
|
|
11680
|
+
i = str.search(/p/i);
|
|
11681
|
+
if (i > 0) {
|
|
11682
|
+
p = +str.slice(i + 1);
|
|
11683
|
+
str = str.substring(2, i);
|
|
11684
|
+
} else {
|
|
11685
|
+
str = str.slice(2);
|
|
11686
|
+
}
|
|
11687
|
+
i = str.indexOf(".");
|
|
11688
|
+
isFloat = i >= 0;
|
|
11689
|
+
Ctor = x.constructor;
|
|
11690
|
+
if (isFloat) {
|
|
11691
|
+
str = str.replace(".", "");
|
|
11692
|
+
len = str.length;
|
|
11693
|
+
i = len - i;
|
|
11694
|
+
divisor = intPow(Ctor, new Ctor(base), i, i * 2);
|
|
11695
|
+
}
|
|
11696
|
+
xd = convertBase(str, base, BASE);
|
|
11697
|
+
xe = xd.length - 1;
|
|
11698
|
+
for (i = xe;xd[i] === 0; --i)
|
|
11699
|
+
xd.pop();
|
|
11700
|
+
if (i < 0)
|
|
11701
|
+
return new Ctor(x.s * 0);
|
|
11702
|
+
x.e = getBase10Exponent(xd, xe);
|
|
11703
|
+
x.d = xd;
|
|
11704
|
+
external2 = false;
|
|
11705
|
+
if (isFloat)
|
|
11706
|
+
x = divide(x, divisor, len * 4);
|
|
11707
|
+
if (p)
|
|
11708
|
+
x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
|
|
11709
|
+
external2 = true;
|
|
11710
|
+
return x;
|
|
11711
|
+
}
|
|
11712
|
+
function sine(Ctor, x) {
|
|
11713
|
+
var k, len = x.d.length;
|
|
11714
|
+
if (len < 3) {
|
|
11715
|
+
return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
|
|
11716
|
+
}
|
|
11717
|
+
k = 1.4 * Math.sqrt(len);
|
|
11718
|
+
k = k > 16 ? 16 : k | 0;
|
|
11719
|
+
x = x.times(1 / tinyPow(5, k));
|
|
11720
|
+
x = taylorSeries(Ctor, 2, x, x);
|
|
11721
|
+
var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
11722
|
+
for (;k--; ) {
|
|
11723
|
+
sin2_x = x.times(x);
|
|
11724
|
+
x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
|
|
11725
|
+
}
|
|
11726
|
+
return x;
|
|
11727
|
+
}
|
|
11728
|
+
function taylorSeries(Ctor, n, x, y, isHyperbolic) {
|
|
11729
|
+
var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
|
|
11730
|
+
external2 = false;
|
|
11731
|
+
x2 = x.times(x);
|
|
11732
|
+
u = new Ctor(y);
|
|
11733
|
+
for (;; ) {
|
|
11734
|
+
t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
11735
|
+
u = isHyperbolic ? y.plus(t) : y.minus(t);
|
|
11736
|
+
y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
11737
|
+
t = u.plus(y);
|
|
11738
|
+
if (t.d[k] !== undefined) {
|
|
11739
|
+
for (j = k;t.d[j] === u.d[j] && j--; )
|
|
11740
|
+
;
|
|
11741
|
+
if (j == -1)
|
|
11742
|
+
break;
|
|
11743
|
+
}
|
|
11744
|
+
j = u;
|
|
11745
|
+
u = y;
|
|
11746
|
+
y = t;
|
|
11747
|
+
t = j;
|
|
11748
|
+
i++;
|
|
11749
|
+
}
|
|
11750
|
+
external2 = true;
|
|
11751
|
+
t.d.length = k + 1;
|
|
11752
|
+
return t;
|
|
11753
|
+
}
|
|
11754
|
+
function tinyPow(b, e) {
|
|
11755
|
+
var n = b;
|
|
11756
|
+
while (--e)
|
|
11757
|
+
n *= b;
|
|
11758
|
+
return n;
|
|
11759
|
+
}
|
|
11760
|
+
function toLessThanHalfPi(Ctor, x) {
|
|
11761
|
+
var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
|
|
11762
|
+
x = x.abs();
|
|
11763
|
+
if (x.lte(halfPi)) {
|
|
11764
|
+
quadrant = isNeg ? 4 : 1;
|
|
11765
|
+
return x;
|
|
11766
|
+
}
|
|
11767
|
+
t = x.divToInt(pi);
|
|
11768
|
+
if (t.isZero()) {
|
|
11769
|
+
quadrant = isNeg ? 3 : 2;
|
|
11770
|
+
} else {
|
|
11771
|
+
x = x.minus(t.times(pi));
|
|
11772
|
+
if (x.lte(halfPi)) {
|
|
11773
|
+
quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
|
|
11774
|
+
return x;
|
|
11775
|
+
}
|
|
11776
|
+
quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
|
|
11777
|
+
}
|
|
11778
|
+
return x.minus(pi).abs();
|
|
11779
|
+
}
|
|
11780
|
+
function toStringBinary(x, baseOut, sd, rm) {
|
|
11781
|
+
var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== undefined;
|
|
11782
|
+
if (isExp) {
|
|
11783
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
11784
|
+
if (rm === undefined)
|
|
11785
|
+
rm = Ctor.rounding;
|
|
11786
|
+
else
|
|
11787
|
+
checkInt32(rm, 0, 8);
|
|
11788
|
+
} else {
|
|
11789
|
+
sd = Ctor.precision;
|
|
11790
|
+
rm = Ctor.rounding;
|
|
11791
|
+
}
|
|
11792
|
+
if (!x.isFinite()) {
|
|
11793
|
+
str = nonFiniteToString(x);
|
|
11794
|
+
} else {
|
|
11795
|
+
str = finiteToString(x);
|
|
11796
|
+
i = str.indexOf(".");
|
|
11797
|
+
if (isExp) {
|
|
11798
|
+
base = 2;
|
|
11799
|
+
if (baseOut == 16) {
|
|
11800
|
+
sd = sd * 4 - 3;
|
|
11801
|
+
} else if (baseOut == 8) {
|
|
11802
|
+
sd = sd * 3 - 2;
|
|
11803
|
+
}
|
|
11804
|
+
} else {
|
|
11805
|
+
base = baseOut;
|
|
11806
|
+
}
|
|
11807
|
+
if (i >= 0) {
|
|
11808
|
+
str = str.replace(".", "");
|
|
11809
|
+
y = new Ctor(1);
|
|
11810
|
+
y.e = str.length - i;
|
|
11811
|
+
y.d = convertBase(finiteToString(y), 10, base);
|
|
11812
|
+
y.e = y.d.length;
|
|
11813
|
+
}
|
|
11814
|
+
xd = convertBase(str, 10, base);
|
|
11815
|
+
e = len = xd.length;
|
|
11816
|
+
for (;xd[--len] == 0; )
|
|
11817
|
+
xd.pop();
|
|
11818
|
+
if (!xd[0]) {
|
|
11819
|
+
str = isExp ? "0p+0" : "0";
|
|
11820
|
+
} else {
|
|
11821
|
+
if (i < 0) {
|
|
11822
|
+
e--;
|
|
11823
|
+
} else {
|
|
11824
|
+
x = new Ctor(x);
|
|
11825
|
+
x.d = xd;
|
|
11826
|
+
x.e = e;
|
|
11827
|
+
x = divide(x, y, sd, rm, 0, base);
|
|
11828
|
+
xd = x.d;
|
|
11829
|
+
e = x.e;
|
|
11830
|
+
roundUp = inexact;
|
|
11831
|
+
}
|
|
11832
|
+
i = xd[sd];
|
|
11833
|
+
k = base / 2;
|
|
11834
|
+
roundUp = roundUp || xd[sd + 1] !== undefined;
|
|
11835
|
+
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));
|
|
11836
|
+
xd.length = sd;
|
|
11837
|
+
if (roundUp) {
|
|
11838
|
+
for (;++xd[--sd] > base - 1; ) {
|
|
11839
|
+
xd[sd] = 0;
|
|
11840
|
+
if (!sd) {
|
|
11841
|
+
++e;
|
|
11842
|
+
xd.unshift(1);
|
|
11843
|
+
}
|
|
11844
|
+
}
|
|
11845
|
+
}
|
|
11846
|
+
for (len = xd.length;!xd[len - 1]; --len)
|
|
11847
|
+
;
|
|
11848
|
+
for (i = 0, str = "";i < len; i++)
|
|
11849
|
+
str += NUMERALS.charAt(xd[i]);
|
|
11850
|
+
if (isExp) {
|
|
11851
|
+
if (len > 1) {
|
|
11852
|
+
if (baseOut == 16 || baseOut == 8) {
|
|
11853
|
+
i = baseOut == 16 ? 4 : 3;
|
|
11854
|
+
for (--len;len % i; len++)
|
|
11855
|
+
str += "0";
|
|
11856
|
+
xd = convertBase(str, base, baseOut);
|
|
11857
|
+
for (len = xd.length;!xd[len - 1]; --len)
|
|
11858
|
+
;
|
|
11859
|
+
for (i = 1, str = "1.";i < len; i++)
|
|
11860
|
+
str += NUMERALS.charAt(xd[i]);
|
|
11861
|
+
} else {
|
|
11862
|
+
str = str.charAt(0) + "." + str.slice(1);
|
|
11863
|
+
}
|
|
11864
|
+
}
|
|
11865
|
+
str = str + (e < 0 ? "p" : "p+") + e;
|
|
11866
|
+
} else if (e < 0) {
|
|
11867
|
+
for (;++e; )
|
|
11868
|
+
str = "0" + str;
|
|
11869
|
+
str = "0." + str;
|
|
11870
|
+
} else {
|
|
11871
|
+
if (++e > len)
|
|
11872
|
+
for (e -= len;e--; )
|
|
11873
|
+
str += "0";
|
|
11874
|
+
else if (e < len)
|
|
11875
|
+
str = str.slice(0, e) + "." + str.slice(e);
|
|
11876
|
+
}
|
|
11877
|
+
}
|
|
11878
|
+
str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
|
|
11879
|
+
}
|
|
11880
|
+
return x.s < 0 ? "-" + str : str;
|
|
11881
|
+
}
|
|
11882
|
+
function truncate(arr, len) {
|
|
11883
|
+
if (arr.length > len) {
|
|
11884
|
+
arr.length = len;
|
|
11885
|
+
return true;
|
|
11886
|
+
}
|
|
11887
|
+
}
|
|
11888
|
+
function abs(x) {
|
|
11889
|
+
return new this(x).abs();
|
|
11890
|
+
}
|
|
11891
|
+
function acos(x) {
|
|
11892
|
+
return new this(x).acos();
|
|
11893
|
+
}
|
|
11894
|
+
function acosh(x) {
|
|
11895
|
+
return new this(x).acosh();
|
|
11896
|
+
}
|
|
11897
|
+
function add(x, y) {
|
|
11898
|
+
return new this(x).plus(y);
|
|
11899
|
+
}
|
|
11900
|
+
function asin(x) {
|
|
11901
|
+
return new this(x).asin();
|
|
11902
|
+
}
|
|
11903
|
+
function asinh(x) {
|
|
11904
|
+
return new this(x).asinh();
|
|
11905
|
+
}
|
|
11906
|
+
function atan(x) {
|
|
11907
|
+
return new this(x).atan();
|
|
11908
|
+
}
|
|
11909
|
+
function atanh(x) {
|
|
11910
|
+
return new this(x).atanh();
|
|
11911
|
+
}
|
|
11912
|
+
function atan2(y, x) {
|
|
11913
|
+
y = new this(y);
|
|
11914
|
+
x = new this(x);
|
|
11915
|
+
var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
|
|
11916
|
+
if (!y.s || !x.s) {
|
|
11917
|
+
r = new this(NaN);
|
|
11918
|
+
} else if (!y.d && !x.d) {
|
|
11919
|
+
r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
|
|
11920
|
+
r.s = y.s;
|
|
11921
|
+
} else if (!x.d || y.isZero()) {
|
|
11922
|
+
r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
|
|
11923
|
+
r.s = y.s;
|
|
11924
|
+
} else if (!y.d || x.isZero()) {
|
|
11925
|
+
r = getPi(this, wpr, 1).times(0.5);
|
|
11926
|
+
r.s = y.s;
|
|
11927
|
+
} else if (x.s < 0) {
|
|
11928
|
+
this.precision = wpr;
|
|
11929
|
+
this.rounding = 1;
|
|
11930
|
+
r = this.atan(divide(y, x, wpr, 1));
|
|
11931
|
+
x = getPi(this, wpr, 1);
|
|
11932
|
+
this.precision = pr;
|
|
11933
|
+
this.rounding = rm;
|
|
11934
|
+
r = y.s < 0 ? r.minus(x) : r.plus(x);
|
|
11935
|
+
} else {
|
|
11936
|
+
r = this.atan(divide(y, x, wpr, 1));
|
|
11937
|
+
}
|
|
11938
|
+
return r;
|
|
11939
|
+
}
|
|
11940
|
+
function cbrt(x) {
|
|
11941
|
+
return new this(x).cbrt();
|
|
11942
|
+
}
|
|
11943
|
+
function ceil(x) {
|
|
11944
|
+
return finalise(x = new this(x), x.e + 1, 2);
|
|
11945
|
+
}
|
|
11946
|
+
function clamp(x, min, max) {
|
|
11947
|
+
return new this(x).clamp(min, max);
|
|
11948
|
+
}
|
|
11949
|
+
function config(obj) {
|
|
11950
|
+
if (!obj || typeof obj !== "object")
|
|
11951
|
+
throw Error(decimalError + "Object expected");
|
|
11952
|
+
var i, p, v, useDefaults = obj.defaults === true, ps = [
|
|
11953
|
+
"precision",
|
|
11954
|
+
1,
|
|
11955
|
+
MAX_DIGITS,
|
|
11956
|
+
"rounding",
|
|
11957
|
+
0,
|
|
11958
|
+
8,
|
|
11959
|
+
"toExpNeg",
|
|
11960
|
+
-EXP_LIMIT,
|
|
11961
|
+
0,
|
|
11962
|
+
"toExpPos",
|
|
11963
|
+
0,
|
|
11964
|
+
EXP_LIMIT,
|
|
11965
|
+
"maxE",
|
|
11966
|
+
0,
|
|
11967
|
+
EXP_LIMIT,
|
|
11968
|
+
"minE",
|
|
11969
|
+
-EXP_LIMIT,
|
|
11970
|
+
0,
|
|
11971
|
+
"modulo",
|
|
11972
|
+
0,
|
|
11973
|
+
9
|
|
11974
|
+
];
|
|
11975
|
+
for (i = 0;i < ps.length; i += 3) {
|
|
11976
|
+
if (p = ps[i], useDefaults)
|
|
11977
|
+
this[p] = DEFAULTS[p];
|
|
11978
|
+
if ((v = obj[p]) !== undefined) {
|
|
11979
|
+
if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
|
|
11980
|
+
this[p] = v;
|
|
11981
|
+
else
|
|
11982
|
+
throw Error(invalidArgument + p + ": " + v);
|
|
11983
|
+
}
|
|
11984
|
+
}
|
|
11985
|
+
if (p = "crypto", useDefaults)
|
|
11986
|
+
this[p] = DEFAULTS[p];
|
|
11987
|
+
if ((v = obj[p]) !== undefined) {
|
|
11988
|
+
if (v === true || v === false || v === 0 || v === 1) {
|
|
11989
|
+
if (v) {
|
|
11990
|
+
if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
|
|
11991
|
+
this[p] = true;
|
|
11992
|
+
} else {
|
|
11993
|
+
throw Error(cryptoUnavailable);
|
|
11994
|
+
}
|
|
11995
|
+
} else {
|
|
11996
|
+
this[p] = false;
|
|
11997
|
+
}
|
|
11998
|
+
} else {
|
|
11999
|
+
throw Error(invalidArgument + p + ": " + v);
|
|
12000
|
+
}
|
|
12001
|
+
}
|
|
12002
|
+
return this;
|
|
12003
|
+
}
|
|
12004
|
+
function cos(x) {
|
|
12005
|
+
return new this(x).cos();
|
|
12006
|
+
}
|
|
12007
|
+
function cosh(x) {
|
|
12008
|
+
return new this(x).cosh();
|
|
12009
|
+
}
|
|
12010
|
+
function clone(obj) {
|
|
12011
|
+
var i, p, ps;
|
|
12012
|
+
function Decimal(v) {
|
|
12013
|
+
var e, i2, t, x = this;
|
|
12014
|
+
if (!(x instanceof Decimal))
|
|
12015
|
+
return new Decimal(v);
|
|
12016
|
+
x.constructor = Decimal;
|
|
12017
|
+
if (isDecimalInstance(v)) {
|
|
12018
|
+
x.s = v.s;
|
|
12019
|
+
if (external2) {
|
|
12020
|
+
if (!v.d || v.e > Decimal.maxE) {
|
|
12021
|
+
x.e = NaN;
|
|
12022
|
+
x.d = null;
|
|
12023
|
+
} else if (v.e < Decimal.minE) {
|
|
12024
|
+
x.e = 0;
|
|
12025
|
+
x.d = [0];
|
|
12026
|
+
} else {
|
|
12027
|
+
x.e = v.e;
|
|
12028
|
+
x.d = v.d.slice();
|
|
12029
|
+
}
|
|
12030
|
+
} else {
|
|
12031
|
+
x.e = v.e;
|
|
12032
|
+
x.d = v.d ? v.d.slice() : v.d;
|
|
12033
|
+
}
|
|
12034
|
+
return;
|
|
12035
|
+
}
|
|
12036
|
+
t = typeof v;
|
|
12037
|
+
if (t === "number") {
|
|
12038
|
+
if (v === 0) {
|
|
12039
|
+
x.s = 1 / v < 0 ? -1 : 1;
|
|
12040
|
+
x.e = 0;
|
|
12041
|
+
x.d = [0];
|
|
12042
|
+
return;
|
|
12043
|
+
}
|
|
12044
|
+
if (v < 0) {
|
|
12045
|
+
v = -v;
|
|
12046
|
+
x.s = -1;
|
|
12047
|
+
} else {
|
|
12048
|
+
x.s = 1;
|
|
12049
|
+
}
|
|
12050
|
+
if (v === ~~v && v < 1e7) {
|
|
12051
|
+
for (e = 0, i2 = v;i2 >= 10; i2 /= 10)
|
|
12052
|
+
e++;
|
|
12053
|
+
if (external2) {
|
|
12054
|
+
if (e > Decimal.maxE) {
|
|
12055
|
+
x.e = NaN;
|
|
12056
|
+
x.d = null;
|
|
12057
|
+
} else if (e < Decimal.minE) {
|
|
12058
|
+
x.e = 0;
|
|
12059
|
+
x.d = [0];
|
|
12060
|
+
} else {
|
|
12061
|
+
x.e = e;
|
|
12062
|
+
x.d = [v];
|
|
12063
|
+
}
|
|
12064
|
+
} else {
|
|
12065
|
+
x.e = e;
|
|
12066
|
+
x.d = [v];
|
|
12067
|
+
}
|
|
12068
|
+
return;
|
|
12069
|
+
}
|
|
12070
|
+
if (v * 0 !== 0) {
|
|
12071
|
+
if (!v)
|
|
12072
|
+
x.s = NaN;
|
|
12073
|
+
x.e = NaN;
|
|
12074
|
+
x.d = null;
|
|
12075
|
+
return;
|
|
12076
|
+
}
|
|
12077
|
+
return parseDecimal(x, v.toString());
|
|
12078
|
+
}
|
|
12079
|
+
if (t === "string") {
|
|
12080
|
+
if ((i2 = v.charCodeAt(0)) === 45) {
|
|
12081
|
+
v = v.slice(1);
|
|
12082
|
+
x.s = -1;
|
|
12083
|
+
} else {
|
|
12084
|
+
if (i2 === 43)
|
|
12085
|
+
v = v.slice(1);
|
|
12086
|
+
x.s = 1;
|
|
12087
|
+
}
|
|
12088
|
+
return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
|
|
12089
|
+
}
|
|
12090
|
+
if (t === "bigint") {
|
|
12091
|
+
if (v < 0) {
|
|
12092
|
+
v = -v;
|
|
12093
|
+
x.s = -1;
|
|
12094
|
+
} else {
|
|
12095
|
+
x.s = 1;
|
|
12096
|
+
}
|
|
12097
|
+
return parseDecimal(x, v.toString());
|
|
12098
|
+
}
|
|
12099
|
+
throw Error(invalidArgument + v);
|
|
12100
|
+
}
|
|
12101
|
+
Decimal.prototype = P;
|
|
12102
|
+
Decimal.ROUND_UP = 0;
|
|
12103
|
+
Decimal.ROUND_DOWN = 1;
|
|
12104
|
+
Decimal.ROUND_CEIL = 2;
|
|
12105
|
+
Decimal.ROUND_FLOOR = 3;
|
|
12106
|
+
Decimal.ROUND_HALF_UP = 4;
|
|
12107
|
+
Decimal.ROUND_HALF_DOWN = 5;
|
|
12108
|
+
Decimal.ROUND_HALF_EVEN = 6;
|
|
12109
|
+
Decimal.ROUND_HALF_CEIL = 7;
|
|
12110
|
+
Decimal.ROUND_HALF_FLOOR = 8;
|
|
12111
|
+
Decimal.EUCLID = 9;
|
|
12112
|
+
Decimal.config = Decimal.set = config;
|
|
12113
|
+
Decimal.clone = clone;
|
|
12114
|
+
Decimal.isDecimal = isDecimalInstance;
|
|
12115
|
+
Decimal.abs = abs;
|
|
12116
|
+
Decimal.acos = acos;
|
|
12117
|
+
Decimal.acosh = acosh;
|
|
12118
|
+
Decimal.add = add;
|
|
12119
|
+
Decimal.asin = asin;
|
|
12120
|
+
Decimal.asinh = asinh;
|
|
12121
|
+
Decimal.atan = atan;
|
|
12122
|
+
Decimal.atanh = atanh;
|
|
12123
|
+
Decimal.atan2 = atan2;
|
|
12124
|
+
Decimal.cbrt = cbrt;
|
|
12125
|
+
Decimal.ceil = ceil;
|
|
12126
|
+
Decimal.clamp = clamp;
|
|
12127
|
+
Decimal.cos = cos;
|
|
12128
|
+
Decimal.cosh = cosh;
|
|
12129
|
+
Decimal.div = div;
|
|
12130
|
+
Decimal.exp = exp;
|
|
12131
|
+
Decimal.floor = floor;
|
|
12132
|
+
Decimal.hypot = hypot;
|
|
12133
|
+
Decimal.ln = ln;
|
|
12134
|
+
Decimal.log = log;
|
|
12135
|
+
Decimal.log10 = log10;
|
|
12136
|
+
Decimal.log2 = log2;
|
|
12137
|
+
Decimal.max = max;
|
|
12138
|
+
Decimal.min = min;
|
|
12139
|
+
Decimal.mod = mod;
|
|
12140
|
+
Decimal.mul = mul;
|
|
12141
|
+
Decimal.pow = pow;
|
|
12142
|
+
Decimal.random = random;
|
|
12143
|
+
Decimal.round = round;
|
|
12144
|
+
Decimal.sign = sign;
|
|
12145
|
+
Decimal.sin = sin;
|
|
12146
|
+
Decimal.sinh = sinh;
|
|
12147
|
+
Decimal.sqrt = sqrt;
|
|
12148
|
+
Decimal.sub = sub;
|
|
12149
|
+
Decimal.sum = sum;
|
|
12150
|
+
Decimal.tan = tan;
|
|
12151
|
+
Decimal.tanh = tanh;
|
|
12152
|
+
Decimal.trunc = trunc;
|
|
12153
|
+
if (obj === undefined)
|
|
12154
|
+
obj = {};
|
|
12155
|
+
if (obj) {
|
|
12156
|
+
if (obj.defaults !== true) {
|
|
12157
|
+
ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
|
|
12158
|
+
for (i = 0;i < ps.length; )
|
|
12159
|
+
if (!obj.hasOwnProperty(p = ps[i++]))
|
|
12160
|
+
obj[p] = this[p];
|
|
12161
|
+
}
|
|
12162
|
+
}
|
|
12163
|
+
Decimal.config(obj);
|
|
12164
|
+
return Decimal;
|
|
12165
|
+
}
|
|
12166
|
+
function div(x, y) {
|
|
12167
|
+
return new this(x).div(y);
|
|
12168
|
+
}
|
|
12169
|
+
function exp(x) {
|
|
12170
|
+
return new this(x).exp();
|
|
12171
|
+
}
|
|
12172
|
+
function floor(x) {
|
|
12173
|
+
return finalise(x = new this(x), x.e + 1, 3);
|
|
12174
|
+
}
|
|
12175
|
+
function hypot() {
|
|
12176
|
+
var i, n, t = new this(0);
|
|
12177
|
+
external2 = false;
|
|
12178
|
+
for (i = 0;i < arguments.length; ) {
|
|
12179
|
+
n = new this(arguments[i++]);
|
|
12180
|
+
if (!n.d) {
|
|
12181
|
+
if (n.s) {
|
|
12182
|
+
external2 = true;
|
|
12183
|
+
return new this(1 / 0);
|
|
12184
|
+
}
|
|
12185
|
+
t = n;
|
|
12186
|
+
} else if (t.d) {
|
|
12187
|
+
t = t.plus(n.times(n));
|
|
12188
|
+
}
|
|
12189
|
+
}
|
|
12190
|
+
external2 = true;
|
|
12191
|
+
return t.sqrt();
|
|
12192
|
+
}
|
|
12193
|
+
function isDecimalInstance(obj) {
|
|
12194
|
+
return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
|
|
12195
|
+
}
|
|
12196
|
+
function ln(x) {
|
|
12197
|
+
return new this(x).ln();
|
|
12198
|
+
}
|
|
12199
|
+
function log(x, y) {
|
|
12200
|
+
return new this(x).log(y);
|
|
12201
|
+
}
|
|
12202
|
+
function log2(x) {
|
|
12203
|
+
return new this(x).log(2);
|
|
12204
|
+
}
|
|
12205
|
+
function log10(x) {
|
|
12206
|
+
return new this(x).log(10);
|
|
12207
|
+
}
|
|
12208
|
+
function max() {
|
|
12209
|
+
return maxOrMin(this, arguments, -1);
|
|
12210
|
+
}
|
|
12211
|
+
function min() {
|
|
12212
|
+
return maxOrMin(this, arguments, 1);
|
|
12213
|
+
}
|
|
12214
|
+
function mod(x, y) {
|
|
12215
|
+
return new this(x).mod(y);
|
|
12216
|
+
}
|
|
12217
|
+
function mul(x, y) {
|
|
12218
|
+
return new this(x).mul(y);
|
|
12219
|
+
}
|
|
12220
|
+
function pow(x, y) {
|
|
12221
|
+
return new this(x).pow(y);
|
|
12222
|
+
}
|
|
12223
|
+
function random(sd) {
|
|
12224
|
+
var d, e, k, n, i = 0, r = new this(1), rd = [];
|
|
12225
|
+
if (sd === undefined)
|
|
12226
|
+
sd = this.precision;
|
|
12227
|
+
else
|
|
12228
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
12229
|
+
k = Math.ceil(sd / LOG_BASE);
|
|
12230
|
+
if (!this.crypto) {
|
|
12231
|
+
for (;i < k; )
|
|
12232
|
+
rd[i++] = Math.random() * 1e7 | 0;
|
|
12233
|
+
} else if (crypto.getRandomValues) {
|
|
12234
|
+
d = crypto.getRandomValues(new Uint32Array(k));
|
|
12235
|
+
for (;i < k; ) {
|
|
12236
|
+
n = d[i];
|
|
12237
|
+
if (n >= 4290000000) {
|
|
12238
|
+
d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
12239
|
+
} else {
|
|
12240
|
+
rd[i++] = n % 1e7;
|
|
12241
|
+
}
|
|
12242
|
+
}
|
|
12243
|
+
} else if (crypto.randomBytes) {
|
|
12244
|
+
d = crypto.randomBytes(k *= 4);
|
|
12245
|
+
for (;i < k; ) {
|
|
12246
|
+
n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
|
|
12247
|
+
if (n >= 2140000000) {
|
|
12248
|
+
crypto.randomBytes(4).copy(d, i);
|
|
12249
|
+
} else {
|
|
12250
|
+
rd.push(n % 1e7);
|
|
12251
|
+
i += 4;
|
|
12252
|
+
}
|
|
12253
|
+
}
|
|
12254
|
+
i = k / 4;
|
|
12255
|
+
} else {
|
|
12256
|
+
throw Error(cryptoUnavailable);
|
|
12257
|
+
}
|
|
12258
|
+
k = rd[--i];
|
|
12259
|
+
sd %= LOG_BASE;
|
|
12260
|
+
if (k && sd) {
|
|
12261
|
+
n = mathpow(10, LOG_BASE - sd);
|
|
12262
|
+
rd[i] = (k / n | 0) * n;
|
|
12263
|
+
}
|
|
12264
|
+
for (;rd[i] === 0; i--)
|
|
12265
|
+
rd.pop();
|
|
12266
|
+
if (i < 0) {
|
|
12267
|
+
e = 0;
|
|
12268
|
+
rd = [0];
|
|
12269
|
+
} else {
|
|
12270
|
+
e = -1;
|
|
12271
|
+
for (;rd[0] === 0; e -= LOG_BASE)
|
|
12272
|
+
rd.shift();
|
|
12273
|
+
for (k = 1, n = rd[0];n >= 10; n /= 10)
|
|
12274
|
+
k++;
|
|
12275
|
+
if (k < LOG_BASE)
|
|
12276
|
+
e -= LOG_BASE - k;
|
|
12277
|
+
}
|
|
12278
|
+
r.e = e;
|
|
12279
|
+
r.d = rd;
|
|
12280
|
+
return r;
|
|
12281
|
+
}
|
|
12282
|
+
function round(x) {
|
|
12283
|
+
return finalise(x = new this(x), x.e + 1, this.rounding);
|
|
12284
|
+
}
|
|
12285
|
+
function sign(x) {
|
|
12286
|
+
x = new this(x);
|
|
12287
|
+
return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
|
|
12288
|
+
}
|
|
12289
|
+
function sin(x) {
|
|
12290
|
+
return new this(x).sin();
|
|
12291
|
+
}
|
|
12292
|
+
function sinh(x) {
|
|
12293
|
+
return new this(x).sinh();
|
|
12294
|
+
}
|
|
12295
|
+
function sqrt(x) {
|
|
12296
|
+
return new this(x).sqrt();
|
|
12297
|
+
}
|
|
12298
|
+
function sub(x, y) {
|
|
12299
|
+
return new this(x).sub(y);
|
|
12300
|
+
}
|
|
12301
|
+
function sum() {
|
|
12302
|
+
var i = 0, args = arguments, x = new this(args[i]);
|
|
12303
|
+
external2 = false;
|
|
12304
|
+
for (;x.s && ++i < args.length; )
|
|
12305
|
+
x = x.plus(args[i]);
|
|
12306
|
+
external2 = true;
|
|
12307
|
+
return finalise(x, this.precision, this.rounding);
|
|
12308
|
+
}
|
|
12309
|
+
function tan(x) {
|
|
12310
|
+
return new this(x).tan();
|
|
12311
|
+
}
|
|
12312
|
+
function tanh(x) {
|
|
12313
|
+
return new this(x).tanh();
|
|
12314
|
+
}
|
|
12315
|
+
function trunc(x) {
|
|
12316
|
+
return finalise(x = new this(x), x.e + 1, 1);
|
|
12317
|
+
}
|
|
12318
|
+
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
12319
|
+
P[Symbol.toStringTag] = "Decimal";
|
|
12320
|
+
var Decimal = P.constructor = clone(DEFAULTS);
|
|
12321
|
+
LN10 = new Decimal(LN10);
|
|
12322
|
+
PI = new Decimal(PI);
|
|
12323
|
+
var decimal_default = Decimal;
|
|
12324
|
+
|
|
12325
|
+
// src/common/base/other.ts
|
|
12326
|
+
var delay = (time = 1000) => {
|
|
12327
|
+
return new Promise((resolve) => setTimeout(resolve, time));
|
|
12328
|
+
};
|
|
12329
|
+
var calcJsText = (expr, context) => {
|
|
12330
|
+
const keys = Object.keys(context);
|
|
12331
|
+
const values = keys.map((key2) => context[key2]);
|
|
12332
|
+
return Function(...keys, `return (${expr})`)(...values);
|
|
12333
|
+
};
|
|
12334
|
+
var optionsToEnum = (options, text, key2) => {
|
|
12335
|
+
return options.reduce((acc, cur) => {
|
|
12336
|
+
acc[cur[key2]] = {
|
|
12337
|
+
text: cur[text]
|
|
12338
|
+
};
|
|
12339
|
+
return acc;
|
|
12340
|
+
}, {});
|
|
12341
|
+
};
|
|
12342
|
+
var performDecimalOperation = (num1, num2, operator) => {
|
|
12343
|
+
if (num1 === undefined || num2 === undefined || !operator) {
|
|
12344
|
+
return;
|
|
12345
|
+
}
|
|
12346
|
+
const decimalNum1 = new decimal_default(Number(num1));
|
|
12347
|
+
const decimalNum2 = new decimal_default(Number(num2));
|
|
12348
|
+
switch (operator) {
|
|
12349
|
+
case "+":
|
|
12350
|
+
return decimalNum1.plus(decimalNum2).toNumber();
|
|
12351
|
+
case "-":
|
|
12352
|
+
return decimalNum1.minus(decimalNum2).toNumber();
|
|
12353
|
+
case "*":
|
|
12354
|
+
return decimalNum1.times(decimalNum2).toNumber();
|
|
12355
|
+
case "/":
|
|
12356
|
+
if (num2 !== 0) {
|
|
12357
|
+
return decimalNum1.dividedBy(decimalNum2).toNumber();
|
|
12358
|
+
} else {
|
|
12359
|
+
console.error("Division by zero is not allowed.");
|
|
12360
|
+
return NaN;
|
|
12361
|
+
}
|
|
12362
|
+
default:
|
|
12363
|
+
console.error("Invalid operator:", operator);
|
|
12364
|
+
return NaN;
|
|
12365
|
+
}
|
|
12366
|
+
};
|
|
12367
|
+
var printConsoleLog = (type, path2, params, response) => {
|
|
12368
|
+
const styles = {
|
|
12369
|
+
header: "color: #fff; background: #35495e; padding: 2px 8px; border-radius: 3px 0 0 3px;",
|
|
12370
|
+
value: "color: #35495e; background: #f0f4f8; padding: 2px 6px; border-radius: 0 3px 3px 0;",
|
|
12371
|
+
separator: "color: #409EFF; margin: 0 4px;"
|
|
12372
|
+
};
|
|
12373
|
+
console.groupCollapsed(`666 %c${type}%c${path2}`, styles.header, styles.value);
|
|
12374
|
+
if (params) {
|
|
12375
|
+
console.table(params);
|
|
12376
|
+
}
|
|
12377
|
+
if (response) {
|
|
12378
|
+
console.table(response);
|
|
12379
|
+
}
|
|
12380
|
+
console.groupEnd();
|
|
12381
|
+
};
|
|
12382
|
+
|
|
12383
|
+
// src/common/base/array.ts
|
|
12384
|
+
var shuffleArray = (array) => {
|
|
12385
|
+
const shuffledArray = [...array];
|
|
12386
|
+
for (let i = shuffledArray.length - 1;i > 0; i--) {
|
|
12387
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
12388
|
+
[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
|
|
12389
|
+
}
|
|
12390
|
+
return shuffledArray;
|
|
12391
|
+
};
|
|
12392
|
+
var removeSimilarDuplicates = (arr, threshold, isLog) => {
|
|
12393
|
+
const uniqueArray = [];
|
|
12394
|
+
const similarPairs = [];
|
|
12395
|
+
for (const str of arr) {
|
|
12396
|
+
const isSimilar = uniqueArray.some((uniqueStr) => {
|
|
12397
|
+
const distance = levenshteinDistance(str, uniqueStr);
|
|
12398
|
+
if (distance <= threshold) {
|
|
12399
|
+
similarPairs.push([str, uniqueStr]);
|
|
12400
|
+
return true;
|
|
12401
|
+
}
|
|
12402
|
+
return false;
|
|
9833
12403
|
});
|
|
9834
|
-
|
|
9835
|
-
|
|
12404
|
+
if (!isSimilar) {
|
|
12405
|
+
uniqueArray.push(str);
|
|
12406
|
+
}
|
|
12407
|
+
}
|
|
12408
|
+
if (isLog) {
|
|
12409
|
+
if (similarPairs.length > 0) {
|
|
12410
|
+
similarPairs.forEach((pair) => {
|
|
12411
|
+
console.log(pair[0]);
|
|
12412
|
+
console.log(pair[1]);
|
|
12413
|
+
console.log();
|
|
12414
|
+
});
|
|
12415
|
+
} else {
|
|
12416
|
+
console.log("没有找到类似的字符串");
|
|
12417
|
+
}
|
|
12418
|
+
}
|
|
12419
|
+
return uniqueArray;
|
|
12420
|
+
};
|
|
12421
|
+
var getTotal = (arr, key2) => {
|
|
12422
|
+
if (!Array.isArray(arr) || !key2) {
|
|
12423
|
+
return 0;
|
|
12424
|
+
}
|
|
12425
|
+
return arr.reduce((total, item) => {
|
|
12426
|
+
const itemValue = Number(item[key2]);
|
|
12427
|
+
if (!isNaN(itemValue)) {
|
|
12428
|
+
return performDecimalOperation(total, itemValue, "+");
|
|
12429
|
+
}
|
|
12430
|
+
return total;
|
|
12431
|
+
}, 0);
|
|
12432
|
+
};
|
|
12433
|
+
|
|
12434
|
+
// src/common/base/number.ts
|
|
12435
|
+
var getRandomNum = (min2, max2) => {
|
|
12436
|
+
return Math.floor(Math.random() * (max2 - min2 + 1) + min2);
|
|
12437
|
+
};
|
|
12438
|
+
var limitDecimals = (v, num = 2, isForce) => {
|
|
12439
|
+
let value = parseFloat(v);
|
|
12440
|
+
if (isNaN(value)) {
|
|
12441
|
+
if (isForce) {
|
|
12442
|
+
value = 0;
|
|
12443
|
+
} else {
|
|
12444
|
+
return "";
|
|
12445
|
+
}
|
|
12446
|
+
}
|
|
12447
|
+
return value.toFixed(num).toString();
|
|
12448
|
+
};
|
|
12449
|
+
var getFileSize = (size) => {
|
|
12450
|
+
let d = "G";
|
|
12451
|
+
let s = size / 1024 / 1024 / 1024;
|
|
12452
|
+
if (s < 1) {
|
|
12453
|
+
d = "M";
|
|
12454
|
+
s *= 1024;
|
|
12455
|
+
}
|
|
12456
|
+
return `${(s.toFixed(1) / 1).toString()}${d}`;
|
|
12457
|
+
};
|
|
12458
|
+
var isValidNumber = (value) => {
|
|
12459
|
+
if (typeof value !== "number") {
|
|
12460
|
+
return false;
|
|
12461
|
+
}
|
|
12462
|
+
if (isNaN(value)) {
|
|
12463
|
+
return false;
|
|
12464
|
+
}
|
|
12465
|
+
if (value === Infinity || value === -Infinity) {
|
|
12466
|
+
return false;
|
|
12467
|
+
}
|
|
12468
|
+
return true;
|
|
12469
|
+
};
|
|
12470
|
+
var numberWithCommas = (x) => {
|
|
12471
|
+
if (x === undefined || x === null) {
|
|
12472
|
+
return "";
|
|
12473
|
+
}
|
|
12474
|
+
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
12475
|
+
};
|
|
12476
|
+
|
|
12477
|
+
// src/common/base/object.ts
|
|
12478
|
+
var findItem = (list, attr, value) => {
|
|
12479
|
+
return list.find((item) => value === undefined ? item[attr] : item[attr] === value);
|
|
12480
|
+
};
|
|
12481
|
+
var filterParams = (params, deep = false) => {
|
|
12482
|
+
const clean = (value) => {
|
|
12483
|
+
if (value === undefined || value === null) {
|
|
12484
|
+
return;
|
|
12485
|
+
}
|
|
12486
|
+
if (!deep) {
|
|
12487
|
+
return value;
|
|
12488
|
+
}
|
|
12489
|
+
if (Array.isArray(value)) {
|
|
12490
|
+
return value.map((v) => clean(v)).filter((v) => v !== undefined);
|
|
12491
|
+
}
|
|
12492
|
+
if (typeof value === "object") {
|
|
12493
|
+
return Object.entries(value).reduce((acc, [k, v]) => {
|
|
12494
|
+
const cleaned = clean(v);
|
|
12495
|
+
if (cleaned !== undefined)
|
|
12496
|
+
acc[k] = cleaned;
|
|
12497
|
+
return acc;
|
|
12498
|
+
}, {});
|
|
12499
|
+
}
|
|
12500
|
+
return value;
|
|
12501
|
+
};
|
|
12502
|
+
return clean(params);
|
|
12503
|
+
};
|
|
12504
|
+
var watch = {
|
|
12505
|
+
observe(obj, key2, watchFun) {
|
|
12506
|
+
const val = obj[key2];
|
|
12507
|
+
Object.defineProperty(obj, key2, {
|
|
12508
|
+
configurable: true,
|
|
12509
|
+
enumerable: true,
|
|
12510
|
+
set(value) {
|
|
12511
|
+
obj[key2] = value;
|
|
12512
|
+
watchFun(value, val);
|
|
12513
|
+
},
|
|
12514
|
+
get() {
|
|
12515
|
+
return val;
|
|
12516
|
+
}
|
|
12517
|
+
});
|
|
12518
|
+
},
|
|
12519
|
+
setWatcher(data = {}, watch2 = {}) {
|
|
12520
|
+
Object.keys(watch2).forEach((v) => {
|
|
12521
|
+
this.observe(data, v, watch2[v]);
|
|
12522
|
+
});
|
|
12523
|
+
}
|
|
12524
|
+
};
|
|
12525
|
+
|
|
12526
|
+
// src/common/base/promise.ts
|
|
12527
|
+
var executePromise = async (promise) => {
|
|
12528
|
+
const start = Date.now();
|
|
12529
|
+
const result = await promise;
|
|
12530
|
+
const time = Date.now() - start;
|
|
12531
|
+
return {
|
|
12532
|
+
result,
|
|
12533
|
+
time
|
|
12534
|
+
};
|
|
12535
|
+
};
|
|
12536
|
+
var retryPromise = async (promiseFn, retryInterval = 1000, retryCount = 3) => {
|
|
12537
|
+
try {
|
|
12538
|
+
return await promiseFn();
|
|
9836
12539
|
} catch (error) {
|
|
9837
|
-
|
|
9838
|
-
|
|
12540
|
+
if (retryCount <= 0) {
|
|
12541
|
+
throw error;
|
|
12542
|
+
}
|
|
12543
|
+
await new Promise((resolve) => setTimeout(resolve, retryInterval));
|
|
12544
|
+
return retryPromise(promiseFn, retryCount - 1, retryInterval);
|
|
9839
12545
|
}
|
|
9840
|
-
}
|
|
9841
|
-
// src/common/enum.ts
|
|
12546
|
+
};
|
|
12547
|
+
// src/common/enum/index.ts
|
|
9842
12548
|
class EnumItem {
|
|
9843
12549
|
label;
|
|
9844
12550
|
value;
|
|
9845
12551
|
extra;
|
|
9846
|
-
constructor(
|
|
9847
|
-
this.value =
|
|
9848
|
-
this.label =
|
|
9849
|
-
this.extra =
|
|
12552
|
+
constructor(config2) {
|
|
12553
|
+
this.value = config2.value;
|
|
12554
|
+
this.label = config2.label;
|
|
12555
|
+
this.extra = config2.extra;
|
|
9850
12556
|
}
|
|
9851
12557
|
}
|
|
9852
12558
|
var Enum = {
|
|
@@ -9885,7 +12591,21 @@ var Enum = {
|
|
|
9885
12591
|
return enumObj;
|
|
9886
12592
|
}
|
|
9887
12593
|
};
|
|
9888
|
-
// src/common/
|
|
12594
|
+
// src/common/image/index.ts
|
|
12595
|
+
var import_axios6 = __toESM(require("axios"));
|
|
12596
|
+
async function imageToBase64(url2) {
|
|
12597
|
+
try {
|
|
12598
|
+
const response = await import_axios6.default.get(url2, {
|
|
12599
|
+
responseType: "arraybuffer"
|
|
12600
|
+
});
|
|
12601
|
+
const base64String = Buffer.from(response.data).toString("base64");
|
|
12602
|
+
return `data:image/*;base64,${base64String}`;
|
|
12603
|
+
} catch (error) {
|
|
12604
|
+
console.error("Failed to fetch the image:", error);
|
|
12605
|
+
throw error;
|
|
12606
|
+
}
|
|
12607
|
+
}
|
|
12608
|
+
// src/common/dayjs/index.ts
|
|
9889
12609
|
var import_dayjs = __toESM(require("dayjs"));
|
|
9890
12610
|
var import_isBetween = __toESM(require("dayjs/plugin/isBetween"));
|
|
9891
12611
|
var import_weekday = __toESM(require("dayjs/plugin/weekday"));
|
|
@@ -9943,10 +12663,10 @@ var transporter = import_nodemailer.default.createTransport({
|
|
|
9943
12663
|
secure: true,
|
|
9944
12664
|
auth: authMap.gmail
|
|
9945
12665
|
});
|
|
9946
|
-
var sendMail = (
|
|
12666
|
+
var sendMail = (config2) => {
|
|
9947
12667
|
return transporter.sendMail({
|
|
9948
12668
|
from: authMap.gmail.user,
|
|
9949
|
-
...
|
|
12669
|
+
...config2
|
|
9950
12670
|
});
|
|
9951
12671
|
};
|
|
9952
12672
|
// src/node/file.ts
|