umt 2.6.0 → 2.8.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 +25 -0
- package/module/Crypto/decodeBase32.d.ts +7 -0
- package/module/Crypto/decodeBase32.js +27 -0
- package/module/Crypto/decodeBase32.js.map +1 -0
- package/module/Crypto/decodeBase32ToString.d.ts +7 -0
- package/module/Crypto/decodeBase32ToString.js +11 -0
- package/module/Crypto/decodeBase32ToString.js.map +1 -0
- package/module/Crypto/decodeBase58.d.ts +7 -0
- package/module/Crypto/decodeBase58.js +34 -0
- package/module/Crypto/decodeBase58.js.map +1 -0
- package/module/Crypto/decodeBase58ToString.d.ts +7 -0
- package/module/Crypto/decodeBase58ToString.js +11 -0
- package/module/Crypto/decodeBase58ToString.js.map +1 -0
- package/module/Crypto/encodeBase32.d.ts +7 -0
- package/module/Crypto/encodeBase32.js +28 -0
- package/module/Crypto/encodeBase32.js.map +1 -0
- package/module/Crypto/encodeBase58.d.ts +7 -0
- package/module/Crypto/encodeBase58.js +29 -0
- package/module/Crypto/encodeBase58.js.map +1 -0
- package/module/Crypto/index.d.ts +6 -0
- package/module/Crypto/index.js +7 -0
- package/module/Crypto/index.js.map +1 -0
- package/module/DataStructure/index.d.ts +1 -0
- package/module/DataStructure/index.js +2 -0
- package/module/DataStructure/index.js.map +1 -0
- package/module/DataStructure/priorityQueue.d.ts +241 -0
- package/module/DataStructure/priorityQueue.js +327 -0
- package/module/DataStructure/priorityQueue.js.map +1 -0
- package/module/Math/correlationCoefficient.d.ts +11 -0
- package/module/Math/correlationCoefficient.js +40 -0
- package/module/Math/correlationCoefficient.js.map +1 -0
- package/module/Math/index.d.ts +3 -0
- package/module/Math/index.js +3 -0
- package/module/Math/index.js.map +1 -1
- package/module/Math/mode.d.ts +10 -0
- package/module/Math/mode.js +31 -0
- package/module/Math/mode.js.map +1 -0
- package/module/Math/percentile.d.ts +11 -0
- package/module/Math/percentile.js +31 -0
- package/module/Math/percentile.js.map +1 -0
- package/module/Math/solveEquation.js +1 -1
- package/module/Math/solveEquation.js.map +1 -1
- package/module/String/fuzzySearch.d.ts +14 -0
- package/module/String/fuzzySearch.js +27 -0
- package/module/String/fuzzySearch.js.map +1 -0
- package/module/String/index.d.ts +4 -0
- package/module/String/index.js +4 -0
- package/module/String/index.js.map +1 -1
- package/module/String/reverseString.js +1 -1
- package/module/String/reverseString.js.map +1 -1
- package/module/String/slugify.d.ts +10 -0
- package/module/String/slugify.js +21 -0
- package/module/String/slugify.js.map +1 -0
- package/module/String/truncate.d.ts +12 -0
- package/module/String/truncate.js +21 -0
- package/module/String/truncate.js.map +1 -0
- package/module/String/unescapeHtml.d.ts +17 -0
- package/module/String/unescapeHtml.js +45 -0
- package/module/String/unescapeHtml.js.map +1 -0
- 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.d.ts +28 -0
- package/module/Validate/isDeepEqual.js +148 -0
- package/module/Validate/isDeepEqual.js.map +1 -0
- package/module/Validate/isNode.js +3 -2
- package/module/Validate/isNode.js.map +1 -1
- package/module/Validate/string/email.js +8 -0
- package/module/Validate/string/email.js.map +1 -1
- package/module/es5/Crypto/decodeBase32.d.ts +7 -0
- package/module/es5/Crypto/decodeBase32.js +44 -0
- package/module/es5/Crypto/decodeBase32ToString.d.ts +7 -0
- package/module/es5/Crypto/decodeBase32ToString.js +16 -0
- package/module/es5/Crypto/decodeBase58.d.ts +7 -0
- package/module/es5/Crypto/decodeBase58.js +63 -0
- package/module/es5/Crypto/decodeBase58ToString.d.ts +7 -0
- package/module/es5/Crypto/decodeBase58ToString.js +16 -0
- package/module/es5/Crypto/encodeBase32.d.ts +7 -0
- package/module/es5/Crypto/encodeBase32.js +45 -0
- package/module/es5/Crypto/encodeBase58.d.ts +7 -0
- package/module/es5/Crypto/encodeBase58.js +55 -0
- package/module/es5/Crypto/index.d.ts +6 -0
- package/module/es5/Crypto/index.js +71 -0
- package/module/es5/DataStructure/index.d.ts +1 -0
- package/module/es5/DataStructure/index.js +16 -0
- package/module/es5/DataStructure/priorityQueue.d.ts +241 -0
- package/module/es5/DataStructure/priorityQueue.js +405 -0
- package/module/es5/Error/retry.js +2 -2
- package/module/es5/Math/correlationCoefficient.d.ts +11 -0
- package/module/es5/Math/correlationCoefficient.js +63 -0
- package/module/es5/Math/index.d.ts +3 -0
- package/module/es5/Math/index.js +33 -0
- package/module/es5/Math/mode.d.ts +10 -0
- package/module/es5/Math/mode.js +67 -0
- package/module/es5/Math/percentile.d.ts +11 -0
- package/module/es5/Math/percentile.js +42 -0
- package/module/es5/Math/solveEquation.js +1 -1
- package/module/es5/String/fuzzySearch.d.ts +14 -0
- package/module/es5/String/fuzzySearch.js +50 -0
- package/module/es5/String/index.d.ts +4 -0
- package/module/es5/String/index.js +44 -0
- package/module/es5/String/reverseString.js +1 -1
- package/module/es5/String/slugify.d.ts +10 -0
- package/module/es5/String/slugify.js +18 -0
- package/module/es5/String/truncate.d.ts +12 -0
- package/module/es5/String/truncate.js +27 -0
- package/module/es5/String/unescapeHtml.d.ts +17 -0
- package/module/es5/String/unescapeHtml.js +51 -0
- package/module/es5/Validate/index.d.ts +1 -0
- package/module/es5/Validate/index.js +11 -0
- package/module/es5/Validate/isDeepEqual.d.ts +28 -0
- package/module/es5/Validate/isDeepEqual.js +232 -0
- package/module/es5/Validate/isNode.js +5 -2
- package/module/es5/Validate/string/email.js +10 -0
- package/module/es5/index.d.ts +2 -0
- package/module/es5/index.js +22 -0
- package/module/es5/tsconfig.tsbuildinfo +1 -1
- package/module/index.d.ts +2 -0
- package/module/index.js +2 -0
- package/module/index.js.map +1 -1
- package/package.json +31 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/String/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/String/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverseString.js","sourceRoot":"","sources":["../../src/String/reverseString.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"reverseString.js","sourceRoot":"","sources":["../../src/String/reverseString.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string to a URL-friendly slug
|
|
3
|
+
* @param str - The string to convert
|
|
4
|
+
* @returns The slugified string
|
|
5
|
+
* @example
|
|
6
|
+
* slugify("Hello World!"); // "hello-world"
|
|
7
|
+
* slugify("This is a Test"); // "this-is-a-test"
|
|
8
|
+
* slugify("Japanese: こんにちは"); // "japanese"
|
|
9
|
+
*/
|
|
10
|
+
export declare const slugify: (string_: string) => string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string to a URL-friendly slug
|
|
3
|
+
* @param str - The string to convert
|
|
4
|
+
* @returns The slugified string
|
|
5
|
+
* @example
|
|
6
|
+
* slugify("Hello World!"); // "hello-world"
|
|
7
|
+
* slugify("This is a Test"); // "this-is-a-test"
|
|
8
|
+
* slugify("Japanese: こんにちは"); // "japanese"
|
|
9
|
+
*/
|
|
10
|
+
export const slugify = (string_) => {
|
|
11
|
+
return string_
|
|
12
|
+
.normalize("NFD")
|
|
13
|
+
.replaceAll(/[\u0300-\u036F]/g, "")
|
|
14
|
+
.toLowerCase()
|
|
15
|
+
.replaceAll(/[^\w\s-]/g, "-")
|
|
16
|
+
.replaceAll(/\s+/g, "-")
|
|
17
|
+
.replaceAll(/_+/g, "-")
|
|
18
|
+
.replaceAll(/-+/g, "-")
|
|
19
|
+
.replaceAll(/^-+|-+$/g, "");
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=slugify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugify.js","sourceRoot":"","sources":["../../src/String/slugify.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAU,EAAE;IACjD,OAAO,OAAO;SACX,SAAS,CAAC,KAAK,CAAC;SAChB,UAAU,CAAC,kBAAkB,EAAE,EAAE,CAAC;SAClC,WAAW,EAAE;SACb,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC;SAC5B,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC;SACvB,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC;SACtB,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC;SACtB,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate a string to a specified length
|
|
3
|
+
* @param str - The string to truncate
|
|
4
|
+
* @param length - The maximum length
|
|
5
|
+
* @param suffix - The suffix to add when truncating (default: "...")
|
|
6
|
+
* @returns The truncated string
|
|
7
|
+
* @example
|
|
8
|
+
* truncate("Hello World", 5); // "Hello..."
|
|
9
|
+
* truncate("Hello World", 5, "~"); // "Hello~"
|
|
10
|
+
* truncate("Hello", 10); // "Hello"
|
|
11
|
+
*/
|
|
12
|
+
export declare const truncate: (string_: string, length: number, suffix?: string) => string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate a string to a specified length
|
|
3
|
+
* @param str - The string to truncate
|
|
4
|
+
* @param length - The maximum length
|
|
5
|
+
* @param suffix - The suffix to add when truncating (default: "...")
|
|
6
|
+
* @returns The truncated string
|
|
7
|
+
* @example
|
|
8
|
+
* truncate("Hello World", 5); // "Hello..."
|
|
9
|
+
* truncate("Hello World", 5, "~"); // "Hello~"
|
|
10
|
+
* truncate("Hello", 10); // "Hello"
|
|
11
|
+
*/
|
|
12
|
+
export const truncate = (string_, length, suffix = "...") => {
|
|
13
|
+
if (length < 0) {
|
|
14
|
+
throw new Error("Length must be non-negative");
|
|
15
|
+
}
|
|
16
|
+
if (string_.length <= length) {
|
|
17
|
+
return string_;
|
|
18
|
+
}
|
|
19
|
+
return string_.slice(0, length) + suffix;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=truncate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.js","sourceRoot":"","sources":["../../src/String/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,OAAe,EACf,MAAc,EACd,MAAM,GAAG,KAAK,EACN,EAAE;IACV,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;AAC3C,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unescapes HTML entities in a string
|
|
3
|
+
* @param string_ - The string to unescape
|
|
4
|
+
* @returns The unescaped string with HTML entities converted back to their original characters
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* unescapeHtml("<script>alert("Hello");</script>");
|
|
8
|
+
* // Returns: "<script>alert("Hello");</script>"
|
|
9
|
+
*
|
|
10
|
+
* unescapeHtml("Tom & Jerry");
|
|
11
|
+
* // Returns: "Tom & Jerry"
|
|
12
|
+
*
|
|
13
|
+
* unescapeHtml("5 < 10 && 10 > 5");
|
|
14
|
+
* // Returns: "5 < 10 && 10 > 5"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const unescapeHtml: (string_: string) => string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML entities map for unescaping
|
|
3
|
+
*/
|
|
4
|
+
const htmlUnescapeMap = {
|
|
5
|
+
"&": "&",
|
|
6
|
+
"<": "<",
|
|
7
|
+
">": ">",
|
|
8
|
+
""": '"',
|
|
9
|
+
"'": "'",
|
|
10
|
+
"'": "'",
|
|
11
|
+
"/": "/",
|
|
12
|
+
"`": "`",
|
|
13
|
+
"=": "=",
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Unescapes HTML entities in a string
|
|
17
|
+
* @param string_ - The string to unescape
|
|
18
|
+
* @returns The unescaped string with HTML entities converted back to their original characters
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* unescapeHtml("<script>alert("Hello");</script>");
|
|
22
|
+
* // Returns: "<script>alert("Hello");</script>"
|
|
23
|
+
*
|
|
24
|
+
* unescapeHtml("Tom & Jerry");
|
|
25
|
+
* // Returns: "Tom & Jerry"
|
|
26
|
+
*
|
|
27
|
+
* unescapeHtml("5 < 10 && 10 > 5");
|
|
28
|
+
* // Returns: "5 < 10 && 10 > 5"
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const unescapeHtml = (string_) => {
|
|
32
|
+
const entityRegex = /&(?:amp|lt|gt|quot|#39|#x27|#x2F|#x60|#x3D);|&#(\d*);|&#x([0-9a-fA-F]*);/g;
|
|
33
|
+
return string_.replaceAll(entityRegex, (match, dec, hex) => {
|
|
34
|
+
if (dec !== undefined) {
|
|
35
|
+
const codePoint = Number.parseInt(dec, 10);
|
|
36
|
+
return Number.isNaN(codePoint) ? match : String.fromCodePoint(codePoint);
|
|
37
|
+
}
|
|
38
|
+
if (hex !== undefined) {
|
|
39
|
+
const codePoint = Number.parseInt(hex, 16);
|
|
40
|
+
return Number.isNaN(codePoint) ? match : String.fromCodePoint(codePoint);
|
|
41
|
+
}
|
|
42
|
+
return htmlUnescapeMap[match];
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=unescapeHtml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unescapeHtml.js","sourceRoot":"","sources":["../../src/String/unescapeHtml.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,eAAe,GAA2B;IAC9C,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,GAAG;IACb,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE;IACtD,MAAM,WAAW,GACf,2EAA2E,CAAC;IAE9E,OAAO,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACzD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/module/Validate/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Validate/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,iBAAiB;AACjB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Validate/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,iBAAiB;AACjB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for isDeepEqual comparison
|
|
3
|
+
*/
|
|
4
|
+
export interface IsDeepEqualOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to ignore array order when comparing arrays
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
strictOrder?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Performs a deep equality comparison between two values
|
|
13
|
+
*
|
|
14
|
+
* @param a - First value to compare
|
|
15
|
+
* @param b - Second value to compare
|
|
16
|
+
* @param options - Comparison options
|
|
17
|
+
* @returns true if values are deeply equal, false otherwise
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* isDeepEqual({ a: 1, b: [2, 3] }, { b: [2, 3], a: 1 }); // true
|
|
22
|
+
* isDeepEqual([1, 2, 3], [3, 2, 1]); // false
|
|
23
|
+
* isDeepEqual([1, 2, 3], [3, 2, 1], { strictOrder: false }); // true
|
|
24
|
+
* isDeepEqual(new Set([1, 2]), new Set([2, 1])); // true
|
|
25
|
+
* isDeepEqual(new Map([['a', 1]]), new Map([['a', 1]])); // true
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function isDeepEqual(a: unknown, b: unknown, options?: IsDeepEqualOptions): boolean;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a deep equality comparison between two values
|
|
3
|
+
*
|
|
4
|
+
* @param a - First value to compare
|
|
5
|
+
* @param b - Second value to compare
|
|
6
|
+
* @param options - Comparison options
|
|
7
|
+
* @returns true if values are deeply equal, false otherwise
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* isDeepEqual({ a: 1, b: [2, 3] }, { b: [2, 3], a: 1 }); // true
|
|
12
|
+
* isDeepEqual([1, 2, 3], [3, 2, 1]); // false
|
|
13
|
+
* isDeepEqual([1, 2, 3], [3, 2, 1], { strictOrder: false }); // true
|
|
14
|
+
* isDeepEqual(new Set([1, 2]), new Set([2, 1])); // true
|
|
15
|
+
* isDeepEqual(new Map([['a', 1]]), new Map([['a', 1]])); // true
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function isDeepEqual(a, b, options = {}) {
|
|
19
|
+
const { strictOrder = true } = options;
|
|
20
|
+
const visited = new WeakSet();
|
|
21
|
+
function compare(x, y) {
|
|
22
|
+
if (Object.is(x, y)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (x == null || y == null) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (typeof x !== typeof y) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (typeof x !== "object" || typeof y !== "object") {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (visited.has(x) || visited.has(y)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
visited.add(x);
|
|
38
|
+
visited.add(y);
|
|
39
|
+
const ctorX = x.constructor;
|
|
40
|
+
const ctorY = y.constructor;
|
|
41
|
+
if (ctorX !== ctorY) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (x instanceof Date && y instanceof Date) {
|
|
45
|
+
return x.getTime() === y.getTime();
|
|
46
|
+
}
|
|
47
|
+
if (x instanceof RegExp && y instanceof RegExp) {
|
|
48
|
+
return x.toString() === y.toString();
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(x) && Array.isArray(y)) {
|
|
51
|
+
if (x.length !== y.length) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (strictOrder) {
|
|
55
|
+
for (const [index, element] of x.entries()) {
|
|
56
|
+
if (!compare(element, y[index])) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const yCopy = [...y];
|
|
63
|
+
for (const itemX of x) {
|
|
64
|
+
let found = false;
|
|
65
|
+
for (let index = 0; index < yCopy.length; index++) {
|
|
66
|
+
if (compare(itemX, yCopy[index])) {
|
|
67
|
+
yCopy.splice(index, 1);
|
|
68
|
+
found = true;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!found) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return yCopy.length === 0;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (x instanceof Set && y instanceof Set) {
|
|
81
|
+
if (x.size !== y.size) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
for (const item of x) {
|
|
85
|
+
let found = false;
|
|
86
|
+
for (const otherItem of y) {
|
|
87
|
+
if (compare(item, otherItem)) {
|
|
88
|
+
found = true;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!found) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if (x instanceof Map && y instanceof Map) {
|
|
99
|
+
if (x.size !== y.size) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
for (const [key, value] of x) {
|
|
103
|
+
let found = false;
|
|
104
|
+
for (const [otherKey, otherValue] of y) {
|
|
105
|
+
if (compare(key, otherKey) && compare(value, otherValue)) {
|
|
106
|
+
found = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!found) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
if (ArrayBuffer.isView(x) && ArrayBuffer.isView(y)) {
|
|
117
|
+
const xArray = x;
|
|
118
|
+
const yArray = y;
|
|
119
|
+
if (xArray.byteLength !== yArray.byteLength) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
for (let index = 0; index < xArray.byteLength; index++) {
|
|
123
|
+
if (xArray[index] !== yArray[index]) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
const keysX = Object.keys(x);
|
|
130
|
+
const keysY = Object.keys(y);
|
|
131
|
+
if (keysX.length !== keysY.length) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
for (const key of keysX) {
|
|
135
|
+
if (!(key in y)) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const key of keysX) {
|
|
140
|
+
if (!compare(x[key], y[key])) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
return compare(a, b);
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=isDeepEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDeepEqual.js","sourceRoot":"","sources":["../../src/Validate/isDeepEqual.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CACzB,CAAU,EACV,CAAU,EACV,UAA8B,EAAE;IAEhC,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAU,CAAC;IAEtC,SAAS,OAAO,CAAC,CAAU,EAAE,CAAU;QACrC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;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C;gBACvD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACpC,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;gBAChB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IACE,CAAC,OAAO,CACL,CAA6B,CAAC,GAAG,CAAC,EAClC,CAA6B,CAAC,GAAG,CAAC,CACpC,EACD,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// biome-ignore lint/correctness/noNodejsModules: ignore
|
|
2
|
+
import process from "node:process";
|
|
1
3
|
/**
|
|
2
4
|
* Determines if the current environment is Node.js
|
|
3
5
|
*/
|
|
4
6
|
export const isNode = () => {
|
|
5
7
|
try {
|
|
6
|
-
|
|
7
|
-
return typeof process !== "undefined" && typeof require !== "undefined";
|
|
8
|
+
return process !== undefined && typeof require !== "undefined";
|
|
8
9
|
}
|
|
9
10
|
catch {
|
|
10
11
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isNode.js","sourceRoot":"","sources":["../../src/Validate/isNode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE;IACzB,IAAI,CAAC;QACH,
|
|
1
|
+
{"version":3,"file":"isNode.js","sourceRoot":"","sources":["../../src/Validate/isNode.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE;IACzB,IAAI,CAAC;QACH,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,WAAW,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -14,6 +14,10 @@ export const email = (message) => {
|
|
|
14
14
|
type: "string",
|
|
15
15
|
message,
|
|
16
16
|
validate: (value) => {
|
|
17
|
+
// RFC 5322 length limitations
|
|
18
|
+
if (value.length > 998) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
17
21
|
// Check for consecutive dots
|
|
18
22
|
if (value.includes("..")) {
|
|
19
23
|
return false;
|
|
@@ -23,6 +27,10 @@ export const email = (message) => {
|
|
|
23
27
|
if (!(localPart && domainPart)) {
|
|
24
28
|
return false;
|
|
25
29
|
}
|
|
30
|
+
// RFC 5321 length limits: local part max 64 chars, domain part max 253 chars
|
|
31
|
+
if (localPart.length > 64 || domainPart.length > 253) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
26
34
|
if (localPart.startsWith(".") || localPart.endsWith(".")) {
|
|
27
35
|
return false;
|
|
28
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../src/Validate/string/email.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAgB,EAA8B,EAAE;IACp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EAAE,IAAI,UAAU,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;gBACrD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3D,OAAO,KAAK,CAAC;YACf,CAAC;YACD,iCAAiC;YACjC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a Base32 string to Uint8Array
|
|
3
|
+
* @param {string} input - Base32 encoded string
|
|
4
|
+
* @returns {Uint8Array} Decoded bytes
|
|
5
|
+
* @example decodeBase32("JBSWY3DP"); // Uint8Array for "Hello"
|
|
6
|
+
*/
|
|
7
|
+
export declare const decodeBase32: (input: string) => Uint8Array;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeBase32 = void 0;
|
|
7
|
+
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; } } }; }
|
|
8
|
+
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; } }
|
|
9
|
+
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; }
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a Base32 string to Uint8Array
|
|
12
|
+
* @param {string} input - Base32 encoded string
|
|
13
|
+
* @returns {Uint8Array} Decoded bytes
|
|
14
|
+
* @example decodeBase32("JBSWY3DP"); // Uint8Array for "Hello"
|
|
15
|
+
*/
|
|
16
|
+
var decodeBase32 = exports.decodeBase32 = function decodeBase32(input) {
|
|
17
|
+
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
18
|
+
var cleanedInput = input.replaceAll("=", "");
|
|
19
|
+
var result = [];
|
|
20
|
+
var buffer = 0;
|
|
21
|
+
var bufferLength = 0;
|
|
22
|
+
var _iterator = _createForOfIteratorHelper(cleanedInput),
|
|
23
|
+
_step;
|
|
24
|
+
try {
|
|
25
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
|
+
var _char = _step.value;
|
|
27
|
+
var value = alphabet.indexOf(_char);
|
|
28
|
+
if (value === -1) {
|
|
29
|
+
throw new Error("Invalid base32 character: ".concat(_char));
|
|
30
|
+
}
|
|
31
|
+
buffer = buffer << 5 | value;
|
|
32
|
+
bufferLength += 5;
|
|
33
|
+
if (bufferLength >= 8) {
|
|
34
|
+
bufferLength -= 8;
|
|
35
|
+
result.push(buffer >> bufferLength & 0xff);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
_iterator.e(err);
|
|
40
|
+
} finally {
|
|
41
|
+
_iterator.f();
|
|
42
|
+
}
|
|
43
|
+
return new Uint8Array(result);
|
|
44
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a Base32 string to a UTF-8 string
|
|
3
|
+
* @param {string} input - Base32 encoded string
|
|
4
|
+
* @returns {string} Decoded string
|
|
5
|
+
* @example decodeBase32ToString("JBSWY3DP"); // "Hello"
|
|
6
|
+
*/
|
|
7
|
+
export declare const decodeBase32ToString: (input: string) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeBase32ToString = void 0;
|
|
7
|
+
var _decodeBase = require("./decodeBase32");
|
|
8
|
+
/**
|
|
9
|
+
* Decodes a Base32 string to a UTF-8 string
|
|
10
|
+
* @param {string} input - Base32 encoded string
|
|
11
|
+
* @returns {string} Decoded string
|
|
12
|
+
* @example decodeBase32ToString("JBSWY3DP"); // "Hello"
|
|
13
|
+
*/
|
|
14
|
+
var decodeBase32ToString = exports.decodeBase32ToString = function decodeBase32ToString(input) {
|
|
15
|
+
return new TextDecoder().decode((0, _decodeBase.decodeBase32)(input));
|
|
16
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a Base58 string to Uint8Array
|
|
3
|
+
* @param {string} input - Base58 encoded string
|
|
4
|
+
* @returns {Uint8Array} Decoded bytes
|
|
5
|
+
* @example decodeBase58("9Ajdvzr"); // Uint8Array for "Hello"
|
|
6
|
+
*/
|
|
7
|
+
export declare const decodeBase58: (input: string) => Uint8Array;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeBase58 = void 0;
|
|
7
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
10
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
11
|
+
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; } } }; }
|
|
12
|
+
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; } }
|
|
13
|
+
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; }
|
|
14
|
+
/**
|
|
15
|
+
* Decodes a Base58 string to Uint8Array
|
|
16
|
+
* @param {string} input - Base58 encoded string
|
|
17
|
+
* @returns {Uint8Array} Decoded bytes
|
|
18
|
+
* @example decodeBase58("9Ajdvzr"); // Uint8Array for "Hello"
|
|
19
|
+
*/
|
|
20
|
+
var decodeBase58 = exports.decodeBase58 = function decodeBase58(input) {
|
|
21
|
+
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
22
|
+
var bigNumber = BigInt(0);
|
|
23
|
+
var _iterator = _createForOfIteratorHelper(input),
|
|
24
|
+
_step;
|
|
25
|
+
try {
|
|
26
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
27
|
+
var _char = _step.value;
|
|
28
|
+
var value = alphabet.indexOf(_char);
|
|
29
|
+
if (value === -1) {
|
|
30
|
+
throw new Error("Invalid base58 character: ".concat(_char));
|
|
31
|
+
}
|
|
32
|
+
bigNumber = bigNumber * BigInt(58) + BigInt(value);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_iterator.e(err);
|
|
36
|
+
} finally {
|
|
37
|
+
_iterator.f();
|
|
38
|
+
}
|
|
39
|
+
var bytes = [];
|
|
40
|
+
while (bigNumber > 0) {
|
|
41
|
+
bytes.unshift(Number(bigNumber % BigInt(256)));
|
|
42
|
+
bigNumber /= BigInt(256);
|
|
43
|
+
}
|
|
44
|
+
var leadingOnes = 0;
|
|
45
|
+
var _iterator2 = _createForOfIteratorHelper(input),
|
|
46
|
+
_step2;
|
|
47
|
+
try {
|
|
48
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
49
|
+
var _char2 = _step2.value;
|
|
50
|
+
if (_char2 !== "1") {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
leadingOnes++;
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
_iterator2.e(err);
|
|
57
|
+
} finally {
|
|
58
|
+
_iterator2.f();
|
|
59
|
+
}
|
|
60
|
+
return new Uint8Array([].concat(_toConsumableArray(Array.from({
|
|
61
|
+
length: leadingOnes
|
|
62
|
+
}).fill(0)), bytes));
|
|
63
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a Base58 string to a UTF-8 string
|
|
3
|
+
* @param {string} input - Base58 encoded string
|
|
4
|
+
* @returns {string} Decoded string
|
|
5
|
+
* @example decodeBase58ToString("9Ajdvzr"); // "Hello"
|
|
6
|
+
*/
|
|
7
|
+
export declare const decodeBase58ToString: (input: string) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeBase58ToString = void 0;
|
|
7
|
+
var _decodeBase = require("./decodeBase58");
|
|
8
|
+
/**
|
|
9
|
+
* Decodes a Base58 string to a UTF-8 string
|
|
10
|
+
* @param {string} input - Base58 encoded string
|
|
11
|
+
* @returns {string} Decoded string
|
|
12
|
+
* @example decodeBase58ToString("9Ajdvzr"); // "Hello"
|
|
13
|
+
*/
|
|
14
|
+
var decodeBase58ToString = exports.decodeBase58ToString = function decodeBase58ToString(input) {
|
|
15
|
+
return new TextDecoder().decode((0, _decodeBase.decodeBase58)(input));
|
|
16
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a string or Uint8Array to Base32 format
|
|
3
|
+
* @param {string | Uint8Array} input - The input to encode
|
|
4
|
+
* @returns {string} Base32 encoded string
|
|
5
|
+
* @example encodeBase32("Hello"); // "JBSWY3DP"
|
|
6
|
+
*/
|
|
7
|
+
export declare const encodeBase32: (input: string | Uint8Array) => string;
|