umt 2.10.1 → 2.12.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/README.md +3 -2
- package/module/Advance/rangeAdvance.d.ts +1 -1
- package/module/Advance/rangeAdvance.js.map +1 -1
- package/module/Array/checkFlagAlignment.js +3 -0
- package/module/Array/checkFlagAlignment.js.map +1 -1
- package/module/Array/compact.js.map +1 -1
- package/module/Array/dualPivotQuickSort.js +4 -3
- package/module/Array/dualPivotQuickSort.js.map +1 -1
- package/module/Array/getArraysCommon.js +33 -12
- package/module/Array/getArraysCommon.js.map +1 -1
- package/module/Array/groupBy.js +1 -1
- package/module/Array/insertionSort.js +4 -10
- package/module/Array/insertionSort.js.map +1 -1
- package/module/Array/quickSort.js +4 -3
- package/module/Array/quickSort.js.map +1 -1
- package/module/Array/range.js +1 -1
- package/module/Array/range.js.map +1 -1
- package/module/Array/sortingHelpers/applyInsertionSortIfNeeded.js +2 -2
- package/module/Array/sortingHelpers/applyInsertionSortIfNeeded.js.map +1 -1
- package/module/Array/sortingHelpers/insertionSortRange.d.ts +5 -0
- package/module/Array/sortingHelpers/insertionSortRange.js +15 -0
- package/module/Array/sortingHelpers/insertionSortRange.js.map +1 -0
- package/module/Array/timSort.js +7 -5
- package/module/Array/timSort.js.map +1 -1
- package/module/Array/ultraNumberSort.js +18 -18
- package/module/Array/ultraNumberSort.js.map +1 -1
- package/module/Color/hexaToRgba.d.ts +1 -1
- package/module/Color/hexaToRgba.js +1 -1
- package/module/Consts/clock.d.ts +1 -1
- package/module/Consts/clock.js.map +1 -1
- package/module/Crypto/decodeBase58.js +4 -4
- package/module/Crypto/decodeBase58.js.map +1 -1
- package/module/Crypto/encodeBase58.js +4 -4
- package/module/Crypto/encodeBase58.js.map +1 -1
- package/module/DataStructure/priorityQueue.d.ts +4 -4
- package/module/DataStructure/priorityQueue.js +3 -2
- package/module/DataStructure/priorityQueue.js.map +1 -1
- package/module/Date/dayOfWeek.js +1 -1
- package/module/Date/format.js +1 -1
- package/module/IP/ipToBinaryString.js +1 -1
- package/module/IP/ipToBinaryString.js.map +1 -1
- package/module/IP/subnetMaskToCidr.js +1 -1
- package/module/IP/subnetMaskToCidr.js.map +1 -1
- package/module/Math/calculator/core.js +15 -5
- package/module/Math/calculator/core.js.map +1 -1
- package/module/Math/gcd.js +5 -2
- package/module/Math/gcd.js.map +1 -1
- package/module/Math/mathConverter.js +1 -1
- package/module/Math/mathConverter.js.map +1 -1
- package/module/Math/mode.js +3 -2
- package/module/Math/mode.js.map +1 -1
- package/module/Math/nCr.js +4 -1
- package/module/Math/nCr.js.map +1 -1
- package/module/Math/nPr.js +4 -1
- package/module/Math/nPr.js.map +1 -1
- package/module/Math/primeFactorization.js +5 -1
- package/module/Math/primeFactorization.js.map +1 -1
- package/module/Math/reduce.js +4 -1
- package/module/Math/reduce.js.map +1 -1
- package/module/Math/solveEquation.js +1 -1
- package/module/Math/solveEquation.js.map +1 -1
- package/module/Math/uuidv7.js +11 -14
- package/module/Math/uuidv7.js.map +1 -1
- package/module/Object/mergeDeep.js.map +1 -1
- package/module/Object/omit.js +1 -0
- package/module/Object/omit.js.map +1 -1
- package/module/Object/pickDeep.js +1 -1
- package/module/String/formatString/applyFormatter.js +1 -1
- package/module/String/formatString/applyFormatter.js.map +1 -1
- package/module/String/formatString/getValue.js +1 -1
- package/module/String/formatString/getValue.js.map +1 -1
- package/module/String/fromBase64.js +2 -1
- package/module/String/fromBase64.js.map +1 -1
- package/module/String/fuzzySearch.d.ts +2 -2
- package/module/String/fuzzySearch.js +2 -1
- package/module/String/fuzzySearch.js.map +1 -1
- package/module/String/levenshteinDistance.d.ts +2 -2
- package/module/String/levenshteinDistance.js +28 -18
- package/module/String/levenshteinDistance.js.map +1 -1
- package/module/String/padStart.d.ts +0 -1
- package/module/String/padStart.js +2 -6
- package/module/String/padStart.js.map +1 -1
- package/module/String/reverseString.js +1 -1
- package/module/String/reverseString.js.map +1 -1
- package/module/Tool/index.d.ts +1 -0
- package/module/Tool/index.js +1 -0
- package/module/Tool/index.js.map +1 -1
- package/module/Tool/unwrap.d.ts +9 -0
- package/module/Tool/unwrap.js +15 -0
- package/module/Tool/unwrap.js.map +1 -0
- package/module/Validate/array/core.js +1 -1
- package/module/Validate/core/index.js +2 -2
- package/module/Validate/index.d.ts +1 -0
- package/module/Validate/index.js +1 -0
- package/module/Validate/index.js.map +1 -1
- package/module/Validate/isDeepEqual.js.map +1 -1
- package/module/Validate/object/core.js +1 -1
- package/module/Validate/parseEmail.d.ts +14 -0
- package/module/Validate/parseEmail.js +24 -0
- package/module/Validate/parseEmail.js.map +1 -0
- package/module/Validate/string/index.d.ts +1 -1
- package/module/Validate/string/index.js +1 -1
- package/module/Validate/string/index.js.map +1 -1
- package/module/Validate/string/uuid.js +10 -11
- package/module/Validate/string/uuid.js.map +1 -1
- package/module/Validate/string/{email.d.ts → validateEmail.d.ts} +2 -1
- package/module/Validate/string/validateEmail.js +23 -0
- package/module/Validate/string/validateEmail.js.map +1 -0
- package/module/es5/Advance/rangeAdvance.d.ts +1 -1
- package/module/es5/Array/checkFlagAlignment.js +3 -0
- package/module/es5/Array/dualPivotQuickSort.js +10 -3
- package/module/es5/Array/getArraysCommon.js +45 -19
- package/module/es5/Array/groupBy.js +2 -1
- package/module/es5/Array/insertionSort.js +10 -10
- package/module/es5/Array/quickSort.js +10 -3
- package/module/es5/Array/range.js +1 -1
- package/module/es5/Array/sortingHelpers/applyInsertionSortIfNeeded.js +2 -2
- package/module/es5/Array/sortingHelpers/insertionSortRange.d.ts +5 -0
- package/module/es5/Array/sortingHelpers/insertionSortRange.js +20 -0
- package/module/es5/Array/timSort.js +13 -5
- package/module/es5/Array/ultraNumberSort.js +38 -34
- package/module/es5/Color/hexaToRgba.d.ts +1 -1
- package/module/es5/Color/hexaToRgba.js +1 -1
- package/module/es5/Consts/clock.d.ts +1 -1
- package/module/es5/Crypto/decodeBase58.js +4 -4
- package/module/es5/Crypto/encodeBase58.js +4 -4
- package/module/es5/DataStructure/priorityQueue.d.ts +4 -4
- package/module/es5/DataStructure/priorityQueue.js +3 -2
- package/module/es5/Date/dayOfWeek.js +2 -1
- package/module/es5/Date/format.js +1 -1
- package/module/es5/IP/ipToBinaryString.js +1 -1
- package/module/es5/IP/subnetMaskToCidr.js +1 -1
- package/module/es5/Math/calculator/core.js +15 -5
- package/module/es5/Math/gcd.js +5 -2
- package/module/es5/Math/mathConverter.js +1 -1
- package/module/es5/Math/mode.js +4 -4
- package/module/es5/Math/nCr.js +4 -1
- package/module/es5/Math/nPr.js +4 -1
- package/module/es5/Math/primeFactorization.js +8 -1
- package/module/es5/Math/reduce.js +8 -1
- package/module/es5/Math/solveEquation.js +1 -1
- package/module/es5/Math/uuidv7.js +13 -14
- package/module/es5/Object/omit.js +1 -0
- package/module/es5/Object/pickDeep.js +2 -1
- package/module/es5/String/formatString/applyFormatter.js +1 -1
- package/module/es5/String/formatString/getValue.js +1 -1
- package/module/es5/String/formatString/index.js +1 -1
- package/module/es5/String/fromBase64.js +2 -1
- package/module/es5/String/fuzzySearch.d.ts +2 -2
- package/module/es5/String/fuzzySearch.js +2 -1
- package/module/es5/String/hasNoLetters.js +1 -1
- package/module/es5/String/levenshteinDistance.d.ts +2 -2
- package/module/es5/String/levenshteinDistance.js +33 -30
- package/module/es5/String/padStart.d.ts +0 -1
- package/module/es5/String/padStart.js +2 -7
- package/module/es5/String/reverseString.js +1 -1
- package/module/es5/Tool/index.d.ts +1 -0
- package/module/es5/Tool/index.js +11 -0
- package/module/es5/Tool/unwrap.d.ts +9 -0
- package/module/es5/Tool/unwrap.js +20 -0
- package/module/es5/Validate/array/core.js +1 -1
- package/module/es5/Validate/core/index.js +3 -2
- package/module/es5/Validate/index.d.ts +1 -0
- package/module/es5/Validate/index.js +11 -0
- package/module/es5/Validate/object/core.js +1 -1
- package/module/es5/Validate/parseEmail.d.ts +14 -0
- package/module/es5/Validate/parseEmail.js +48 -0
- package/module/es5/Validate/string/index.d.ts +1 -1
- package/module/es5/Validate/string/index.js +4 -4
- package/module/es5/Validate/string/uuid.js +7 -4
- package/module/es5/Validate/string/{email.d.ts → validateEmail.d.ts} +2 -1
- package/module/es5/Validate/string/validateEmail.js +31 -0
- package/module/es5/tsconfig.tsbuildinfo +1 -1
- package/package.json +70 -43
- package/module/Validate/string/email.js +0 -45
- package/module/Validate/string/email.js.map +0 -1
- package/module/es5/Validate/string/email.js +0 -62
package/module/es5/Math/nPr.js
CHANGED
|
@@ -15,9 +15,12 @@ exports.nPr = void 0;
|
|
|
15
15
|
* nPr = n * (n-1) * (n-2) * ... * (n-r+1)
|
|
16
16
|
*/
|
|
17
17
|
var nPr = exports.nPr = function nPr(n, r) {
|
|
18
|
-
if (n
|
|
18
|
+
if (n < r || n < 0 || r < 0) {
|
|
19
19
|
return Number.NaN;
|
|
20
20
|
}
|
|
21
|
+
if (r === 0) {
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
21
24
|
var result = 1;
|
|
22
25
|
for (var index = 0; index < r; index++) {
|
|
23
26
|
result *= n - index;
|
|
@@ -17,7 +17,7 @@ var primeFactorization = exports.primeFactorization = function primeFactorizatio
|
|
|
17
17
|
var n = 0;
|
|
18
18
|
var copyX = x;
|
|
19
19
|
var out = [];
|
|
20
|
-
for (var index = 2; index <= copyX; index++) {
|
|
20
|
+
for (var index = 2; index * index <= copyX; index++) {
|
|
21
21
|
if (copyX % index === 0) {
|
|
22
22
|
n = 0;
|
|
23
23
|
while (copyX % index === 0) {
|
|
@@ -30,5 +30,12 @@ var primeFactorization = exports.primeFactorization = function primeFactorizatio
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
// If remaining value is greater than 1, it's a prime factor
|
|
34
|
+
if (copyX > 1) {
|
|
35
|
+
out.push({
|
|
36
|
+
number: copyX,
|
|
37
|
+
count: 1
|
|
38
|
+
});
|
|
39
|
+
}
|
|
33
40
|
return out;
|
|
34
41
|
};
|
|
@@ -18,12 +18,19 @@ var _gcd = require("./gcd");
|
|
|
18
18
|
* - gcd: greatest common divisor used for reduction
|
|
19
19
|
*/
|
|
20
20
|
var reduce = exports.reduce = function reduce(x, y) {
|
|
21
|
-
if (
|
|
21
|
+
if (y === 0) {
|
|
22
22
|
return {
|
|
23
23
|
x: Number.NaN,
|
|
24
24
|
y: Number.NaN
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
if (x === 0) {
|
|
28
|
+
return {
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 1,
|
|
31
|
+
gcd: Math.abs(y)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
27
34
|
var gcdValue = (0, _gcd.gcd)(Math.abs(x), Math.abs(y));
|
|
28
35
|
var sign = y < 0 ? -1 : 1;
|
|
29
36
|
return {
|
|
@@ -70,7 +70,7 @@ var solveEquation = exports.solveEquation = function solveEquation(coefficients,
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// Return the solution vector with values rounded to 1 decimal place
|
|
73
|
-
return solution.
|
|
73
|
+
return [].concat(solution).reverse().map(function (value) {
|
|
74
74
|
return (0, _roundOf.roundOf)(value, 1);
|
|
75
75
|
});
|
|
76
76
|
};
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.uuidv7 = void 0;
|
|
7
|
-
var _random = require("./random");
|
|
8
7
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
9
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
@@ -28,23 +27,23 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
28
27
|
var uuidv7 = exports.uuidv7 = function uuidv7() {
|
|
29
28
|
var DIGITS = "0123456789abcdef";
|
|
30
29
|
var unixTsMs = Date.now();
|
|
31
|
-
var randA = (0, _random.random)(0xfff);
|
|
32
|
-
var randBHi = (0, _random.random)(0x3fffffff);
|
|
33
|
-
var randBLo = (0, _random.random)(0xffffffff);
|
|
34
30
|
var bytes = new Uint8Array(16);
|
|
35
31
|
for (var index = 0; index < 6; index++) {
|
|
36
32
|
bytes[index] = unixTsMs >>> (5 - index) * 8 & 0xff;
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
bytes
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
bytes[
|
|
45
|
-
|
|
46
|
-
bytes[
|
|
47
|
-
|
|
34
|
+
|
|
35
|
+
// Generate 10 random bytes for the rest
|
|
36
|
+
var randomBytes = new Uint8Array(10);
|
|
37
|
+
globalThis.crypto.getRandomValues(randomBytes);
|
|
38
|
+
|
|
39
|
+
// Version 7 (0x70) + 4 bits from randomBytes[0]
|
|
40
|
+
bytes[6] = 0x70 | randomBytes[0] & 0x0f;
|
|
41
|
+
// Random byte
|
|
42
|
+
bytes[7] = randomBytes[1];
|
|
43
|
+
// Variant 2 (0x80) + 6 bits from randomBytes[2]
|
|
44
|
+
bytes[8] = 0x80 | randomBytes[2] & 0x3f;
|
|
45
|
+
// Remaining random bytes
|
|
46
|
+
bytes.set(randomBytes.subarray(3), 9);
|
|
48
47
|
var uuid = "";
|
|
49
48
|
var _iterator = _createForOfIteratorHelper(bytes.entries()),
|
|
50
49
|
_step;
|
|
@@ -57,7 +57,8 @@ var pickDeep = exports.pickDeep = function pickDeep(object) {
|
|
|
57
57
|
if (index === parts.length - 1) {
|
|
58
58
|
target[part] = current[part];
|
|
59
59
|
} else {
|
|
60
|
-
|
|
60
|
+
var _target$part;
|
|
61
|
+
target[part] = (_target$part = target[part]) !== null && _target$part !== void 0 ? _target$part : {};
|
|
61
62
|
current = current[part];
|
|
62
63
|
target = target[part];
|
|
63
64
|
}
|
|
@@ -39,7 +39,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
39
39
|
* applyFormatter("test", "invalid!@#", {}) // → "test"
|
|
40
40
|
*/
|
|
41
41
|
function applyFormatter(value, formatterString, formatters) {
|
|
42
|
-
var match =
|
|
42
|
+
var match = /^(\w+)(?:\(([^)]*)\))?$/.exec(formatterString);
|
|
43
43
|
if (!match) {
|
|
44
44
|
return String(value);
|
|
45
45
|
}
|
|
@@ -46,7 +46,7 @@ function getValue(object, path) {
|
|
|
46
46
|
try {
|
|
47
47
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
48
|
var part = _step.value;
|
|
49
|
-
var arrayMatch =
|
|
49
|
+
var arrayMatch = /^(.+?)\[(-?\d+)\]$/.exec(part);
|
|
50
50
|
if (arrayMatch) {
|
|
51
51
|
var _arrayMatch = _slicedToArray(arrayMatch, 3),
|
|
52
52
|
key = _arrayMatch[1],
|
|
@@ -128,7 +128,7 @@ function formatString(template, dataOrFirstValue, optionsOrSecondValue) {
|
|
|
128
128
|
var _pathAndFormatter$spl = pathAndFormatter.split(":"),
|
|
129
129
|
_pathAndFormatter$spl2 = _toArray(_pathAndFormatter$spl),
|
|
130
130
|
path = _pathAndFormatter$spl2[0],
|
|
131
|
-
formatterParts = _pathAndFormatter$spl2.slice(1);
|
|
131
|
+
formatterParts = _arrayLikeToArray(_pathAndFormatter$spl2).slice(1);
|
|
132
132
|
var formatterString = formatterParts.join(":");
|
|
133
133
|
var value;
|
|
134
134
|
if (Array.isArray(data)) {
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.fromBase64 = void 0;
|
|
7
|
+
var _unwrap = require("@/Tool/unwrap");
|
|
7
8
|
/**
|
|
8
9
|
* Converts Base64 to string
|
|
9
10
|
* @param {string} base64String - Base64 encoded string
|
|
@@ -16,7 +17,7 @@ var fromBase64 = exports.fromBase64 = function fromBase64(base64String) {
|
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
19
|
return new TextDecoder().decode(Uint8Array.from(atob(base64String).split("").map(function (c) {
|
|
19
|
-
return c.codePointAt(0);
|
|
20
|
+
return (0, _unwrap.unwrap)(c.codePointAt(0), "panic: invalid base64 string");
|
|
20
21
|
})));
|
|
21
22
|
} catch (_unused) {
|
|
22
23
|
throw new Error("Invalid Base64 string");
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* fuzzySearch("hello", ["hello", "world", "helo", "help"]);
|
|
9
9
|
* // [{ item: "hello", score: 1 }, { item: "helo", score: 0.8 }, { item: "help", score: 0.6 }]
|
|
10
10
|
*/
|
|
11
|
-
export declare const fuzzySearch: (query: string, items: string[], threshold?: number) =>
|
|
11
|
+
export declare const fuzzySearch: (query: string, items: string[], threshold?: number) => {
|
|
12
12
|
item: string;
|
|
13
13
|
score: number;
|
|
14
|
-
}
|
|
14
|
+
}[];
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fuzzySearch = void 0;
|
|
7
7
|
var _levenshteinDistance = require("./levenshteinDistance");
|
|
8
|
+
var _quickSort = require("@/Array/quickSort");
|
|
8
9
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
9
10
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -44,7 +45,7 @@ var fuzzySearch = exports.fuzzySearch = function fuzzySearch(query, items) {
|
|
|
44
45
|
} finally {
|
|
45
46
|
_iterator.f();
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
+
return (0, _quickSort.quickSort)(results, function (a, b) {
|
|
48
49
|
return b.score - a.score;
|
|
49
50
|
});
|
|
50
51
|
};
|
|
@@ -19,6 +19,6 @@ var hasNoLetters = exports.hasNoLetters = function hasNoLetters(text) {
|
|
|
19
19
|
// Uses Unicode pattern:
|
|
20
20
|
// \p{L} matches any Unicode letter
|
|
21
21
|
// [^\p{L}]* matches zero or more non-letter characters
|
|
22
|
-
var nonTextPattern = /^(?:[\0-@\[-`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u036F\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482-\u0489\u0530\u0557\u0558\u055A-\u055F\u0589-\u05CF\u05EB-\u05EE\u05F3-\u061F\u064B-\u066D\u0670\u06D4\u06D6-\u06E4\u06E7-\u06ED\u06F0-\u06F9\u06FD\u06FE\u0700-\u070F\u0711\u0730-\u074C\u07A6-\u07B0\u07B2-\u07C9\u07EB-\u07F3\u07F6-\u07F9\u07FB-\u07FF\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u083F\u0859-\u085F\u086B-\u086F\u0888\
|
|
22
|
+
var nonTextPattern = /^(?:[\0-@\[-`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u036F\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482-\u0489\u0530\u0557\u0558\u055A-\u055F\u0589-\u05CF\u05EB-\u05EE\u05F3-\u061F\u064B-\u066D\u0670\u06D4\u06D6-\u06E4\u06E7-\u06ED\u06F0-\u06F9\u06FD\u06FE\u0700-\u070F\u0711\u0730-\u074C\u07A6-\u07B0\u07B2-\u07C9\u07EB-\u07F3\u07F6-\u07F9\u07FB-\u07FF\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u083F\u0859-\u085F\u086B-\u086F\u0888\u0890-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962-\u0970\u0981-\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA-\u09BC\u09BE-\u09CD\u09CF-\u09DB\u09DE\u09E2-\u09EF\u09F2-\u09FB\u09FD-\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A-\u0A58\u0A5D\u0A5F-\u0A71\u0A75-\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA-\u0ABC\u0ABE-\u0ACF\u0AD1-\u0ADF\u0AE2-\u0AF8\u0AFA-\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A-\u0B3C\u0B3E-\u0B5B\u0B5E\u0B62-\u0B70\u0B72-\u0B82\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BCF\u0BD1-\u0C04\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C3E-\u0C57\u0C5B\u0C5E\u0C5F\u0C62-\u0C7F\u0C81-\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA-\u0CBC\u0CBE-\u0CDB\u0CDF\u0CE2-\u0CF0\u0CF3-\u0D03\u0D0D\u0D11\u0D3B\u0D3C\u0D3E-\u0D4D\u0D4F-\u0D53\u0D57-\u0D5E\u0D62-\u0D79\u0D80-\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0E00\u0E31\u0E34-\u0E3F\u0E47-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EB1\u0EB4-\u0EBC\u0EBE\u0EBF\u0EC5\u0EC7-\u0EDB\u0EE0-\u0EFF\u0F01-\u0F3F\u0F48\u0F6D-\u0F87\u0F8D-\u0FFF\u102B-\u103E\u1040-\u104F\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16F0\u16F9-\u16FF\u1712-\u171E\u1732-\u173F\u1752-\u175F\u176D\u1771-\u177F\u17B4-\u17D6\u17D8-\u17DB\u17DD-\u181F\u1879-\u187F\u1885\u1886\u18A9\u18AB-\u18AF\u18F6-\u18FF\u191F-\u194F\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19FF\u1A17-\u1A1F\u1A55-\u1AA6\u1AA8-\u1B04\u1B34-\u1B44\u1B4D-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BFF\u1C24-\u1C4C\u1C50-\u1C59\u1C7E\u1C7F\u1C8B-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1CFB-\u1CFF\u1DC0-\u1DFF\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u2182\u2185-\u2BFF\u2CE5-\u2CEA\u2CEF-\u2CF1\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7F\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF-\u2E2E\u2E30-\u3004\u3007-\u3030\u3036-\u303A\u303D-\u3040\u3097-\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA620-\uA629\uA62C-\uA63F\uA66F-\uA67E\uA69E\uA69F\uA6E6-\uA716\uA720\uA721\uA789\uA78A\uA7DD-\uA7F0\uA802\uA806\uA80B\uA823-\uA83F\uA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EAF]|\uD87A[\uDFE1-\uDFEF]|\uD87B[\uDE5E-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDF4F]|\uD88D[\uDC7A-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*$/;
|
|
23
23
|
return nonTextPattern.test(text);
|
|
24
24
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculates the Levenshtein distance between two strings
|
|
3
3
|
* Returns the minimum number of single-character edits (insertions, deletions, or substitutions)
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param string1 - First string to compare
|
|
5
|
+
* @param string2 - Second string to compare
|
|
6
6
|
* @returns The Levenshtein distance
|
|
7
7
|
*/
|
|
8
8
|
export declare const levenshteinDistance: (string1: string, string2: string) => number;
|
|
@@ -7,15 +7,16 @@ exports.levenshteinDistance = void 0;
|
|
|
7
7
|
/**
|
|
8
8
|
* Calculates the Levenshtein distance between two strings
|
|
9
9
|
* Returns the minimum number of single-character edits (insertions, deletions, or substitutions)
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
10
|
+
* @param string1 - First string to compare
|
|
11
|
+
* @param string2 - Second string to compare
|
|
12
12
|
* @returns The Levenshtein distance
|
|
13
13
|
*/
|
|
14
|
-
var
|
|
14
|
+
var _levenshteinDistance = exports.levenshteinDistance = function levenshteinDistance(string1, string2) {
|
|
15
|
+
if (string1 === string2) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
15
18
|
var length1 = string1.length;
|
|
16
19
|
var length2 = string2.length;
|
|
17
|
-
|
|
18
|
-
// Return the length of the other string if one is empty
|
|
19
20
|
if (length1 === 0) {
|
|
20
21
|
return length2;
|
|
21
22
|
}
|
|
@@ -23,36 +24,38 @@ var levenshteinDistance = exports.levenshteinDistance = function levenshteinDist
|
|
|
23
24
|
return length1;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
27
|
+
// Ensure string1 is the shorter string to minimize space complexity to O(min(N, M))
|
|
28
|
+
if (length1 > length2) {
|
|
29
|
+
return _levenshteinDistance(string2, string1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Create a single row array to store distances
|
|
33
|
+
// We only need the current row and the previous diagonal value
|
|
34
|
+
// eslint-disable-next-line unicorn/no-new-array
|
|
35
|
+
var row = new Array(length1 + 1);
|
|
36
36
|
|
|
37
|
-
// Initialize first
|
|
37
|
+
// Initialize first row (0 to length1)
|
|
38
38
|
for (var index = 0; index <= length1; index++) {
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
for (var _index = 0; _index <= length2; _index++) {
|
|
42
|
-
matrix[0][_index] = _index;
|
|
39
|
+
row[index] = index;
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
//
|
|
46
|
-
for (var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
42
|
+
// Iterate through each character of string2
|
|
43
|
+
for (var _index = 1; _index <= length2; _index++) {
|
|
44
|
+
var previousDiagonal = row[0]; // Stores the value of matrix[i-1][j-1]
|
|
45
|
+
row[0] = _index; // Update first element for the new row (matrix[0][j])
|
|
46
|
+
|
|
47
|
+
var char2 = string2[_index - 1];
|
|
48
|
+
for (var _index2 = 1; _index2 <= length1; _index2++) {
|
|
49
|
+
var temporary = row[_index2]; // Store current value to become prevDiagonal for next iteration
|
|
50
|
+
var cost = string1[_index2 - 1] === char2 ? 0 : 1;
|
|
51
|
+
row[_index2] = Math.min(row[_index2] + 1,
|
|
52
|
+
// deletion (value from previous row, same column)
|
|
53
|
+
row[_index2 - 1] + 1,
|
|
54
|
+
// insertion (value from current row, previous column)
|
|
55
|
+
previousDiagonal + cost // substitution (value from previous row, previous column)
|
|
54
56
|
);
|
|
57
|
+
previousDiagonal = temporary;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
|
-
return
|
|
60
|
+
return row[length1];
|
|
58
61
|
};
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* @param {number} targetLength - The target length after padding
|
|
6
6
|
* @param {string} padString - The string to use for padding
|
|
7
7
|
* @returns {string} The padded string
|
|
8
|
-
* @throws {Error} If padString is empty
|
|
9
8
|
* @example
|
|
10
9
|
* ```typescript
|
|
11
10
|
* padStart("123", 5, "0"); // Returns: "00123"
|
|
@@ -11,7 +11,6 @@ exports.padStart = void 0;
|
|
|
11
11
|
* @param {number} targetLength - The target length after padding
|
|
12
12
|
* @param {string} padString - The string to use for padding
|
|
13
13
|
* @returns {string} The padded string
|
|
14
|
-
* @throws {Error} If padString is empty
|
|
15
14
|
* @example
|
|
16
15
|
* ```typescript
|
|
17
16
|
* padStart("123", 5, "0"); // Returns: "00123"
|
|
@@ -19,12 +18,8 @@ exports.padStart = void 0;
|
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
20
|
var padStart = exports.padStart = function padStart(string_, targetLength, padString) {
|
|
22
|
-
if
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Return original string if it's longer than target length
|
|
27
|
-
if (string_.length >= targetLength) {
|
|
21
|
+
// Return original string if padString is empty or string is already long enough
|
|
22
|
+
if (padString === "" || string_.length >= targetLength) {
|
|
28
23
|
return string_;
|
|
29
24
|
}
|
|
30
25
|
var padding = "";
|
|
@@ -11,5 +11,5 @@ exports.reverseString = void 0;
|
|
|
11
11
|
* @example reverseString("Hello"); // "olleH"
|
|
12
12
|
*/
|
|
13
13
|
var reverseString = exports.reverseString = function reverseString(_char) {
|
|
14
|
-
return _char.split("").
|
|
14
|
+
return _char.split("").reverse().join("");
|
|
15
15
|
};
|
package/module/es5/Tool/index.js
CHANGED
|
@@ -35,4 +35,15 @@ Object.keys(_pipe).forEach(function (key) {
|
|
|
35
35
|
return _pipe[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
});
|
|
39
|
+
var _unwrap = require("./unwrap");
|
|
40
|
+
Object.keys(_unwrap).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _unwrap[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _unwrap[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
38
49
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unwraps a value that may be undefined or null, throwing an error if the value is absent
|
|
3
|
+
* @template T The type of the value to unwrap
|
|
4
|
+
* @param value The value to unwrap (may be undefined or null)
|
|
5
|
+
* @param message The error message to throw if the value is absent
|
|
6
|
+
* @returns The unwrapped value of type T
|
|
7
|
+
* @throws {Error} If the value is undefined or null
|
|
8
|
+
*/
|
|
9
|
+
export declare const unwrap: <T>(value: T | undefined | null, message: string) => T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unwrap = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Unwraps a value that may be undefined or null, throwing an error if the value is absent
|
|
9
|
+
* @template T The type of the value to unwrap
|
|
10
|
+
* @param value The value to unwrap (may be undefined or null)
|
|
11
|
+
* @param message The error message to throw if the value is absent
|
|
12
|
+
* @returns The unwrapped value of type T
|
|
13
|
+
* @throws {Error} If the value is undefined or null
|
|
14
|
+
*/
|
|
15
|
+
var unwrap = exports.unwrap = function unwrap(value, message) {
|
|
16
|
+
if (value !== undefined && value !== null) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
throw new Error(message);
|
|
20
|
+
};
|
|
@@ -27,7 +27,7 @@ var core = exports.core = function core(type) {
|
|
|
27
27
|
if (_typeof(value) !== type) {
|
|
28
28
|
return {
|
|
29
29
|
validate: false,
|
|
30
|
-
message: message
|
|
30
|
+
message: message !== null && message !== void 0 ? message : "",
|
|
31
31
|
type: type
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -37,9 +37,10 @@ var core = exports.core = function core(type) {
|
|
|
37
37
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
38
|
var validate = _step.value;
|
|
39
39
|
if (!validate.validate(value)) {
|
|
40
|
+
var _validate$message;
|
|
40
41
|
return {
|
|
41
42
|
validate: false,
|
|
42
|
-
message: validate.message
|
|
43
|
+
message: (_validate$message = validate.message) !== null && _validate$message !== void 0 ? _validate$message : "",
|
|
43
44
|
type: type
|
|
44
45
|
};
|
|
45
46
|
}
|
|
@@ -233,4 +233,15 @@ Object.keys(_isValueNaN).forEach(function (key) {
|
|
|
233
233
|
return _isValueNaN[key];
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
|
+
});
|
|
237
|
+
var _parseEmail = require("./parseEmail");
|
|
238
|
+
Object.keys(_parseEmail).forEach(function (key) {
|
|
239
|
+
if (key === "default" || key === "__esModule") return;
|
|
240
|
+
if (key in exports && exports[key] === _parseEmail[key]) return;
|
|
241
|
+
Object.defineProperty(exports, key, {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function get() {
|
|
244
|
+
return _parseEmail[key];
|
|
245
|
+
}
|
|
246
|
+
});
|
|
236
247
|
});
|
|
@@ -24,7 +24,7 @@ var object = exports.object = function object() {
|
|
|
24
24
|
if (!(0, _isDictionaryObject.isDictionaryObject)(value)) {
|
|
25
25
|
return {
|
|
26
26
|
validate: false,
|
|
27
|
-
message: message
|
|
27
|
+
message: message !== null && message !== void 0 ? message : "",
|
|
28
28
|
// biome-ignore lint/suspicious/noExplicitAny: Type assertion needed for return type compatibility
|
|
29
29
|
type: value
|
|
30
30
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ParseEmailLevel = "basic" | "rfc822" | "rfc2822" | "rfc5321" | "rfc5322";
|
|
2
|
+
export interface ParseEmailOptions {
|
|
3
|
+
level: ParseEmailLevel;
|
|
4
|
+
}
|
|
5
|
+
export declare const parseEmail: ({ email, options, }: {
|
|
6
|
+
email: string;
|
|
7
|
+
options: ParseEmailOptions;
|
|
8
|
+
}) => {
|
|
9
|
+
valid: boolean;
|
|
10
|
+
parts?: {
|
|
11
|
+
local: string;
|
|
12
|
+
domain: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.parseEmail = void 0;
|
|
8
|
+
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)(>|$)/g, function (e, r, t) { if ("" === t) return e; var p = o[r]; return Array.isArray(p) ? "$" + p.join("$") : "number" == typeof p ? "$" + p : ""; })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
|
|
9
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
10
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
11
|
+
var EMAIL_PATTERNS = {
|
|
12
|
+
basic: /*#__PURE__*/_wrapRegExp(/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+)@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/, {
|
|
13
|
+
local: 1,
|
|
14
|
+
domain: 2
|
|
15
|
+
}),
|
|
16
|
+
rfc822: /*#__PURE__*/_wrapRegExp(/^(?:\s|\((?:[^()\\]|\\[\s\S])*(?:\((?:[^()\\]|\\[\s\S])*\)(?:[^()\\]|\\[\s\S])*)*\))*("(?:[^"\\]|\\[\s\S]){0,62}"|[a-zA-Z0-9!#$%&'*/=?^_`{|}~-]{1,64}(?:\.[a-zA-Z0-9!#$%&'*/=?^_`{|}~-]+)*)(?:\s|\((?:[^()\\]|\\[\s\S])*(?:\((?:[^()\\]|\\[\s\S])*\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])?)+|\[(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}|IPv6:[0-9a-fA-F:]+)\])(?:\s|\((?:[^()\\]|\\[\s\S])*(?:\((?:[^()\\]|\\[\s\S])*\)(?:[^()\\]|\\[\s\S])*)*\))*$/, {
|
|
29
|
+
local: 1,
|
|
30
|
+
domain: 2
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
var parseEmail = exports.parseEmail = function parseEmail(_ref) {
|
|
34
|
+
var email = _ref.email,
|
|
35
|
+
options = _ref.options;
|
|
36
|
+
var level = options.level;
|
|
37
|
+
var pattern = EMAIL_PATTERNS[level];
|
|
38
|
+
var match = pattern.exec(email);
|
|
39
|
+
return {
|
|
40
|
+
valid: match !== null,
|
|
41
|
+
parts: match !== null && match !== void 0 && match.groups ? {
|
|
42
|
+
// biome-ignore lint/complexity/useLiteralKeys: Literal keys are used for group names
|
|
43
|
+
local: match.groups["local"],
|
|
44
|
+
// biome-ignore lint/complexity/useLiteralKeys: Literal keys are used for group names
|
|
45
|
+
domain: match.groups["domain"]
|
|
46
|
+
} : undefined
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -14,14 +14,14 @@ Object.keys(_core).forEach(function (key) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
17
|
+
var _validateEmail = require("./validateEmail");
|
|
18
|
+
Object.keys(_validateEmail).forEach(function (key) {
|
|
19
19
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] ===
|
|
20
|
+
if (key in exports && exports[key] === _validateEmail[key]) return;
|
|
21
21
|
Object.defineProperty(exports, key, {
|
|
22
22
|
enumerable: true,
|
|
23
23
|
get: function get() {
|
|
24
|
-
return
|
|
24
|
+
return _validateEmail[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|