@unchainedshop/utils 5.0.0-alpha.3 → 5.0.0-alpha.4
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/lib/phone-number.js +7 -7
- package/package.json +3 -3
package/lib/phone-number.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parsePhoneNumber } from 'awesome-phonenumber';
|
|
2
2
|
export const normalizePhoneNumber = (value, defaultCountry) => {
|
|
3
3
|
if (!value)
|
|
4
4
|
return undefined;
|
|
5
|
-
const parsed =
|
|
6
|
-
if (!parsed
|
|
5
|
+
const parsed = parsePhoneNumber(value, defaultCountry ? { regionCode: defaultCountry } : undefined);
|
|
6
|
+
if (!parsed.valid)
|
|
7
7
|
return undefined;
|
|
8
|
-
return parsed.number;
|
|
8
|
+
return parsed.number.e164;
|
|
9
9
|
};
|
|
10
10
|
export const phoneNumberToParts = (value, defaultCountry) => {
|
|
11
11
|
if (!value)
|
|
12
12
|
return undefined;
|
|
13
|
-
const parsed =
|
|
14
|
-
if (!parsed
|
|
13
|
+
const parsed = parsePhoneNumber(value, defaultCountry ? { regionCode: defaultCountry } : undefined);
|
|
14
|
+
if (!parsed.valid)
|
|
15
15
|
return undefined;
|
|
16
|
-
return { cc: parsed.
|
|
16
|
+
return { cc: String(parsed.countryCode), subscriber: parsed.number.significant };
|
|
17
17
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/utils",
|
|
3
3
|
"description": "Common utility functions and base classes for the Unchained Engine",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.4",
|
|
5
5
|
"main": "lib/utils-index.js",
|
|
6
6
|
"types": "lib/utils-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@unchainedshop/logger": "^5.0.0-alpha.1",
|
|
33
|
-
"
|
|
33
|
+
"awesome-phonenumber": "^7.8.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^26.2.0",
|
|
37
|
-
"typescript": "^
|
|
37
|
+
"typescript": "^6.0.3"
|
|
38
38
|
}
|
|
39
39
|
}
|