@andrew_l/toolkit 0.2.20 → 0.3.0
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/index.cjs +683 -616
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -7
- package/dist/index.d.mts +25 -7
- package/dist/index.d.ts +25 -7
- package/dist/index.mjs +682 -617
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -781,12 +781,42 @@ function uniqBy(array, comparator) {
|
|
|
781
781
|
});
|
|
782
782
|
}
|
|
783
783
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
784
|
+
class BrowserAssertionError extends Error {
|
|
785
|
+
/**
|
|
786
|
+
* Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
|
|
787
|
+
*/
|
|
788
|
+
actual;
|
|
789
|
+
/**
|
|
790
|
+
* Set to the `expected` argument for methods such as {@link assert.strictEqual()}.
|
|
791
|
+
*/
|
|
792
|
+
expected;
|
|
793
|
+
/**
|
|
794
|
+
* Set to the passed in operator value.
|
|
795
|
+
*/
|
|
796
|
+
operator;
|
|
797
|
+
/**
|
|
798
|
+
* Indicates if the message was auto-generated (`true`) or not.
|
|
799
|
+
*/
|
|
800
|
+
generatedMessage;
|
|
801
|
+
/**
|
|
802
|
+
* Value is always `ERR_ASSERTION` to show that the error is an assertion error.
|
|
803
|
+
*/
|
|
804
|
+
code;
|
|
805
|
+
constructor(options) {
|
|
806
|
+
super(options?.message);
|
|
807
|
+
this.actual = options?.actual;
|
|
808
|
+
this.expected = options?.expected;
|
|
809
|
+
this.operator = options?.operator ?? "none";
|
|
810
|
+
this.generatedMessage = false;
|
|
811
|
+
this.code = "ERR_ASSERTION";
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
let AssertionError = BrowserAssertionError;
|
|
816
|
+
if (!globalThis.window) {
|
|
817
|
+
import('node:assert').then((r) => AssertionError = r.AssertionError).catch(() => {
|
|
818
|
+
});
|
|
819
|
+
}
|
|
790
820
|
|
|
791
821
|
function ok(value, message) {
|
|
792
822
|
if (!value) {
|
|
@@ -1026,13 +1056,360 @@ function basex(alphabet) {
|
|
|
1026
1056
|
}
|
|
1027
1057
|
}
|
|
1028
1058
|
|
|
1029
|
-
const base62 = basex(
|
|
1030
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
1031
|
-
);
|
|
1059
|
+
const base62 = basex(
|
|
1060
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
1061
|
+
);
|
|
1062
|
+
|
|
1063
|
+
function capitalize(str) {
|
|
1064
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
|
|
1068
|
+
function getWords(str) {
|
|
1069
|
+
if (!isString(str)) return [];
|
|
1070
|
+
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function camelCase(str) {
|
|
1074
|
+
const words = getWords(str);
|
|
1075
|
+
if (words.length === 0) {
|
|
1076
|
+
return "";
|
|
1077
|
+
}
|
|
1078
|
+
const [first, ...rest] = words;
|
|
1079
|
+
return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join("")}`;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
function convertToUnit(str, unit = "px") {
|
|
1083
|
+
if (str == null || str === "") {
|
|
1084
|
+
return void 0;
|
|
1085
|
+
} else if (isNaN(+str)) {
|
|
1086
|
+
return String(str);
|
|
1087
|
+
} else {
|
|
1088
|
+
return `${Number(str)}${unit}`;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
const htmlEscapes = Object.freeze({
|
|
1093
|
+
38: "&",
|
|
1094
|
+
// &
|
|
1095
|
+
60: "<",
|
|
1096
|
+
// <
|
|
1097
|
+
62: ">",
|
|
1098
|
+
// >
|
|
1099
|
+
34: """,
|
|
1100
|
+
// "
|
|
1101
|
+
39: "'"
|
|
1102
|
+
// '
|
|
1103
|
+
});
|
|
1104
|
+
function escapeHtml(unsafe) {
|
|
1105
|
+
if (typeof unsafe !== "string") {
|
|
1106
|
+
return "";
|
|
1107
|
+
}
|
|
1108
|
+
let result = "";
|
|
1109
|
+
let strLen = unsafe.length;
|
|
1110
|
+
let char;
|
|
1111
|
+
for (let idx = 0; idx < strLen; idx++) {
|
|
1112
|
+
char = unsafe.charCodeAt(idx);
|
|
1113
|
+
result += htmlEscapes[char] || String.fromCharCode(char);
|
|
1114
|
+
}
|
|
1115
|
+
return result;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
function escapeNumeric(str) {
|
|
1119
|
+
const result = String(str).replace(/\D/g, "");
|
|
1120
|
+
if (!result.length) {
|
|
1121
|
+
return void 0;
|
|
1122
|
+
}
|
|
1123
|
+
return result;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
function escapeRegExp(str) {
|
|
1127
|
+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
const vs16RegExp = /\uFE0F/g;
|
|
1131
|
+
const zeroWidthJoiner = String.fromCharCode(8205);
|
|
1132
|
+
function removeVS16s(rawEmoji) {
|
|
1133
|
+
return rawEmoji.indexOf(zeroWidthJoiner) < 0 ? rawEmoji.replace(vs16RegExp, "") : rawEmoji;
|
|
1134
|
+
}
|
|
1135
|
+
const TWEMOJI_REGEX = /(?:\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83e\udef1\ud83c\udffb\u200d\ud83e\udef2\ud83c[\udffc-\udfff]|\ud83e\udef1\ud83c\udffc\u200d\ud83e\udef2\ud83c[\udffb\udffd-\udfff]|\ud83e\udef1\ud83c\udffd\u200d\ud83e\udef2\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\udef1\ud83c\udffe\u200d\ud83e\udef2\ud83c[\udffb-\udffd\udfff]|\ud83e\udef1\ud83c\udfff\u200d\ud83e\udef2\ud83c[\udffb-\udffe]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d\udc8f\ud83c[\udffb-\udfff]|\ud83d\udc91\ud83c[\udffb-\udfff]|\ud83e\udd1d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d\udc8f\udc91]|\ud83e\udd1d)|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf7c\udf84\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc70\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd4\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83d\ude36\u200d\ud83c\udf2b\ufe0f|\u2764\ufe0f\u200d\ud83d\udd25|\u2764\ufe0f\u200d\ud83e\ude79|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc3b\u200d\u2744\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83d\ude2e\u200d\ud83d\udca8|\ud83d\ude35\u200d\ud83d\udcab|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f|\ud83d\udc08\u200d\u2b1b)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0c\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\udd77\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd\udec3-\udec5\udef0-\udef6]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udc8e\udc90\udc92-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5-\uded7\udedd-\udedf\udeeb\udeec\udef4-\udefc\udfe0-\udfeb\udff0]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd76\udd78-\uddb4\uddb7\uddba\uddbc-\uddcc\uddd0\uddde-\uddff\ude70-\ude74\ude78-\ude7c\ude80-\ude86\ude90-\udeac\udeb0-\udeba\udec0-\udec2\uded0-\uded9\udee0-\udee7]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g;
|
|
1136
|
+
|
|
1137
|
+
function isOneEmoji(text) {
|
|
1138
|
+
return !!(typeof text === "string" && text && (text.match(TWEMOJI_REGEX) || [])[0]?.length === text.length);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
const IGNORED_TITLES = Object.freeze(
|
|
1142
|
+
/* @__PURE__ */ new Set([
|
|
1143
|
+
"dr.",
|
|
1144
|
+
"mr.",
|
|
1145
|
+
"mrs.",
|
|
1146
|
+
"miss",
|
|
1147
|
+
"ms.",
|
|
1148
|
+
"prof.",
|
|
1149
|
+
"sir",
|
|
1150
|
+
"rev.",
|
|
1151
|
+
"hon."
|
|
1152
|
+
])
|
|
1153
|
+
);
|
|
1154
|
+
function getInitials(fullName) {
|
|
1155
|
+
if (!isString(fullName)) return "";
|
|
1156
|
+
let [first, ...rest] = fullName.replace(/\s{2,}/g, " ").replace(/[,+/#!$@%^&*;:{}=\-_`~()]/g, "").trim().split(" ").filter((word) => !IGNORED_TITLES.has(word.toLowerCase())).map((v) => v.replaceAll(".", "").trim()).filter(Boolean);
|
|
1157
|
+
let last = rest[rest.length - 1];
|
|
1158
|
+
if (rest.length > 1) {
|
|
1159
|
+
if (isOneEmoji(first)) {
|
|
1160
|
+
first = rest[0];
|
|
1161
|
+
} else if (isOneEmoji(last)) {
|
|
1162
|
+
last = rest[0];
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return [first, last].filter(Boolean).map((letter = "") => [...letter.toUpperCase()][0]).join("");
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
const DEF_PROTOCOLS = ["http://", "https://"];
|
|
1169
|
+
function hasProtocol(url, protocols = DEF_PROTOCOLS) {
|
|
1170
|
+
if (!isString(url)) return false;
|
|
1171
|
+
return protocols.some((v) => url.startsWith(v));
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
const byteToHex = [];
|
|
1175
|
+
for (let n = 0; n <= 255; ++n) {
|
|
1176
|
+
const hexOctet = n.toString(16).padStart(2, "0");
|
|
1177
|
+
byteToHex.push(hexOctet);
|
|
1178
|
+
}
|
|
1179
|
+
function hex(value) {
|
|
1180
|
+
const buff = Array.isArray(value) ? new Uint8Array(value) : value;
|
|
1181
|
+
const hexOctets = new Array(buff.length);
|
|
1182
|
+
for (let i = 0; i < buff.length; ++i) {
|
|
1183
|
+
hexOctets[i] = byteToHex[buff[i]];
|
|
1184
|
+
}
|
|
1185
|
+
return hexOctets.join("");
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
function isoToFlagEmoji(iso) {
|
|
1189
|
+
const code = iso.toUpperCase();
|
|
1190
|
+
if (!/^[A-Z]{2}$/.test(code)) return iso;
|
|
1191
|
+
const codePoints = [...code].map((c) => c.codePointAt(0) + 127397);
|
|
1192
|
+
return String.fromCodePoint(...codePoints);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
function kebabCase(str) {
|
|
1196
|
+
const words = getWords(str);
|
|
1197
|
+
return words.map((word) => word.toLowerCase()).join("-");
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
const lowerCase = (str) => {
|
|
1201
|
+
return getWords(str).map((word) => word.toLowerCase()).join(" ");
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
function maskingWords(value, withChar = "*") {
|
|
1205
|
+
return getWords(value).map((word) => {
|
|
1206
|
+
const len = word.length;
|
|
1207
|
+
if (len < 2) {
|
|
1208
|
+
return "".padEnd(len, withChar);
|
|
1209
|
+
} else if (len < 3) {
|
|
1210
|
+
return word[0].padEnd(len, withChar);
|
|
1211
|
+
} else {
|
|
1212
|
+
return word[0].padEnd(len - 2, withChar) + word.at(-1);
|
|
1213
|
+
}
|
|
1214
|
+
}).join(" ");
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
function maskingEmail(value) {
|
|
1218
|
+
if (!isString(value)) return "";
|
|
1219
|
+
const [username, host] = value.split("@", 2);
|
|
1220
|
+
if (!username || !host) return "";
|
|
1221
|
+
return `${maskingWords(username)}@${host}`;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
function maskingPhone(value, fromPosition = 2, toPosition = 4, withChar = "X") {
|
|
1225
|
+
if (!isString(value)) return "";
|
|
1226
|
+
const numbersAmount = value.replace(/\D/g, "").length;
|
|
1227
|
+
const fromIdx = fromPosition - 1;
|
|
1228
|
+
let toIdx = numbersAmount - toPosition;
|
|
1229
|
+
if (toIdx <= 0) {
|
|
1230
|
+
toIdx = numbersAmount;
|
|
1231
|
+
}
|
|
1232
|
+
let i = -1;
|
|
1233
|
+
return value.replace(/\d/g, (char) => {
|
|
1234
|
+
i++;
|
|
1235
|
+
return i > fromIdx && i < toIdx ? withChar : char;
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
function timestamp(fromValue = Date.now()) {
|
|
1240
|
+
if (isDate(fromValue)) {
|
|
1241
|
+
fromValue = fromValue.getTime();
|
|
1242
|
+
}
|
|
1243
|
+
return Math.floor(fromValue / 1e3);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
let index = Math.floor(Math.random() * 16777215);
|
|
1247
|
+
const buffer = new Uint8Array(12);
|
|
1248
|
+
function objectId(fromValue = Date.now()) {
|
|
1249
|
+
const value = timestamp(fromValue);
|
|
1250
|
+
const inc = getInc();
|
|
1251
|
+
buffer[0] = value >> 24;
|
|
1252
|
+
buffer[1] = value >> 16;
|
|
1253
|
+
buffer[2] = value >> 8;
|
|
1254
|
+
buffer[3] = value;
|
|
1255
|
+
buffer[4] = Math.floor(Math.random() * 256);
|
|
1256
|
+
buffer[5] = Math.floor(Math.random() * 256);
|
|
1257
|
+
buffer[6] = Math.floor(Math.random() * 256);
|
|
1258
|
+
buffer[7] = Math.floor(Math.random() * 256);
|
|
1259
|
+
buffer[8] = Math.floor(Math.random() * 256);
|
|
1260
|
+
buffer[11] = inc & 255;
|
|
1261
|
+
buffer[10] = inc >> 8 & 255;
|
|
1262
|
+
buffer[9] = inc >> 16 & 255;
|
|
1263
|
+
return hex(buffer);
|
|
1264
|
+
}
|
|
1265
|
+
function getInc() {
|
|
1266
|
+
return index = (index + 1) % 16777215;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
const rndCharacters = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
1270
|
+
const charactersLength = rndCharacters.length;
|
|
1271
|
+
function randomString(length) {
|
|
1272
|
+
let str = "";
|
|
1273
|
+
let num = isNumber(length) ? Math.max(0, length) : 0;
|
|
1274
|
+
while (num--) {
|
|
1275
|
+
str += rndCharacters[charactersLength * Math.random() | 0];
|
|
1276
|
+
}
|
|
1277
|
+
return str;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
const snakeCase = (str) => {
|
|
1281
|
+
return getWords(str).map((word) => word.toLowerCase()).join("_");
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
function sprintf(line, args, unusedArgs = []) {
|
|
1285
|
+
let result = "";
|
|
1286
|
+
const argsLen = args.length;
|
|
1287
|
+
const lineLen = line.length;
|
|
1288
|
+
let opened = false;
|
|
1289
|
+
let currentChar = -1;
|
|
1290
|
+
let lastPos = 0;
|
|
1291
|
+
let argsIndex = 0;
|
|
1292
|
+
for (let idx = 0; idx < lineLen; idx++) {
|
|
1293
|
+
currentChar = line.charCodeAt(idx);
|
|
1294
|
+
if (currentChar === 37) {
|
|
1295
|
+
opened = true;
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1298
|
+
if (!opened) continue;
|
|
1299
|
+
opened = false;
|
|
1300
|
+
switch (currentChar) {
|
|
1301
|
+
// 'd'
|
|
1302
|
+
case 100:
|
|
1303
|
+
// 'f'
|
|
1304
|
+
case 102: {
|
|
1305
|
+
result += line.slice(lastPos, idx - 1);
|
|
1306
|
+
result += Number(args[argsIndex]);
|
|
1307
|
+
lastPos = idx + 1;
|
|
1308
|
+
argsIndex++;
|
|
1309
|
+
break;
|
|
1310
|
+
}
|
|
1311
|
+
// 'i'
|
|
1312
|
+
case 105: {
|
|
1313
|
+
result += line.slice(lastPos, idx - 1);
|
|
1314
|
+
result += Math.floor(Number(args[argsIndex]));
|
|
1315
|
+
lastPos = idx + 1;
|
|
1316
|
+
argsIndex++;
|
|
1317
|
+
break;
|
|
1318
|
+
}
|
|
1319
|
+
// 'O'
|
|
1320
|
+
case 79:
|
|
1321
|
+
// 'o'
|
|
1322
|
+
case 111:
|
|
1323
|
+
// 'j'
|
|
1324
|
+
case 106: {
|
|
1325
|
+
result += line.slice(lastPos, idx - 1);
|
|
1326
|
+
result += tryStringify(args[argsIndex]);
|
|
1327
|
+
lastPos = idx + 1;
|
|
1328
|
+
argsIndex++;
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
// 's'
|
|
1332
|
+
case 115: {
|
|
1333
|
+
result += line.slice(lastPos, idx - 1);
|
|
1334
|
+
result += String(args[argsIndex]);
|
|
1335
|
+
lastPos = idx + 1;
|
|
1336
|
+
argsIndex++;
|
|
1337
|
+
break;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
if (argsIndex >= argsLen) break;
|
|
1341
|
+
}
|
|
1342
|
+
if (lastPos < lineLen) {
|
|
1343
|
+
result += line.slice(lastPos, lineLen);
|
|
1344
|
+
}
|
|
1345
|
+
if (argsIndex < argsLen) {
|
|
1346
|
+
unusedArgs.push(...args.slice(argsIndex, argsLen));
|
|
1347
|
+
}
|
|
1348
|
+
return result;
|
|
1349
|
+
}
|
|
1350
|
+
function tryStringify(o) {
|
|
1351
|
+
switch (typeof o) {
|
|
1352
|
+
case "function": {
|
|
1353
|
+
return o.name || "<anonymous>";
|
|
1354
|
+
}
|
|
1355
|
+
case "string": {
|
|
1356
|
+
return "'" + o + "'";
|
|
1357
|
+
}
|
|
1358
|
+
default: {
|
|
1359
|
+
try {
|
|
1360
|
+
return JSON.stringify(o);
|
|
1361
|
+
} catch (e) {
|
|
1362
|
+
return '"[Circular]"';
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
const startCase = (value) => {
|
|
1369
|
+
return getWords(value).map(capitalize).join(" ");
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
const DEF_STR_ASSIGN_REGEXP = /\{{([A-z-_. ]*)\}}/g;
|
|
1373
|
+
const DEF_STR_ASSIGN_METHOD = (obj, key) => obj[key];
|
|
1374
|
+
function strAssign(str, obj, method = DEF_STR_ASSIGN_METHOD) {
|
|
1375
|
+
return str.replace(DEF_STR_ASSIGN_REGEXP, (match, p1) => {
|
|
1376
|
+
const key = p1.trim();
|
|
1377
|
+
const value = method(obj, key);
|
|
1378
|
+
if (value === void 0 || value === null) {
|
|
1379
|
+
return match;
|
|
1380
|
+
}
|
|
1381
|
+
return value;
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
var textEncoder = new TextEncoder();
|
|
1386
|
+
var textDecoder = new TextDecoder();
|
|
1387
|
+
|
|
1388
|
+
function truncate(value, maxLength = 120, insignificantThreshold = 0.05) {
|
|
1389
|
+
if (!shouldTruncate(value, maxLength, insignificantThreshold)) {
|
|
1390
|
+
return value;
|
|
1391
|
+
}
|
|
1392
|
+
let truncated = value.slice(0, maxLength).trim();
|
|
1393
|
+
const lastSpace = truncated.lastIndexOf(" ");
|
|
1394
|
+
if (lastSpace > 0) {
|
|
1395
|
+
truncated = truncated.slice(0, lastSpace);
|
|
1396
|
+
}
|
|
1397
|
+
return `${truncated}...`;
|
|
1398
|
+
}
|
|
1399
|
+
function shouldTruncate(text, maxLength, insignificantThreshold) {
|
|
1400
|
+
return text.length - maxLength > maxLength * insignificantThreshold;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function wrapText(value, maxLength = 30) {
|
|
1404
|
+
if (value.length > maxLength) {
|
|
1405
|
+
return value.slice(0, maxLength) + "...";
|
|
1406
|
+
}
|
|
1407
|
+
return value;
|
|
1408
|
+
}
|
|
1032
1409
|
|
|
1033
1410
|
var ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
1034
1411
|
var ENCODE_TABLE = new TextEncoder().encode(ALPHABET);
|
|
1035
|
-
var DECODE_TABLE = new Uint8Array(
|
|
1412
|
+
var DECODE_TABLE = new Uint8Array(128);
|
|
1036
1413
|
for (let i = 0; i < ENCODE_TABLE.length; ++i) {
|
|
1037
1414
|
DECODE_TABLE[ENCODE_TABLE[i]] = i;
|
|
1038
1415
|
}
|
|
@@ -1041,49 +1418,52 @@ LOG2_TABLE[0] = 1;
|
|
|
1041
1418
|
for (let i = 1; i < 62; ++i) {
|
|
1042
1419
|
LOG2_TABLE[i] = Math.ceil(Math.log2(i + 1));
|
|
1043
1420
|
}
|
|
1044
|
-
|
|
1421
|
+
var allocEncode = createAllocator();
|
|
1045
1422
|
const base62Fast = {
|
|
1046
1423
|
alphabet: ALPHABET,
|
|
1047
1424
|
padding: "",
|
|
1048
1425
|
/**
|
|
1049
1426
|
* Encodes a Uint8Array into a Base62 string using a custom 5/6-bit variable length scheme.
|
|
1050
|
-
* Processes bits from
|
|
1427
|
+
* Processes bits from left to right maintaining correct order.
|
|
1051
1428
|
* @param input The Uint8Array to encode.
|
|
1052
1429
|
* @returns The encoded Base62 string.
|
|
1053
1430
|
*/
|
|
1054
1431
|
encode(input) {
|
|
1055
|
-
var
|
|
1056
|
-
var output = allocEncode((
|
|
1432
|
+
var totalBits = input.length * 8;
|
|
1433
|
+
var output = allocEncode((totalBits / 5 | 0) + 1);
|
|
1057
1434
|
var outputIndex = 0;
|
|
1435
|
+
var bitPosition = 0;
|
|
1436
|
+
var buffer = 0;
|
|
1437
|
+
var inputIndex = 0;
|
|
1058
1438
|
var chunkSize;
|
|
1059
|
-
var remainderBits;
|
|
1060
|
-
var byteIndex;
|
|
1061
|
-
var extractedBits;
|
|
1062
1439
|
var value;
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
extractedBits |= input[byteIndex - 1] << remainderBits;
|
|
1440
|
+
if (input.length > 0) {
|
|
1441
|
+
buffer = input[0];
|
|
1442
|
+
inputIndex = 1;
|
|
1443
|
+
bitPosition = 8;
|
|
1444
|
+
}
|
|
1445
|
+
while (bitPosition > 0 || inputIndex < input.length) {
|
|
1446
|
+
while (bitPosition < 6 && inputIndex < input.length) {
|
|
1447
|
+
buffer |= input[inputIndex] << bitPosition;
|
|
1448
|
+
inputIndex++;
|
|
1449
|
+
bitPosition += 8;
|
|
1074
1450
|
}
|
|
1075
|
-
|
|
1451
|
+
if (bitPosition === 0) break;
|
|
1452
|
+
value = buffer & 63;
|
|
1453
|
+
chunkSize = 6;
|
|
1076
1454
|
if ((value & 30) === 30) {
|
|
1077
|
-
|
|
1455
|
+
var remainingBits = bitPosition + (input.length - inputIndex) * 8;
|
|
1456
|
+
if (remainingBits > 6 || value > 31) {
|
|
1078
1457
|
chunkSize = 5;
|
|
1079
1458
|
value &= 31;
|
|
1080
1459
|
}
|
|
1081
1460
|
}
|
|
1082
|
-
output[outputIndex] = ENCODE_TABLE[
|
|
1461
|
+
output[outputIndex] = ENCODE_TABLE[value];
|
|
1083
1462
|
outputIndex++;
|
|
1084
|
-
|
|
1463
|
+
buffer >>= chunkSize;
|
|
1464
|
+
bitPosition -= chunkSize;
|
|
1085
1465
|
}
|
|
1086
|
-
return
|
|
1466
|
+
return textDecoder.decode(output.subarray(0, outputIndex));
|
|
1087
1467
|
},
|
|
1088
1468
|
/**
|
|
1089
1469
|
* Decodes a Base62 string generated by the custom encoder back into a Uint8Array.
|
|
@@ -1093,49 +1473,52 @@ const base62Fast = {
|
|
|
1093
1473
|
decode(input) {
|
|
1094
1474
|
var inputLength = input.length;
|
|
1095
1475
|
var maxOutputLength = inputLength * 6 / 8 | 0;
|
|
1096
|
-
var output = new Uint8Array(maxOutputLength);
|
|
1097
|
-
var writeIndex =
|
|
1476
|
+
var output = new Uint8Array(maxOutputLength + 1);
|
|
1477
|
+
var writeIndex = 0;
|
|
1098
1478
|
var bitPosition = 0;
|
|
1099
1479
|
var buffer = 0;
|
|
1100
1480
|
var charCode = 0;
|
|
1101
1481
|
var value = 0;
|
|
1482
|
+
var bitsToAdd = 0;
|
|
1102
1483
|
for (var readIndex = 0; readIndex < inputLength; readIndex++) {
|
|
1103
1484
|
charCode = input.charCodeAt(readIndex);
|
|
1104
1485
|
value = DECODE_TABLE[charCode];
|
|
1105
|
-
value = DECODE_TABLE[ENCODE_TABLE[additiveCipherReverse(value, readIndex % 63)]];
|
|
1106
1486
|
if (isNaN(charCode) || value === void 0) {
|
|
1107
1487
|
throw new Error(
|
|
1108
1488
|
"Invalid Base62 input: contains non-alphabet characters. Index: " + readIndex
|
|
1109
1489
|
);
|
|
1110
1490
|
}
|
|
1111
|
-
buffer |= value << bitPosition;
|
|
1112
1491
|
if (readIndex === inputLength - 1) {
|
|
1113
1492
|
if (LOG2_TABLE[value] === void 0) {
|
|
1114
1493
|
throw new Error(
|
|
1115
1494
|
"Invalid Base62 input: unexpected value for last character."
|
|
1116
1495
|
);
|
|
1117
1496
|
}
|
|
1118
|
-
|
|
1497
|
+
bitsToAdd = LOG2_TABLE[value];
|
|
1119
1498
|
} else if ((value & 30) === 30) {
|
|
1120
|
-
|
|
1499
|
+
bitsToAdd = 5;
|
|
1121
1500
|
} else {
|
|
1122
|
-
|
|
1501
|
+
bitsToAdd = 6;
|
|
1123
1502
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1503
|
+
buffer |= value << bitPosition;
|
|
1504
|
+
bitPosition += bitsToAdd;
|
|
1505
|
+
while (bitPosition >= 8) {
|
|
1506
|
+
output[writeIndex] = buffer & 255;
|
|
1507
|
+
writeIndex++;
|
|
1127
1508
|
buffer >>= 8;
|
|
1509
|
+
bitPosition -= 8;
|
|
1128
1510
|
}
|
|
1129
1511
|
}
|
|
1130
1512
|
if (bitPosition > 0) {
|
|
1131
|
-
output[
|
|
1513
|
+
output[writeIndex] = buffer & 255;
|
|
1514
|
+
writeIndex++;
|
|
1132
1515
|
}
|
|
1133
|
-
return output.subarray(writeIndex);
|
|
1516
|
+
return output.subarray(0, writeIndex);
|
|
1134
1517
|
}
|
|
1135
1518
|
};
|
|
1136
1519
|
function createAllocator() {
|
|
1137
|
-
var currentBuffer = new Uint8Array(
|
|
1138
|
-
var currentSize =
|
|
1520
|
+
var currentBuffer = new Uint8Array(256);
|
|
1521
|
+
var currentSize = 256;
|
|
1139
1522
|
return (size) => {
|
|
1140
1523
|
if (currentSize < size) {
|
|
1141
1524
|
currentBuffer = new Uint8Array(size);
|
|
@@ -1144,12 +1527,6 @@ function createAllocator() {
|
|
|
1144
1527
|
return currentBuffer;
|
|
1145
1528
|
};
|
|
1146
1529
|
}
|
|
1147
|
-
function additiveCipher(value, shift) {
|
|
1148
|
-
return (value + shift) % 62;
|
|
1149
|
-
}
|
|
1150
|
-
function additiveCipherReverse(obscured, shift) {
|
|
1151
|
-
return (obscured - shift + 62) % 62;
|
|
1152
|
-
}
|
|
1153
1530
|
|
|
1154
1531
|
class Base64Encoding {
|
|
1155
1532
|
alphabet;
|
|
@@ -1372,17 +1749,6 @@ function uint8ToUint32(value) {
|
|
|
1372
1749
|
return uint32Array;
|
|
1373
1750
|
}
|
|
1374
1751
|
|
|
1375
|
-
const rndCharacters = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
1376
|
-
const charactersLength = rndCharacters.length;
|
|
1377
|
-
function randomString(length) {
|
|
1378
|
-
let str = "";
|
|
1379
|
-
let num = isNumber(length) ? Math.max(0, length) : 0;
|
|
1380
|
-
while (num--) {
|
|
1381
|
-
str += rndCharacters[charactersLength * Math.random() | 0];
|
|
1382
|
-
}
|
|
1383
|
-
return str;
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
1752
|
const objectKeys = /* @__PURE__ */ new WeakMap();
|
|
1387
1753
|
const BSON_TYPES = Object.freeze(/* @__PURE__ */ new Set(["ObjectID", "ObjectId"]));
|
|
1388
1754
|
const SYM_WITH_CACHE = Symbol();
|
|
@@ -2781,7 +3147,6 @@ const ColorParser = {
|
|
|
2781
3147
|
HEX: parseHEX
|
|
2782
3148
|
};
|
|
2783
3149
|
|
|
2784
|
-
var encoder = new TextEncoder();
|
|
2785
3150
|
var TABLE = new Int32Array([
|
|
2786
3151
|
0,
|
|
2787
3152
|
1996959894,
|
|
@@ -3040,13 +3405,21 @@ var TABLE = new Int32Array([
|
|
|
3040
3405
|
1510334235,
|
|
3041
3406
|
755167117
|
|
3042
3407
|
]);
|
|
3043
|
-
function crc32(
|
|
3044
|
-
if (isString(
|
|
3045
|
-
return crc32(
|
|
3408
|
+
function crc32(value, seed) {
|
|
3409
|
+
if (isString(value)) {
|
|
3410
|
+
return crc32(textEncoder.encode(value), seed);
|
|
3046
3411
|
}
|
|
3047
3412
|
var crc = seed === 0 ? 0 : ~~seed ^ -1;
|
|
3048
|
-
|
|
3049
|
-
|
|
3413
|
+
if (value instanceof Uint8Array) {
|
|
3414
|
+
for (var index = 0; index < value.length; index++) {
|
|
3415
|
+
crc = TABLE[(crc ^ value[index]) & 255] ^ crc >>> 8;
|
|
3416
|
+
}
|
|
3417
|
+
} else {
|
|
3418
|
+
for (var current of value) {
|
|
3419
|
+
for (var index = 0; index < current.length; index++) {
|
|
3420
|
+
crc = TABLE[(crc ^ current[index]) & 255] ^ crc >>> 8;
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3050
3423
|
}
|
|
3051
3424
|
return crc ^ -1;
|
|
3052
3425
|
}
|
|
@@ -3315,13 +3688,6 @@ function timeFromMinutes(value, returnsNullWhenInvalid = false) {
|
|
|
3315
3688
|
return { h, m };
|
|
3316
3689
|
}
|
|
3317
3690
|
|
|
3318
|
-
function timestamp(fromValue = Date.now()) {
|
|
3319
|
-
if (isDate(fromValue)) {
|
|
3320
|
-
fromValue = fromValue.getTime();
|
|
3321
|
-
}
|
|
3322
|
-
return Math.floor(fromValue / 1e3);
|
|
3323
|
-
}
|
|
3324
|
-
|
|
3325
3691
|
function timestampToDate(value) {
|
|
3326
3692
|
if (!isNumber(value)) return null;
|
|
3327
3693
|
return new Date(value * 1e3);
|
|
@@ -3598,11 +3964,14 @@ class EJSONStream extends TransformStream {
|
|
|
3598
3964
|
constructor({ ejson, cl, op, sep, onFlush, onStart }) {
|
|
3599
3965
|
let firstChunk = true;
|
|
3600
3966
|
super({
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3967
|
+
start(controller) {
|
|
3968
|
+
return Promise.resolve().then(() => {
|
|
3969
|
+
if (onStart) {
|
|
3970
|
+
return onStart(controller);
|
|
3971
|
+
}
|
|
3972
|
+
}).then(() => {
|
|
3973
|
+
controller.enqueue(op);
|
|
3974
|
+
});
|
|
3606
3975
|
},
|
|
3607
3976
|
transform(chunk, controller) {
|
|
3608
3977
|
const jsonString = ejson.stringify(chunk);
|
|
@@ -3654,47 +4023,49 @@ function createEJSONStreamPayload(options) {
|
|
|
3654
4023
|
cl,
|
|
3655
4024
|
op,
|
|
3656
4025
|
sep,
|
|
3657
|
-
|
|
4026
|
+
onStart(controller) {
|
|
3658
4027
|
if (!prepend) {
|
|
3659
4028
|
controller.enqueue(`{"${resultKey}":`);
|
|
3660
|
-
return;
|
|
3661
|
-
}
|
|
3662
|
-
const data = await prepend();
|
|
3663
|
-
if (data === null || data === void 0) {
|
|
3664
|
-
controller.enqueue(`{"${resultKey}":`);
|
|
3665
|
-
return;
|
|
3666
|
-
}
|
|
3667
|
-
ok(
|
|
3668
|
-
isPlainObject(data),
|
|
3669
|
-
"prepend result expected to be plain object"
|
|
3670
|
-
);
|
|
3671
|
-
const dataPart = instance.stringify(data).slice(0, -1);
|
|
3672
|
-
if (dataPart === "{") {
|
|
3673
|
-
controller.enqueue(`{"${resultKey}":`);
|
|
3674
|
-
return;
|
|
4029
|
+
return Promise.resolve();
|
|
3675
4030
|
}
|
|
3676
|
-
|
|
4031
|
+
return Promise.resolve().then(() => prepend()).then((data) => {
|
|
4032
|
+
if (data === null || data === void 0) {
|
|
4033
|
+
controller.enqueue(`{"${resultKey}":`);
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
ok(
|
|
4037
|
+
isPlainObject(data),
|
|
4038
|
+
"prepend result expected to be plain object"
|
|
4039
|
+
);
|
|
4040
|
+
const dataPart = instance.stringify(data).slice(0, -1);
|
|
4041
|
+
if (dataPart === "{") {
|
|
4042
|
+
controller.enqueue(`{"${resultKey}":`);
|
|
4043
|
+
return;
|
|
4044
|
+
}
|
|
4045
|
+
controller.enqueue(`${dataPart}${sep}"${resultKey}":`);
|
|
4046
|
+
});
|
|
3677
4047
|
},
|
|
3678
|
-
|
|
4048
|
+
onFlush(controller) {
|
|
3679
4049
|
if (!append) {
|
|
3680
4050
|
controller.enqueue("}");
|
|
3681
|
-
return;
|
|
3682
|
-
}
|
|
3683
|
-
const data = await append();
|
|
3684
|
-
if (data === null || data === void 0) {
|
|
3685
|
-
controller.enqueue("}");
|
|
3686
|
-
return;
|
|
3687
|
-
}
|
|
3688
|
-
ok(
|
|
3689
|
-
isPlainObject(data),
|
|
3690
|
-
"prepend result expected to be plain object"
|
|
3691
|
-
);
|
|
3692
|
-
const dataPart = instance.stringify(data).slice(1);
|
|
3693
|
-
if (dataPart === "}") {
|
|
3694
|
-
controller.enqueue(`}`);
|
|
3695
|
-
return;
|
|
4051
|
+
return Promise.resolve();
|
|
3696
4052
|
}
|
|
3697
|
-
|
|
4053
|
+
return Promise.resolve().then(() => append()).then((data) => {
|
|
4054
|
+
if (data === null || data === void 0) {
|
|
4055
|
+
controller.enqueue("}");
|
|
4056
|
+
return;
|
|
4057
|
+
}
|
|
4058
|
+
ok(
|
|
4059
|
+
isPlainObject(data),
|
|
4060
|
+
"prepend result expected to be plain object"
|
|
4061
|
+
);
|
|
4062
|
+
const dataPart = instance.stringify(data).slice(1);
|
|
4063
|
+
if (dataPart === "}") {
|
|
4064
|
+
controller.enqueue(`}`);
|
|
4065
|
+
return;
|
|
4066
|
+
}
|
|
4067
|
+
controller.enqueue(`${sep}${dataPart}`);
|
|
4068
|
+
});
|
|
3698
4069
|
}
|
|
3699
4070
|
});
|
|
3700
4071
|
return stream;
|
|
@@ -3890,42 +4261,6 @@ class AppError extends Error {
|
|
|
3890
4261
|
}
|
|
3891
4262
|
}
|
|
3892
4263
|
|
|
3893
|
-
class BrowserAssertionError extends Error {
|
|
3894
|
-
/**
|
|
3895
|
-
* Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
|
|
3896
|
-
*/
|
|
3897
|
-
actual;
|
|
3898
|
-
/**
|
|
3899
|
-
* Set to the `expected` argument for methods such as {@link assert.strictEqual()}.
|
|
3900
|
-
*/
|
|
3901
|
-
expected;
|
|
3902
|
-
/**
|
|
3903
|
-
* Set to the passed in operator value.
|
|
3904
|
-
*/
|
|
3905
|
-
operator;
|
|
3906
|
-
/**
|
|
3907
|
-
* Indicates if the message was auto-generated (`true`) or not.
|
|
3908
|
-
*/
|
|
3909
|
-
generatedMessage;
|
|
3910
|
-
/**
|
|
3911
|
-
* Value is always `ERR_ASSERTION` to show that the error is an assertion error.
|
|
3912
|
-
*/
|
|
3913
|
-
code;
|
|
3914
|
-
constructor(options) {
|
|
3915
|
-
super(options?.message);
|
|
3916
|
-
this.actual = options?.actual;
|
|
3917
|
-
this.expected = options?.expected;
|
|
3918
|
-
this.operator = options?.operator ?? "none";
|
|
3919
|
-
this.generatedMessage = false;
|
|
3920
|
-
this.code = "ERR_ASSERTION";
|
|
3921
|
-
}
|
|
3922
|
-
}
|
|
3923
|
-
|
|
3924
|
-
const BrowserAssertionError$1 = {
|
|
3925
|
-
__proto__: null,
|
|
3926
|
-
BrowserAssertionError: BrowserAssertionError
|
|
3927
|
-
};
|
|
3928
|
-
|
|
3929
4264
|
function getFileExtension(name, withDot = true) {
|
|
3930
4265
|
if (!isString(name)) {
|
|
3931
4266
|
return null;
|
|
@@ -3934,12 +4269,6 @@ function getFileExtension(name, withDot = true) {
|
|
|
3934
4269
|
return ext ? withDot ? `.${ext}` : ext : null;
|
|
3935
4270
|
}
|
|
3936
4271
|
|
|
3937
|
-
const DEF_PROTOCOLS = ["http://", "https://"];
|
|
3938
|
-
function hasProtocol(url, protocols = DEF_PROTOCOLS) {
|
|
3939
|
-
if (!isString(url)) return false;
|
|
3940
|
-
return protocols.some((v) => url.startsWith(v));
|
|
3941
|
-
}
|
|
3942
|
-
|
|
3943
4272
|
function getFileName(value) {
|
|
3944
4273
|
if (hasProtocol(value)) {
|
|
3945
4274
|
return getFileName(decodeURI(value.split("/").at(-1)?.split("?")?.at(0)));
|
|
@@ -4314,48 +4643,40 @@ function delay(amount = "tick") {
|
|
|
4314
4643
|
return d.promise;
|
|
4315
4644
|
}
|
|
4316
4645
|
|
|
4317
|
-
|
|
4646
|
+
var NOOP_SHOULD_RETRY_BASED_ON_ERROR = () => true;
|
|
4318
4647
|
function retryOnError({
|
|
4319
|
-
beforeRetryCallback,
|
|
4320
|
-
shouldRetryBasedOnError =
|
|
4321
|
-
|
|
4648
|
+
beforeRetryCallback = noop,
|
|
4649
|
+
shouldRetryBasedOnError = NOOP_SHOULD_RETRY_BASED_ON_ERROR,
|
|
4650
|
+
maxAttempts,
|
|
4651
|
+
maxRetriesNumber = 1,
|
|
4322
4652
|
delayFactor = 0,
|
|
4323
4653
|
delayMaxMs = 1e3,
|
|
4324
4654
|
delayMinMs = 100
|
|
4325
4655
|
}, fn) {
|
|
4326
|
-
let retryCount = maxRetriesNumber;
|
|
4327
|
-
let delayMs = 0;
|
|
4328
4656
|
delayMinMs = Math.max(delayMinMs, 1);
|
|
4329
4657
|
delayMaxMs = Math.max(delayMaxMs, 1);
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
return
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
retryCount--;
|
|
4341
|
-
delayMs = Math.floor(
|
|
4342
|
-
Math.min(Math.max(delayMs, delayMinMs) * delayFactor, delayMaxMs)
|
|
4343
|
-
);
|
|
4344
|
-
if (beforeRetryCallback) {
|
|
4345
|
-
const newParams = await beforeRetryCallback(
|
|
4346
|
-
currentAttempt,
|
|
4347
|
-
retryCount === 0
|
|
4348
|
-
);
|
|
4349
|
-
if (newParams) {
|
|
4350
|
-
return run(newParams);
|
|
4351
|
-
}
|
|
4658
|
+
return function(...args) {
|
|
4659
|
+
var delayMs = 0;
|
|
4660
|
+
var currentAttempt = 0;
|
|
4661
|
+
var leftAttempts = isNumber(maxAttempts) ? maxAttempts : maxRetriesNumber + 1;
|
|
4662
|
+
var run = () => {
|
|
4663
|
+
currentAttempt++;
|
|
4664
|
+
leftAttempts--;
|
|
4665
|
+
return Promise.resolve().then(() => fn.apply(this, args)).catch((e) => {
|
|
4666
|
+
if (leftAttempts < 1 || !shouldRetryBasedOnError(e, currentAttempt)) {
|
|
4667
|
+
return Promise.reject(e);
|
|
4352
4668
|
}
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4669
|
+
delayMs = clamp(delayMs * delayFactor, delayMinMs, delayMaxMs);
|
|
4670
|
+
return Promise.resolve().then(() => beforeRetryCallback(currentAttempt, leftAttempts <= 1)).then((newParams) => {
|
|
4671
|
+
if (Array.isArray(newParams)) {
|
|
4672
|
+
args = newParams;
|
|
4673
|
+
}
|
|
4674
|
+
return delay(delayMs).then(() => run());
|
|
4675
|
+
});
|
|
4676
|
+
});
|
|
4677
|
+
};
|
|
4678
|
+
return run();
|
|
4357
4679
|
};
|
|
4358
|
-
return run;
|
|
4359
4680
|
}
|
|
4360
4681
|
|
|
4361
4682
|
function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
|
|
@@ -4378,90 +4699,6 @@ function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] }
|
|
|
4378
4699
|
return throttled;
|
|
4379
4700
|
}
|
|
4380
4701
|
|
|
4381
|
-
function sprintf(line, args, unusedArgs = []) {
|
|
4382
|
-
let result = "";
|
|
4383
|
-
const argsLen = args.length;
|
|
4384
|
-
const lineLen = line.length;
|
|
4385
|
-
let opened = false;
|
|
4386
|
-
let currentChar = -1;
|
|
4387
|
-
let lastPos = 0;
|
|
4388
|
-
let argsIndex = 0;
|
|
4389
|
-
for (let idx = 0; idx < lineLen; idx++) {
|
|
4390
|
-
currentChar = line.charCodeAt(idx);
|
|
4391
|
-
if (currentChar === 37) {
|
|
4392
|
-
opened = true;
|
|
4393
|
-
continue;
|
|
4394
|
-
}
|
|
4395
|
-
if (!opened) continue;
|
|
4396
|
-
opened = false;
|
|
4397
|
-
switch (currentChar) {
|
|
4398
|
-
// 'd'
|
|
4399
|
-
case 100:
|
|
4400
|
-
// 'f'
|
|
4401
|
-
case 102: {
|
|
4402
|
-
result += line.slice(lastPos, idx - 1);
|
|
4403
|
-
result += Number(args[argsIndex]);
|
|
4404
|
-
lastPos = idx + 1;
|
|
4405
|
-
argsIndex++;
|
|
4406
|
-
break;
|
|
4407
|
-
}
|
|
4408
|
-
// 'i'
|
|
4409
|
-
case 105: {
|
|
4410
|
-
result += line.slice(lastPos, idx - 1);
|
|
4411
|
-
result += Math.floor(Number(args[argsIndex]));
|
|
4412
|
-
lastPos = idx + 1;
|
|
4413
|
-
argsIndex++;
|
|
4414
|
-
break;
|
|
4415
|
-
}
|
|
4416
|
-
// 'O'
|
|
4417
|
-
case 79:
|
|
4418
|
-
// 'o'
|
|
4419
|
-
case 111:
|
|
4420
|
-
// 'j'
|
|
4421
|
-
case 106: {
|
|
4422
|
-
result += line.slice(lastPos, idx - 1);
|
|
4423
|
-
result += tryStringify(args[argsIndex]);
|
|
4424
|
-
lastPos = idx + 1;
|
|
4425
|
-
argsIndex++;
|
|
4426
|
-
break;
|
|
4427
|
-
}
|
|
4428
|
-
// 's'
|
|
4429
|
-
case 115: {
|
|
4430
|
-
result += line.slice(lastPos, idx - 1);
|
|
4431
|
-
result += String(args[argsIndex]);
|
|
4432
|
-
lastPos = idx + 1;
|
|
4433
|
-
argsIndex++;
|
|
4434
|
-
break;
|
|
4435
|
-
}
|
|
4436
|
-
}
|
|
4437
|
-
if (argsIndex >= argsLen) break;
|
|
4438
|
-
}
|
|
4439
|
-
if (lastPos < lineLen) {
|
|
4440
|
-
result += line.slice(lastPos, lineLen);
|
|
4441
|
-
}
|
|
4442
|
-
if (argsIndex < argsLen) {
|
|
4443
|
-
unusedArgs.push(...args.slice(argsIndex, argsLen));
|
|
4444
|
-
}
|
|
4445
|
-
return result;
|
|
4446
|
-
}
|
|
4447
|
-
function tryStringify(o) {
|
|
4448
|
-
switch (typeof o) {
|
|
4449
|
-
case "function": {
|
|
4450
|
-
return o.name || "<anonymous>";
|
|
4451
|
-
}
|
|
4452
|
-
case "string": {
|
|
4453
|
-
return "'" + o + "'";
|
|
4454
|
-
}
|
|
4455
|
-
default: {
|
|
4456
|
-
try {
|
|
4457
|
-
return JSON.stringify(o);
|
|
4458
|
-
} catch (e) {
|
|
4459
|
-
return '"[Circular]"';
|
|
4460
|
-
}
|
|
4461
|
-
}
|
|
4462
|
-
}
|
|
4463
|
-
}
|
|
4464
|
-
|
|
4465
4702
|
const LEVEL_NUM = {
|
|
4466
4703
|
debug: 0,
|
|
4467
4704
|
log: 1,
|
|
@@ -4513,18 +4750,26 @@ const logger = (...baseArgs) => {
|
|
|
4513
4750
|
return instance;
|
|
4514
4751
|
};
|
|
4515
4752
|
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4753
|
+
function asyncFilter(array, predicate) {
|
|
4754
|
+
var i = 0;
|
|
4755
|
+
var result = [];
|
|
4756
|
+
var cooldown = nextTickIteration(10);
|
|
4757
|
+
return new Promise((resolve, reject) => {
|
|
4758
|
+
var processNextBatch = () => {
|
|
4759
|
+
if (i < array.length) {
|
|
4760
|
+
cooldown().then(() => predicate(array[i], i, array)).then((valid) => {
|
|
4761
|
+
if (Boolean(valid)) {
|
|
4762
|
+
result.push(array[i]);
|
|
4763
|
+
}
|
|
4764
|
+
i++;
|
|
4765
|
+
setTimeout(processNextBatch, 0);
|
|
4766
|
+
}).catch(reject);
|
|
4767
|
+
} else {
|
|
4768
|
+
resolve(result);
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
processNextBatch();
|
|
4772
|
+
});
|
|
4528
4773
|
}
|
|
4529
4774
|
|
|
4530
4775
|
function nextTickIteration(amount, delay = "tick") {
|
|
@@ -4546,33 +4791,60 @@ function nextTickIteration(amount, delay = "tick") {
|
|
|
4546
4791
|
};
|
|
4547
4792
|
}
|
|
4548
4793
|
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4794
|
+
function asyncFind(array, callbackfn) {
|
|
4795
|
+
var i = 0;
|
|
4796
|
+
var cooldown = nextTickIteration(10);
|
|
4797
|
+
return new Promise((resolve, reject) => {
|
|
4798
|
+
var processNextBatch = () => {
|
|
4799
|
+
if (i < array.length) {
|
|
4800
|
+
cooldown().then(() => callbackfn(array[i], i, array)).then((result) => {
|
|
4801
|
+
if (Boolean(result)) {
|
|
4802
|
+
resolve(array[i]);
|
|
4803
|
+
} else {
|
|
4804
|
+
i++;
|
|
4805
|
+
setTimeout(processNextBatch, 0);
|
|
4806
|
+
}
|
|
4807
|
+
}).catch(reject);
|
|
4808
|
+
} else {
|
|
4809
|
+
resolve(void 0);
|
|
4810
|
+
}
|
|
4811
|
+
};
|
|
4812
|
+
processNextBatch();
|
|
4813
|
+
});
|
|
4561
4814
|
}
|
|
4562
4815
|
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4816
|
+
function asyncForEach(array, callbackfn, { concurrency = 1 } = {}) {
|
|
4817
|
+
concurrency = Math.max(concurrency, 1);
|
|
4818
|
+
var i = 0;
|
|
4819
|
+
var cooldown = nextTickIteration(10);
|
|
4820
|
+
var tasks = Array(concurrency);
|
|
4821
|
+
return new Promise((resolve, reject) => {
|
|
4822
|
+
var processNextBatch = () => {
|
|
4823
|
+
if (i >= array.length) {
|
|
4824
|
+
resolve();
|
|
4825
|
+
return;
|
|
4826
|
+
}
|
|
4827
|
+
cooldown().then(() => {
|
|
4828
|
+
for (var idx = 0; idx < concurrency; idx++) {
|
|
4829
|
+
tasks[idx] = Promise.resolve(i);
|
|
4830
|
+
if (i < array.length) {
|
|
4831
|
+
tasks[idx] = tasks[idx].then(
|
|
4832
|
+
(itemIndex) => callbackfn(array[itemIndex], itemIndex, array)
|
|
4833
|
+
);
|
|
4834
|
+
}
|
|
4835
|
+
i++;
|
|
4836
|
+
}
|
|
4837
|
+
return Promise.all(tasks);
|
|
4838
|
+
}).then(() => {
|
|
4839
|
+
if (i < array.length) {
|
|
4840
|
+
setTimeout(processNextBatch, 0);
|
|
4841
|
+
} else {
|
|
4842
|
+
resolve();
|
|
4843
|
+
}
|
|
4844
|
+
}).catch(reject);
|
|
4845
|
+
};
|
|
4846
|
+
processNextBatch();
|
|
4847
|
+
});
|
|
4576
4848
|
}
|
|
4577
4849
|
|
|
4578
4850
|
const onError = (error) => {
|
|
@@ -4648,20 +4920,27 @@ class Queue {
|
|
|
4648
4920
|
constructor(limit) {
|
|
4649
4921
|
this.#limit = limit;
|
|
4650
4922
|
}
|
|
4651
|
-
|
|
4923
|
+
get() {
|
|
4924
|
+
var getItem = () => {
|
|
4925
|
+
const item = this.items.shift();
|
|
4926
|
+
this.#events.emit("get");
|
|
4927
|
+
return Promise.resolve(item);
|
|
4928
|
+
};
|
|
4652
4929
|
if (this.items.length === 0) {
|
|
4653
|
-
|
|
4930
|
+
return SimpleEventEmitter.once(this.#events, "put").then(getItem);
|
|
4654
4931
|
}
|
|
4655
|
-
|
|
4656
|
-
this.#events.emit("get");
|
|
4657
|
-
return item;
|
|
4932
|
+
return getItem();
|
|
4658
4933
|
}
|
|
4659
|
-
|
|
4934
|
+
put(item) {
|
|
4935
|
+
var putItem = () => {
|
|
4936
|
+
this.items.push(item);
|
|
4937
|
+
this.#events.emit("put");
|
|
4938
|
+
return Promise.resolve();
|
|
4939
|
+
};
|
|
4660
4940
|
if (this.#limit && this.items.length >= this.#limit) {
|
|
4661
|
-
|
|
4941
|
+
return SimpleEventEmitter.once(this.#events, "get").then(putItem);
|
|
4662
4942
|
}
|
|
4663
|
-
|
|
4664
|
-
this.#events.emit("put");
|
|
4943
|
+
return putItem();
|
|
4665
4944
|
}
|
|
4666
4945
|
}
|
|
4667
4946
|
|
|
@@ -4688,37 +4967,56 @@ class AsyncIterableQueue {
|
|
|
4688
4967
|
}
|
|
4689
4968
|
[Symbol.asyncIterator]() {
|
|
4690
4969
|
return {
|
|
4691
|
-
next:
|
|
4970
|
+
next: () => {
|
|
4692
4971
|
if (this._closed && this._queue.items.length === 0) {
|
|
4693
|
-
return { value: void 0, done: true };
|
|
4694
|
-
}
|
|
4695
|
-
const item = await this._queue.get();
|
|
4696
|
-
if (item === AsyncIterableQueue.QUEUE_END_MARKER && this._closed) {
|
|
4697
|
-
return { value: void 0, done: true };
|
|
4972
|
+
return Promise.resolve({ value: void 0, done: true });
|
|
4698
4973
|
}
|
|
4699
|
-
return
|
|
4974
|
+
return this._queue.get().then((item) => {
|
|
4975
|
+
if (item === AsyncIterableQueue.QUEUE_END_MARKER && this._closed) {
|
|
4976
|
+
return { value: void 0, done: true };
|
|
4977
|
+
}
|
|
4978
|
+
return { value: item, done: false };
|
|
4979
|
+
});
|
|
4700
4980
|
}
|
|
4701
4981
|
};
|
|
4702
4982
|
}
|
|
4703
4983
|
}
|
|
4704
4984
|
|
|
4705
|
-
|
|
4706
|
-
let result = [];
|
|
4985
|
+
function asyncMap(array, callbackfn, { concurrency = 1 } = {}) {
|
|
4707
4986
|
concurrency = Math.max(concurrency, 1);
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4987
|
+
var result = [];
|
|
4988
|
+
var i = 0;
|
|
4989
|
+
var cooldown = nextTickIteration(10);
|
|
4990
|
+
var tasks = Array(concurrency);
|
|
4991
|
+
return new Promise((resolve, reject) => {
|
|
4992
|
+
var processNextBatch = () => {
|
|
4993
|
+
if (i >= array.length) {
|
|
4994
|
+
resolve(result);
|
|
4995
|
+
} else {
|
|
4996
|
+
cooldown().then(() => {
|
|
4997
|
+
for (var idx = 0; idx < concurrency; idx++) {
|
|
4998
|
+
tasks[idx] = Promise.resolve(i);
|
|
4999
|
+
if (i < array.length) {
|
|
5000
|
+
tasks[idx] = tasks[idx].then(
|
|
5001
|
+
(itemIndex) => callbackfn(array[itemIndex], itemIndex, array)
|
|
5002
|
+
).then((transformed) => {
|
|
5003
|
+
result.push(transformed);
|
|
5004
|
+
});
|
|
5005
|
+
}
|
|
5006
|
+
i++;
|
|
5007
|
+
}
|
|
5008
|
+
return Promise.all(tasks);
|
|
5009
|
+
}).then(() => {
|
|
5010
|
+
if (i < array.length) {
|
|
5011
|
+
setTimeout(processNextBatch, 0);
|
|
5012
|
+
} else {
|
|
5013
|
+
resolve(result);
|
|
5014
|
+
}
|
|
5015
|
+
}).catch(reject);
|
|
5016
|
+
}
|
|
5017
|
+
};
|
|
5018
|
+
processNextBatch();
|
|
5019
|
+
});
|
|
4722
5020
|
}
|
|
4723
5021
|
|
|
4724
5022
|
class CancellablePromise {
|
|
@@ -4865,6 +5163,7 @@ class ResourcePool extends SimpleEventEmitter {
|
|
|
4865
5163
|
queueAcquire: [],
|
|
4866
5164
|
queueDrain: [],
|
|
4867
5165
|
queueDestroy: [],
|
|
5166
|
+
createPending: 0,
|
|
4868
5167
|
destroying: false
|
|
4869
5168
|
};
|
|
4870
5169
|
}
|
|
@@ -4909,23 +5208,24 @@ class ResourcePool extends SimpleEventEmitter {
|
|
|
4909
5208
|
* }
|
|
4910
5209
|
* ```
|
|
4911
5210
|
*/
|
|
4912
|
-
|
|
5211
|
+
acquire() {
|
|
4913
5212
|
if (this.state.destroying) {
|
|
4914
5213
|
return this.enqueueAcquireRequest();
|
|
4915
5214
|
}
|
|
4916
5215
|
let availableResource = this.tryGetAvailableResource();
|
|
4917
5216
|
if (availableResource !== null) {
|
|
4918
|
-
return availableResource;
|
|
4919
|
-
}
|
|
4920
|
-
const autoCreatedResource = await this.tryCreateAutoResource();
|
|
4921
|
-
if (autoCreatedResource !== null) {
|
|
4922
|
-
return autoCreatedResource;
|
|
4923
|
-
}
|
|
4924
|
-
availableResource = this.tryGetAvailableResource();
|
|
4925
|
-
if (availableResource !== null) {
|
|
4926
|
-
return availableResource;
|
|
5217
|
+
return Promise.resolve(availableResource);
|
|
4927
5218
|
}
|
|
4928
|
-
return this.
|
|
5219
|
+
return Promise.resolve().then(() => this.tryCreateAutoResource()).then((autoCreatedResource) => {
|
|
5220
|
+
if (autoCreatedResource !== null) {
|
|
5221
|
+
return autoCreatedResource;
|
|
5222
|
+
}
|
|
5223
|
+
availableResource = this.tryGetAvailableResource();
|
|
5224
|
+
if (availableResource !== null) {
|
|
5225
|
+
return availableResource;
|
|
5226
|
+
}
|
|
5227
|
+
return this.enqueueAcquireRequest();
|
|
5228
|
+
});
|
|
4929
5229
|
}
|
|
4930
5230
|
/**
|
|
4931
5231
|
* Returns a resource to the pool, making it available for reuse.
|
|
@@ -4999,9 +5299,9 @@ class ResourcePool extends SimpleEventEmitter {
|
|
|
4999
5299
|
* - Multiple drain calls can be made concurrently; they will all resolve together
|
|
5000
5300
|
* - Does not prevent new acquisitions; use destroy() to prevent new usage
|
|
5001
5301
|
*/
|
|
5002
|
-
|
|
5302
|
+
drain() {
|
|
5003
5303
|
if (this.isIdle) {
|
|
5004
|
-
return;
|
|
5304
|
+
return Promise.resolve();
|
|
5005
5305
|
}
|
|
5006
5306
|
const drainDefer = defer();
|
|
5007
5307
|
this.state.queueDrain.push(drainDefer);
|
|
@@ -5035,24 +5335,22 @@ class ResourcePool extends SimpleEventEmitter {
|
|
|
5035
5335
|
* - Resources currently in use will not be force-destroyed; drain() is called first
|
|
5036
5336
|
* - If destroyResource was not provided, resources are simply discarded
|
|
5037
5337
|
*/
|
|
5038
|
-
|
|
5338
|
+
destroy(rejectAcquires = false) {
|
|
5039
5339
|
if (this.state.destroying) {
|
|
5040
5340
|
return this.enqueueDestroyRequest();
|
|
5041
5341
|
}
|
|
5042
5342
|
this.state.destroying = true;
|
|
5043
|
-
|
|
5044
|
-
await this.drain();
|
|
5343
|
+
return Promise.resolve().then(() => this.drain()).then(() => {
|
|
5045
5344
|
if (rejectAcquires) {
|
|
5046
5345
|
this.rejectPendingAcquires();
|
|
5047
5346
|
}
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
} catch (err) {
|
|
5347
|
+
return this.destroyAllResources();
|
|
5348
|
+
}).then(() => this.resetState()).catch((err) => {
|
|
5051
5349
|
this.emit("error", toError(err));
|
|
5052
|
-
}
|
|
5350
|
+
}).finally(() => {
|
|
5053
5351
|
this.state.destroying = false;
|
|
5054
5352
|
this.resolveDestroyQueue();
|
|
5055
|
-
}
|
|
5353
|
+
});
|
|
5056
5354
|
}
|
|
5057
5355
|
tryGetAvailableResource() {
|
|
5058
5356
|
if (this.state.availableResources.length === 0) {
|
|
@@ -5062,13 +5360,20 @@ class ResourcePool extends SimpleEventEmitter {
|
|
|
5062
5360
|
this.state.inUseResources.add(resource);
|
|
5063
5361
|
return resource;
|
|
5064
5362
|
}
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5363
|
+
isLimitReached() {
|
|
5364
|
+
return this.state.inUseResources.size + this.state.createPending + this.state.availableResources.length >= this.poolSize;
|
|
5365
|
+
}
|
|
5366
|
+
tryCreateAutoResource() {
|
|
5367
|
+
if (!this.auto || this.isLimitReached()) {
|
|
5368
|
+
return Promise.resolve(null);
|
|
5068
5369
|
}
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5370
|
+
this.state.createPending++;
|
|
5371
|
+
return Promise.resolve().then(() => this.createResource()).then((resource) => {
|
|
5372
|
+
this.state.inUseResources.add(resource);
|
|
5373
|
+
return resource;
|
|
5374
|
+
}).finally(() => {
|
|
5375
|
+
this.state.createPending--;
|
|
5376
|
+
});
|
|
5072
5377
|
}
|
|
5073
5378
|
enqueueAcquireRequest() {
|
|
5074
5379
|
const acquireDefer = defer();
|
|
@@ -5103,18 +5408,14 @@ class ResourcePool extends SimpleEventEmitter {
|
|
|
5103
5408
|
this.state.queueAcquire.forEach((deferred) => deferred.reject(destroyError));
|
|
5104
5409
|
this.state.queueAcquire = [];
|
|
5105
5410
|
}
|
|
5106
|
-
|
|
5411
|
+
destroyAllResources() {
|
|
5107
5412
|
if (!this.destroyResource || this.state.availableResources.length === 0) {
|
|
5108
|
-
return;
|
|
5413
|
+
return Promise.resolve();
|
|
5109
5414
|
}
|
|
5110
|
-
|
|
5415
|
+
return asyncForEach(
|
|
5111
5416
|
this.state.availableResources,
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
await this.destroyResource(resource);
|
|
5115
|
-
} catch (err) {
|
|
5116
|
-
this.emit("error", toError(err));
|
|
5117
|
-
}
|
|
5417
|
+
(resource) => {
|
|
5418
|
+
return Promise.resolve().then(() => this.destroyResource(resource)).catch((err) => this.emit("error", toError(err))).then(noop);
|
|
5118
5419
|
},
|
|
5119
5420
|
{ concurrency: 4 }
|
|
5120
5421
|
);
|
|
@@ -5158,241 +5459,5 @@ function timeout(ms, promiseOrCallback, timeoutError = new AppError(408)) {
|
|
|
5158
5459
|
});
|
|
5159
5460
|
}
|
|
5160
5461
|
|
|
5161
|
-
|
|
5162
|
-
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
5163
|
-
}
|
|
5164
|
-
|
|
5165
|
-
const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
|
|
5166
|
-
function getWords(str) {
|
|
5167
|
-
if (!isString(str)) return [];
|
|
5168
|
-
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
5169
|
-
}
|
|
5170
|
-
|
|
5171
|
-
function camelCase(str) {
|
|
5172
|
-
const words = getWords(str);
|
|
5173
|
-
if (words.length === 0) {
|
|
5174
|
-
return "";
|
|
5175
|
-
}
|
|
5176
|
-
const [first, ...rest] = words;
|
|
5177
|
-
return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join("")}`;
|
|
5178
|
-
}
|
|
5179
|
-
|
|
5180
|
-
function convertToUnit(str, unit = "px") {
|
|
5181
|
-
if (str == null || str === "") {
|
|
5182
|
-
return void 0;
|
|
5183
|
-
} else if (isNaN(+str)) {
|
|
5184
|
-
return String(str);
|
|
5185
|
-
} else {
|
|
5186
|
-
return `${Number(str)}${unit}`;
|
|
5187
|
-
}
|
|
5188
|
-
}
|
|
5189
|
-
|
|
5190
|
-
const htmlEscapes = Object.freeze({
|
|
5191
|
-
38: "&",
|
|
5192
|
-
// &
|
|
5193
|
-
60: "<",
|
|
5194
|
-
// <
|
|
5195
|
-
62: ">",
|
|
5196
|
-
// >
|
|
5197
|
-
34: """,
|
|
5198
|
-
// "
|
|
5199
|
-
39: "'"
|
|
5200
|
-
// '
|
|
5201
|
-
});
|
|
5202
|
-
function escapeHtml(unsafe) {
|
|
5203
|
-
if (typeof unsafe !== "string") {
|
|
5204
|
-
return "";
|
|
5205
|
-
}
|
|
5206
|
-
let result = "";
|
|
5207
|
-
let strLen = unsafe.length;
|
|
5208
|
-
let char;
|
|
5209
|
-
for (let idx = 0; idx < strLen; idx++) {
|
|
5210
|
-
char = unsafe.charCodeAt(idx);
|
|
5211
|
-
result += htmlEscapes[char] || String.fromCharCode(char);
|
|
5212
|
-
}
|
|
5213
|
-
return result;
|
|
5214
|
-
}
|
|
5215
|
-
|
|
5216
|
-
function escapeNumeric(str) {
|
|
5217
|
-
const result = String(str).replace(/\D/g, "");
|
|
5218
|
-
if (!result.length) {
|
|
5219
|
-
return void 0;
|
|
5220
|
-
}
|
|
5221
|
-
return result;
|
|
5222
|
-
}
|
|
5223
|
-
|
|
5224
|
-
function escapeRegExp(str) {
|
|
5225
|
-
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
5226
|
-
}
|
|
5227
|
-
|
|
5228
|
-
const vs16RegExp = /\uFE0F/g;
|
|
5229
|
-
const zeroWidthJoiner = String.fromCharCode(8205);
|
|
5230
|
-
function removeVS16s(rawEmoji) {
|
|
5231
|
-
return rawEmoji.indexOf(zeroWidthJoiner) < 0 ? rawEmoji.replace(vs16RegExp, "") : rawEmoji;
|
|
5232
|
-
}
|
|
5233
|
-
const TWEMOJI_REGEX = /(?:\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83d\udc68\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc68\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83d\udc69\ud83c[\udffb-\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffc-\udfff]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffd-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffd\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\u2764\ufe0f\u200d\ud83e\uddd1\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83e\udef1\ud83c\udffb\u200d\ud83e\udef2\ud83c[\udffc-\udfff]|\ud83e\udef1\ud83c\udffc\u200d\ud83e\udef2\ud83c[\udffb\udffd-\udfff]|\ud83e\udef1\ud83c\udffd\u200d\ud83e\udef2\ud83c[\udffb\udffc\udffe\udfff]|\ud83e\udef1\ud83c\udffe\u200d\ud83e\udef2\ud83c[\udffb-\udffd\udfff]|\ud83e\udef1\ud83c\udfff\u200d\ud83e\udef2\ud83c[\udffb-\udffe]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d\udc8f\ud83c[\udffb-\udfff]|\ud83d\udc91\ud83c[\udffb-\udfff]|\ud83e\udd1d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d\udc8f\udc91]|\ud83e\udd1d)|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf7c\udf84\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc70\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd4\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83d\ude36\u200d\ud83c\udf2b\ufe0f|\u2764\ufe0f\u200d\ud83d\udd25|\u2764\ufe0f\u200d\ud83e\ude79|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc3b\u200d\u2744\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83d\ude2e\u200d\ud83d\udca8|\ud83d\ude35\u200d\ud83d\udcab|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f|\ud83d\udc08\u200d\u2b1b)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0c\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\udd77\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd\udec3-\udec5\udef0-\udef6]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udc8e\udc90\udc92-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5-\uded7\udedd-\udedf\udeeb\udeec\udef4-\udefc\udfe0-\udfeb\udff0]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd76\udd78-\uddb4\uddb7\uddba\uddbc-\uddcc\uddd0\uddde-\uddff\ude70-\ude74\ude78-\ude7c\ude80-\ude86\ude90-\udeac\udeb0-\udeba\udec0-\udec2\uded0-\uded9\udee0-\udee7]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g;
|
|
5234
|
-
|
|
5235
|
-
function isOneEmoji(text) {
|
|
5236
|
-
return !!(typeof text === "string" && text && (text.match(TWEMOJI_REGEX) || [])[0]?.length === text.length);
|
|
5237
|
-
}
|
|
5238
|
-
|
|
5239
|
-
const IGNORED_TITLES = Object.freeze(
|
|
5240
|
-
/* @__PURE__ */ new Set([
|
|
5241
|
-
"dr.",
|
|
5242
|
-
"mr.",
|
|
5243
|
-
"mrs.",
|
|
5244
|
-
"miss",
|
|
5245
|
-
"ms.",
|
|
5246
|
-
"prof.",
|
|
5247
|
-
"sir",
|
|
5248
|
-
"rev.",
|
|
5249
|
-
"hon."
|
|
5250
|
-
])
|
|
5251
|
-
);
|
|
5252
|
-
function getInitials(fullName) {
|
|
5253
|
-
if (!isString(fullName)) return "";
|
|
5254
|
-
let [first, ...rest] = fullName.replace(/\s{2,}/g, " ").replace(/[,+/#!$@%^&*;:{}=\-_`~()]/g, "").trim().split(" ").filter((word) => !IGNORED_TITLES.has(word.toLowerCase())).map((v) => v.replaceAll(".", "").trim()).filter(Boolean);
|
|
5255
|
-
let last = rest[rest.length - 1];
|
|
5256
|
-
if (rest.length > 1) {
|
|
5257
|
-
if (isOneEmoji(first)) {
|
|
5258
|
-
first = rest[0];
|
|
5259
|
-
} else if (isOneEmoji(last)) {
|
|
5260
|
-
last = rest[0];
|
|
5261
|
-
}
|
|
5262
|
-
}
|
|
5263
|
-
return [first, last].filter(Boolean).map((letter = "") => [...letter.toUpperCase()][0]).join("");
|
|
5264
|
-
}
|
|
5265
|
-
|
|
5266
|
-
const byteToHex = [];
|
|
5267
|
-
for (let n = 0; n <= 255; ++n) {
|
|
5268
|
-
const hexOctet = n.toString(16).padStart(2, "0");
|
|
5269
|
-
byteToHex.push(hexOctet);
|
|
5270
|
-
}
|
|
5271
|
-
function hex(value) {
|
|
5272
|
-
const buff = Array.isArray(value) ? new Uint8Array(value) : value;
|
|
5273
|
-
const hexOctets = new Array(buff.length);
|
|
5274
|
-
for (let i = 0; i < buff.length; ++i) {
|
|
5275
|
-
hexOctets[i] = byteToHex[buff[i]];
|
|
5276
|
-
}
|
|
5277
|
-
return hexOctets.join("");
|
|
5278
|
-
}
|
|
5279
|
-
|
|
5280
|
-
function isoToFlagEmoji(iso) {
|
|
5281
|
-
const code = iso.toUpperCase();
|
|
5282
|
-
if (!/^[A-Z]{2}$/.test(code)) return iso;
|
|
5283
|
-
const codePoints = [...code].map((c) => c.codePointAt(0) + 127397);
|
|
5284
|
-
return String.fromCodePoint(...codePoints);
|
|
5285
|
-
}
|
|
5286
|
-
|
|
5287
|
-
function kebabCase(str) {
|
|
5288
|
-
const words = getWords(str);
|
|
5289
|
-
return words.map((word) => word.toLowerCase()).join("-");
|
|
5290
|
-
}
|
|
5291
|
-
|
|
5292
|
-
const lowerCase = (str) => {
|
|
5293
|
-
return getWords(str).map((word) => word.toLowerCase()).join(" ");
|
|
5294
|
-
};
|
|
5295
|
-
|
|
5296
|
-
function maskingWords(value, withChar = "*") {
|
|
5297
|
-
return getWords(value).map((word) => {
|
|
5298
|
-
const len = word.length;
|
|
5299
|
-
if (len < 2) {
|
|
5300
|
-
return "".padEnd(len, withChar);
|
|
5301
|
-
} else if (len < 3) {
|
|
5302
|
-
return word[0].padEnd(len, withChar);
|
|
5303
|
-
} else {
|
|
5304
|
-
return word[0].padEnd(len - 2, withChar) + word.at(-1);
|
|
5305
|
-
}
|
|
5306
|
-
}).join(" ");
|
|
5307
|
-
}
|
|
5308
|
-
|
|
5309
|
-
function maskingEmail(value) {
|
|
5310
|
-
if (!isString(value)) return "";
|
|
5311
|
-
const [username, host] = value.split("@", 2);
|
|
5312
|
-
if (!username || !host) return "";
|
|
5313
|
-
return `${maskingWords(username)}@${host}`;
|
|
5314
|
-
}
|
|
5315
|
-
|
|
5316
|
-
function maskingPhone(value, fromPosition = 2, toPosition = 4, withChar = "X") {
|
|
5317
|
-
if (!isString(value)) return "";
|
|
5318
|
-
const numbersAmount = value.replace(/\D/g, "").length;
|
|
5319
|
-
const fromIdx = fromPosition - 1;
|
|
5320
|
-
let toIdx = numbersAmount - toPosition;
|
|
5321
|
-
if (toIdx <= 0) {
|
|
5322
|
-
toIdx = numbersAmount;
|
|
5323
|
-
}
|
|
5324
|
-
let i = -1;
|
|
5325
|
-
return value.replace(/\d/g, (char) => {
|
|
5326
|
-
i++;
|
|
5327
|
-
return i > fromIdx && i < toIdx ? withChar : char;
|
|
5328
|
-
});
|
|
5329
|
-
}
|
|
5330
|
-
|
|
5331
|
-
let index = Math.floor(Math.random() * 16777215);
|
|
5332
|
-
const buffer = new Uint8Array(12);
|
|
5333
|
-
function objectId(fromValue = Date.now()) {
|
|
5334
|
-
const value = timestamp(fromValue);
|
|
5335
|
-
const inc = getInc();
|
|
5336
|
-
buffer[0] = value >> 24;
|
|
5337
|
-
buffer[1] = value >> 16;
|
|
5338
|
-
buffer[2] = value >> 8;
|
|
5339
|
-
buffer[3] = value;
|
|
5340
|
-
buffer[4] = Math.floor(Math.random() * 256);
|
|
5341
|
-
buffer[5] = Math.floor(Math.random() * 256);
|
|
5342
|
-
buffer[6] = Math.floor(Math.random() * 256);
|
|
5343
|
-
buffer[7] = Math.floor(Math.random() * 256);
|
|
5344
|
-
buffer[8] = Math.floor(Math.random() * 256);
|
|
5345
|
-
buffer[11] = inc & 255;
|
|
5346
|
-
buffer[10] = inc >> 8 & 255;
|
|
5347
|
-
buffer[9] = inc >> 16 & 255;
|
|
5348
|
-
return hex(buffer);
|
|
5349
|
-
}
|
|
5350
|
-
function getInc() {
|
|
5351
|
-
return index = (index + 1) % 16777215;
|
|
5352
|
-
}
|
|
5353
|
-
|
|
5354
|
-
const snakeCase = (str) => {
|
|
5355
|
-
return getWords(str).map((word) => word.toLowerCase()).join("_");
|
|
5356
|
-
};
|
|
5357
|
-
|
|
5358
|
-
const startCase = (value) => {
|
|
5359
|
-
return getWords(value).map(capitalize).join(" ");
|
|
5360
|
-
};
|
|
5361
|
-
|
|
5362
|
-
const DEF_STR_ASSIGN_REGEXP = /\{{([A-z-_. ]*)\}}/g;
|
|
5363
|
-
const DEF_STR_ASSIGN_METHOD = (obj, key) => obj[key];
|
|
5364
|
-
function strAssign(str, obj, method = DEF_STR_ASSIGN_METHOD) {
|
|
5365
|
-
return str.replace(DEF_STR_ASSIGN_REGEXP, (match, p1) => {
|
|
5366
|
-
const key = p1.trim();
|
|
5367
|
-
const value = method(obj, key);
|
|
5368
|
-
if (value === void 0 || value === null) {
|
|
5369
|
-
return match;
|
|
5370
|
-
}
|
|
5371
|
-
return value;
|
|
5372
|
-
});
|
|
5373
|
-
}
|
|
5374
|
-
|
|
5375
|
-
function truncate(value, maxLength = 120, insignificantThreshold = 0.05) {
|
|
5376
|
-
if (!shouldTruncate(value, maxLength, insignificantThreshold)) {
|
|
5377
|
-
return value;
|
|
5378
|
-
}
|
|
5379
|
-
let truncated = value.slice(0, maxLength).trim();
|
|
5380
|
-
const lastSpace = truncated.lastIndexOf(" ");
|
|
5381
|
-
if (lastSpace > 0) {
|
|
5382
|
-
truncated = truncated.slice(0, lastSpace);
|
|
5383
|
-
}
|
|
5384
|
-
return `${truncated}...`;
|
|
5385
|
-
}
|
|
5386
|
-
function shouldTruncate(text, maxLength, insignificantThreshold) {
|
|
5387
|
-
return text.length - maxLength > maxLength * insignificantThreshold;
|
|
5388
|
-
}
|
|
5389
|
-
|
|
5390
|
-
function wrapText(value, maxLength = 30) {
|
|
5391
|
-
if (value.length > maxLength) {
|
|
5392
|
-
return value.slice(0, maxLength) + "...";
|
|
5393
|
-
}
|
|
5394
|
-
return value;
|
|
5395
|
-
}
|
|
5396
|
-
|
|
5397
|
-
export { AppError, AsyncIterableQueue, BrowserAssertionError, CancellablePromise, ColorParser, instance as EJSON, EJSON as EJSONInstance, EJSONStream, FindMean, FixedMap, FixedWeakMap, LruCache, Queue, ResourcePool, SimpleEventEmitter, SortedArray, TWEMOJI_REGEX, TimeBucket, TimeSpan, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base62, base62Fast, base64, base64ToBytes, base64url, basex, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
|
|
5462
|
+
export { AppError, AsyncIterableQueue, BrowserAssertionError, CancellablePromise, ColorParser, instance as EJSON, EJSON as EJSONInstance, EJSONStream, FindMean, FixedMap, FixedWeakMap, LruCache, Queue, ResourcePool, SimpleEventEmitter, SortedArray, TWEMOJI_REGEX, TimeBucket, TimeSpan, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base62, base62Fast, base64, base64ToBytes, base64url, basex, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, textDecoder, textEncoder, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
|
|
5398
5463
|
//# sourceMappingURL=index.mjs.map
|