@unicode-utils/core 0.12.0-beta.20 → 0.12.0-beta.21
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.d.mts +18 -0
- package/dist/index.mjs +7 -3
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -17,6 +17,24 @@ interface GetCurrentDraftVersionOptions {
|
|
|
17
17
|
* Each pattern must include exactly one capturing group that matches the version
|
|
18
18
|
*/
|
|
19
19
|
patterns?: RegExp[];
|
|
20
|
+
/**
|
|
21
|
+
* Called when a version is successfully extracted
|
|
22
|
+
* @param {string} version - The extracted Unicode draft version.
|
|
23
|
+
* @returns {void}
|
|
24
|
+
*/
|
|
25
|
+
onSuccess?: (version: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Called when no version could be extracted from the response body
|
|
28
|
+
* @param {string} text - The fetched ReadMe response text.
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
onNotFound?: (text: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Called only when an error is caught in the catch block
|
|
34
|
+
* @param {unknown} error - The caught error value.
|
|
35
|
+
* @returns {void}
|
|
36
|
+
*/
|
|
37
|
+
onError?: (error: unknown) => void;
|
|
20
38
|
}
|
|
21
39
|
/**
|
|
22
40
|
* Retrieves the current Unicode Standard draft version by fetching and parsing
|
package/dist/index.mjs
CHANGED
|
@@ -35,7 +35,7 @@ async function getCurrentDraftVersion(options = {}) {
|
|
|
35
35
|
/Version (\d+\.\d+(?:\.\d+)?) of the Unicode Standard/,
|
|
36
36
|
/Unicode(\d+\.\d+(?:\.\d+)?)/,
|
|
37
37
|
/Version (\d+\.\d+)(?!\.\d)/
|
|
38
|
-
] } = options;
|
|
38
|
+
], onSuccess, onNotFound, onError } = options;
|
|
39
39
|
try {
|
|
40
40
|
const res = await fetch(url, fetchOptions);
|
|
41
41
|
if (!res.ok) throw new Error("failed to fetch draft ReadMe");
|
|
@@ -43,10 +43,14 @@ async function getCurrentDraftVersion(options = {}) {
|
|
|
43
43
|
for (const pattern of patterns) {
|
|
44
44
|
const match = text.match(pattern);
|
|
45
45
|
if (match == null || match[1] == null) continue;
|
|
46
|
-
|
|
46
|
+
const version = match[1].trim();
|
|
47
|
+
onSuccess?.(version);
|
|
48
|
+
return version;
|
|
47
49
|
}
|
|
50
|
+
onNotFound?.(text);
|
|
48
51
|
return null;
|
|
49
|
-
} catch {
|
|
52
|
+
} catch (err) {
|
|
53
|
+
onError?.(err);
|
|
50
54
|
return null;
|
|
51
55
|
}
|
|
52
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unicode-utils/core",
|
|
3
|
-
"version": "0.12.0-beta.
|
|
3
|
+
"version": "0.12.0-beta.21",
|
|
4
4
|
"description": "Utilities for working with Unicode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@luxass/utils": "2.7.3",
|
|
37
37
|
"defu": "6.1.4",
|
|
38
|
-
"@unicode-utils/metadata": "0.12.0-beta.
|
|
39
|
-
"@unicode-utils/parser": "0.12.0-beta.
|
|
38
|
+
"@unicode-utils/metadata": "0.12.0-beta.21",
|
|
39
|
+
"@unicode-utils/parser": "0.12.0-beta.21"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@luxass/eslint-config": "7.2.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"tsx": "4.21.0",
|
|
50
50
|
"typescript": "5.9.3",
|
|
51
51
|
"vitest-package-exports": "1.2.0",
|
|
52
|
-
"@unicode-utils-tooling/
|
|
53
|
-
"@unicode-utils-tooling/
|
|
52
|
+
"@unicode-utils-tooling/tsdown-config": "0.12.0-beta.21",
|
|
53
|
+
"@unicode-utils-tooling/tsconfig": "0.12.0-beta.21"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsdown --tsconfig=./tsconfig.build.json",
|