@nhtio/phone-object 1.20250512.0 → 1.20251202.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/index.cjs +12 -17
- package/index.cjs.map +1 -1
- package/index.d.mts +517 -0
- package/index.mjs +17859 -18529
- package/index.mjs.map +1 -1
- package/package.json +3 -3
- package/index.d.ts +0 -13
- package/lib/countries/constants/countries.d.ts +0 -4
- package/lib/countries/constants/timezones.d.ts +0 -5
- package/lib/countries/countries.d.ts +0 -13
- package/lib/countries/index.d.ts +0 -4
- package/lib/countries/types.d.ts +0 -46
- package/lib/nampa/constants.d.ts +0 -14
- package/lib/nampa/index.d.ts +0 -1
- package/lib/phone/index.d.ts +0 -2
- package/lib/phone/phone.d.ts +0 -244
- package/lib/phone/types.d.ts +0 -170
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nhtio/phone-object",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20251202.0",
|
|
4
4
|
"description": "An immutable data structure representing a specific phone number and accompanying methods.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Jak Giveon <jak@nht.io>",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"types": "./index.d.ts"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"dependencies": {},
|
|
19
18
|
"packageManager": "pnpm@10.8.0+sha512.0e82714d1b5b43c74610193cb20734897c1d00de89d0e18420aebc5977fa13d780a9cb05734624e81ebd81cc876cd464794850641c48b9544326b5622ca29971",
|
|
20
|
-
"type": "module"
|
|
19
|
+
"type": "module",
|
|
20
|
+
"dependencies": {}
|
|
21
21
|
}
|
package/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An immutable data structure representing a specific phone number and accompanying methods.
|
|
3
|
-
* @module @nhtio/phone-object
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* The current version of the package.
|
|
7
|
-
*
|
|
8
|
-
* @tip This is a constant that is replaced during the build process with the actual version of the package.
|
|
9
|
-
*/
|
|
10
|
-
export declare const version: string;
|
|
11
|
-
export * from './lib/countries';
|
|
12
|
-
export * from './lib/nampa';
|
|
13
|
-
export * from './lib/phone';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Numeric, SpecificTimeAdvancedOptions } from './types.ts';
|
|
2
|
-
/**
|
|
3
|
-
* An immutable set of all of the ISO 3166-1 alpha-2 country codes recognized by the library.
|
|
4
|
-
*/
|
|
5
|
-
export declare const isos: Readonly<Set<string>>;
|
|
6
|
-
/**
|
|
7
|
-
* Returns an array of ISO 3166-1 alpha-2 country codes that have the same specific time as the given options.
|
|
8
|
-
* @param minute - The minute of the specific time.
|
|
9
|
-
* @param hour - The hour of the specific time. Can be a number or an object of advanced options.
|
|
10
|
-
* @param advanced - An object of advanced options for the specific time.
|
|
11
|
-
* @returns An array of ISO 3166-1 alpha-2 country codes that have the same specific time as the given options.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getCountriesWithSpecificTime(minute: Numeric, hour?: Numeric | SpecificTimeAdvancedOptions, advanced?: SpecificTimeAdvancedOptions): string[];
|
package/lib/countries/index.d.ts
DELETED
package/lib/countries/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a numeric value that can be either a string or a number.
|
|
3
|
-
*/
|
|
4
|
-
export type Numeric = string | number;
|
|
5
|
-
/**
|
|
6
|
-
* Represents the ISO 3166-1 alpha-2 country codes of all countries recognized by the library.
|
|
7
|
-
*/
|
|
8
|
-
export type Country = 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';
|
|
9
|
-
/**
|
|
10
|
-
* Represents either the ISO 3166-1 alpha-2 country codes of all countries recognized by the library or the string `'XX'` to represent an unknown country.
|
|
11
|
-
*/
|
|
12
|
-
export type CountryOrUnknown = Country | 'XX';
|
|
13
|
-
/**
|
|
14
|
-
* Represents the possible timezones of all countries recognized by the library.
|
|
15
|
-
*/
|
|
16
|
-
export type CountryTimezone = 'Europe/Andorra' | 'Asia/Dubai' | 'Asia/Kabul' | 'America/Antigua' | 'America/Anguilla' | 'Europe/Tirane' | 'Asia/Yerevan' | 'Africa/Luanda' | 'Antarctica/Casey' | 'America/Argentina/Buenos_Aires' | 'Pacific/Pago_Pago' | 'Europe/Vienna' | 'Australia/Sydney' | 'America/Aruba' | 'Europe/Mariehamn' | 'Asia/Baku' | 'Europe/Sarajevo' | 'America/Barbados' | 'Asia/Dhaka' | 'Europe/Brussels' | 'Africa/Ouagadougou' | 'Europe/Sofia' | 'Asia/Bahrain' | 'Africa/Bujumbura' | 'Africa/Porto-Novo' | 'America/St_Barthelemy' | 'Atlantic/Bermuda' | 'Asia/Brunei' | 'America/La_Paz' | 'America/Kralendijk' | 'America/Sao_Paulo' | 'America/Nassau' | 'Asia/Thimphu' | 'Africa/Gaborone' | 'Europe/Minsk' | 'America/Belize' | 'America/Toronto' | 'Indian/Cocos' | 'Africa/Kinshasa' | 'Africa/Bangui' | 'Africa/Brazzaville' | 'Europe/Zurich' | 'Africa/Abidjan' | 'Pacific/Rarotonga' | 'America/Santiago' | 'Africa/Douala' | 'Asia/Shanghai' | 'America/Bogota' | 'America/Costa_Rica' | 'America/Havana' | 'Atlantic/Cape_Verde' | 'America/Curacao' | 'Indian/Christmas' | 'Asia/Nicosia' | 'Europe/Prague' | 'Europe/Berlin' | 'Africa/Djibouti' | 'Europe/Copenhagen' | 'America/Dominica' | 'America/Santo_Domingo' | 'Africa/Algiers' | 'America/Guayaquil' | 'Europe/Tallinn' | 'Africa/Cairo' | 'Africa/El_Aaiun' | 'Africa/Asmara' | 'Europe/Madrid' | 'Africa/Addis_Ababa' | 'Europe/Helsinki' | 'Pacific/Fiji' | 'Atlantic/Stanley' | 'Pacific/Pohnpei' | 'Atlantic/Faroe' | 'Europe/Paris' | 'Africa/Libreville' | 'Europe/London' | 'America/Grenada' | 'Asia/Tbilisi' | 'America/Cayenne' | 'Europe/Guernsey' | 'Africa/Accra' | 'Europe/Gibraltar' | 'America/Godthab' | 'Africa/Banjul' | 'Africa/Conakry' | 'America/Guadeloupe' | 'Africa/Malabo' | 'Europe/Athens' | 'Atlantic/South_Georgia' | 'America/Guatemala' | 'Pacific/Guam' | 'Africa/Bissau' | 'America/Guyana' | 'Asia/Hong_Kong' | 'America/Tegucigalpa' | 'Europe/Zagreb' | 'America/Port-au-Prince' | 'Europe/Budapest' | 'Asia/Jakarta' | 'Europe/Dublin' | 'Asia/Jerusalem' | 'Europe/Isle_of_Man' | 'Asia/Kolkata' | 'Indian/Chagos' | 'Asia/Baghdad' | 'Asia/Tehran' | 'Atlantic/Reykjavik' | 'Europe/Rome' | 'Europe/Jersey' | 'America/Jamaica' | 'Asia/Amman' | 'Asia/Tokyo' | 'Africa/Nairobi' | 'Asia/Bishkek' | 'Asia/Phnom_Penh' | 'Pacific/Tarawa' | 'Indian/Comoro' | 'America/St_Kitts' | 'Asia/Pyongyang' | 'Asia/Seoul' | 'Asia/Kuwait' | 'America/Cayman' | 'Asia/Almaty' | 'Asia/Vientiane' | 'Asia/Beirut' | 'America/St_Lucia' | 'Europe/Vaduz' | 'Asia/Colombo' | 'Africa/Monrovia' | 'Africa/Maseru' | 'Europe/Vilnius' | 'Europe/Luxembourg' | 'Europe/Riga' | 'Africa/Tripoli' | 'Africa/Casablanca' | 'Europe/Monaco' | 'Europe/Chisinau' | 'Europe/Podgorica' | 'America/Marigot' | 'Indian/Antananarivo' | 'Pacific/Majuro' | 'Europe/Skopje' | 'Africa/Bamako' | 'Asia/Yangon' | 'Asia/Ulaanbaatar' | 'Asia/Macau' | 'Pacific/Saipan' | 'America/Martinique' | 'Africa/Nouakchott' | 'America/Montserrat' | 'Europe/Malta' | 'Indian/Mauritius' | 'Indian/Maldives' | 'Africa/Blantyre' | 'America/Mexico_City' | 'Asia/Kuala_Lumpur' | 'Africa/Maputo' | 'Africa/Windhoek' | 'Pacific/Noumea' | 'Africa/Niamey' | 'Pacific/Norfolk' | 'Africa/Lagos' | 'America/Managua' | 'Europe/Amsterdam' | 'Europe/Oslo' | 'Asia/Kathmandu' | 'Pacific/Nauru' | 'Pacific/Niue' | 'Pacific/Auckland' | 'Asia/Muscat' | 'America/Panama' | 'America/Lima' | 'Pacific/Tahiti' | 'Pacific/Port_Moresby' | 'Asia/Manila' | 'Asia/Karachi' | 'Europe/Warsaw' | 'America/Miquelon' | 'Pacific/Pitcairn' | 'America/Puerto_Rico' | 'Asia/Gaza' | 'Europe/Lisbon' | 'Pacific/Palau' | 'America/Asuncion' | 'Asia/Qatar' | 'Indian/Reunion' | 'Europe/Bucharest' | 'Europe/Belgrade' | 'Europe/Moscow' | 'Africa/Kigali' | 'Asia/Riyadh' | 'Pacific/Guadalcanal' | 'Indian/Mahe' | 'Africa/Khartoum' | 'Europe/Stockholm' | 'Asia/Singapore' | 'Atlantic/St_Helena' | 'Europe/Ljubljana' | 'Arctic/Longyearbyen' | 'Europe/Bratislava' | 'Africa/Freetown' | 'Europe/San_Marino' | 'Africa/Dakar' | 'Africa/Mogadishu' | 'America/Paramaribo' | 'Africa/Juba' | 'Africa/Sao_Tome' | 'America/El_Salvador' | 'America/Lower_Princes' | 'Asia/Damascus' | 'Africa/Mbabane' | 'America/Grand_Turk' | 'Africa/Ndjamena' | 'Indian/Kerguelen' | 'Africa/Lome' | 'Asia/Bangkok' | 'Asia/Dushanbe' | 'Pacific/Fakaofo' | 'Asia/Dili' | 'Asia/Ashgabat' | 'Africa/Tunis' | 'Pacific/Tongatapu' | 'Europe/Istanbul' | 'America/Port_of_Spain' | 'Pacific/Funafuti' | 'Asia/Taipei' | 'Africa/Dar_es_Salaam' | 'Europe/Kiev' | 'Africa/Kampala' | 'Pacific/Wake' | 'America/New_York' | 'America/Montevideo' | 'Asia/Tashkent' | 'Europe/Vatican' | 'America/St_Vincent' | 'America/Caracas' | 'America/Tortola' | 'America/St_Thomas' | 'Asia/Ho_Chi_Minh' | 'Pacific/Efate' | 'Pacific/Wallis' | 'Pacific/Apia' | 'Asia/Aden' | 'Indian/Mayotte' | 'Africa/Johannesburg' | 'Africa/Lusaka' | 'Africa/Harare';
|
|
17
|
-
/**
|
|
18
|
-
* Interface representing advanced options for specifying a specific time for use with the `getCountriesWithSpecificTime` function.
|
|
19
|
-
* @interface
|
|
20
|
-
*/
|
|
21
|
-
export interface SpecificTimeAdvancedOptions {
|
|
22
|
-
/**
|
|
23
|
-
* The hour of the day to match.
|
|
24
|
-
*/
|
|
25
|
-
hourOfDay?: Numeric;
|
|
26
|
-
/**
|
|
27
|
-
* The day of the week to match.
|
|
28
|
-
*/
|
|
29
|
-
dayOfWeek?: Numeric;
|
|
30
|
-
/**
|
|
31
|
-
* The week of the year to match.
|
|
32
|
-
*/
|
|
33
|
-
weekOfYear?: Numeric;
|
|
34
|
-
/**
|
|
35
|
-
* The day of the month to match.
|
|
36
|
-
*/
|
|
37
|
-
dayOfMonth?: Numeric;
|
|
38
|
-
/**
|
|
39
|
-
* The month of the year to match.
|
|
40
|
-
*/
|
|
41
|
-
monthOfYear?: Numeric;
|
|
42
|
-
/**
|
|
43
|
-
* The year to match.
|
|
44
|
-
*/
|
|
45
|
-
year?: Numeric;
|
|
46
|
-
}
|
package/lib/nampa/constants.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An interface describing an object where a NANPA area code is a key, and a NANPA country code is a value.
|
|
3
|
-
*/
|
|
4
|
-
export interface AreaCodeMap {
|
|
5
|
-
[areaCode: string]: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A map of NANPA area codes to NANPA country codes.
|
|
9
|
-
*/
|
|
10
|
-
export declare const areaCodeMap: AreaCodeMap;
|
|
11
|
-
/**
|
|
12
|
-
* A list of NANPA country codes.
|
|
13
|
-
*/
|
|
14
|
-
export declare const nanpaCountries: Array<string>;
|
package/lib/nampa/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './constants';
|
package/lib/phone/index.d.ts
DELETED
package/lib/phone/phone.d.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `CountryOrUnknown` type is imported from the `./countries` module and represents a country's ISO 3166-1 alpha-2 code, or an unknown country represented by the `'XX'` code.
|
|
3
|
-
* @typedef {Country | 'XX'} CountryOrUnknown
|
|
4
|
-
*/
|
|
5
|
-
import type { CountryOrUnknown } from '../countries';
|
|
6
|
-
import { PhoneModel, PhoneTypes, PossiblePhoneTimezone, RawCountryType, RawPhoneType } from './types.ts';
|
|
7
|
-
/**
|
|
8
|
-
* The `Phone` class represents a phone number and provides methods to retrieve information about it.
|
|
9
|
-
* It implements the `PhoneModel` interface.
|
|
10
|
-
* @implements {PhoneModel}
|
|
11
|
-
*/
|
|
12
|
-
export declare class Phone implements PhoneModel {
|
|
13
|
-
#private;
|
|
14
|
-
/**
|
|
15
|
-
* The `Phone` class constructor takes a `phone` argument of type `RawPhoneType` and an optional `country` argument of type `RawCountryType`.
|
|
16
|
-
* It initializes `Phone` instance.
|
|
17
|
-
* @constructor
|
|
18
|
-
* @param {RawPhoneType} phone - The phone number to be parsed and validated.
|
|
19
|
-
* @param {RawCountryType} [country] - The country code of the phone number. If not provided, the country will be guessed based on the phone number.
|
|
20
|
-
*/
|
|
21
|
-
constructor(phone: RawPhoneType, country?: RawCountryType);
|
|
22
|
-
/**
|
|
23
|
-
* Returns the country code of the phone number.
|
|
24
|
-
* @readonly
|
|
25
|
-
* @type {CountryOrUnknown}
|
|
26
|
-
*/
|
|
27
|
-
get country(): CountryOrUnknown;
|
|
28
|
-
/**
|
|
29
|
-
* Returns whether the phone number uses a valid format for the parsed country or not.
|
|
30
|
-
* @readonly
|
|
31
|
-
* @type {boolean}
|
|
32
|
-
*/
|
|
33
|
-
get valid(): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Returns the type of the phone number.
|
|
36
|
-
* @readonly
|
|
37
|
-
* @type {PhoneTypes}
|
|
38
|
-
*/
|
|
39
|
-
get type(): PhoneTypes;
|
|
40
|
-
/**
|
|
41
|
-
* Returns whether the phone number is a mobile number or not.
|
|
42
|
-
* @readonly
|
|
43
|
-
* @type {boolean}
|
|
44
|
-
*/
|
|
45
|
-
get mobile(): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the raw phone number.
|
|
48
|
-
* @readonly
|
|
49
|
-
* @type {string}
|
|
50
|
-
*
|
|
51
|
-
* @remarks
|
|
52
|
-
* If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned.
|
|
53
|
-
*/
|
|
54
|
-
get raw(): string;
|
|
55
|
-
/**
|
|
56
|
-
* Returns the national format of the phone number.
|
|
57
|
-
* @readonly
|
|
58
|
-
* @type {string}
|
|
59
|
-
*
|
|
60
|
-
* @remarks
|
|
61
|
-
* If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned.
|
|
62
|
-
*/
|
|
63
|
-
get national(): string;
|
|
64
|
-
/**
|
|
65
|
-
* Returns the international format of the phone number.
|
|
66
|
-
* @readonly
|
|
67
|
-
* @type {string}
|
|
68
|
-
*
|
|
69
|
-
* @remarks
|
|
70
|
-
* If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned.
|
|
71
|
-
*/
|
|
72
|
-
get international(): string;
|
|
73
|
-
/**
|
|
74
|
-
* Returns the E.164 format of the phone number.
|
|
75
|
-
* @readonly
|
|
76
|
-
* @type {string}
|
|
77
|
-
*
|
|
78
|
-
* @remarks
|
|
79
|
-
* If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned.
|
|
80
|
-
*/
|
|
81
|
-
get e164(): string;
|
|
82
|
-
/**
|
|
83
|
-
* Returns the timezone of the phone number.
|
|
84
|
-
* @readonly
|
|
85
|
-
* @type {PossiblePhoneTimezone}
|
|
86
|
-
*/
|
|
87
|
-
get timezone(): PossiblePhoneTimezone;
|
|
88
|
-
/**
|
|
89
|
-
* Returns an object representation of the phone number.
|
|
90
|
-
* @returns {{
|
|
91
|
-
* phone: string;
|
|
92
|
-
* country: string;
|
|
93
|
-
* valid: boolean;
|
|
94
|
-
* type: PhoneTypes;
|
|
95
|
-
* mobile: boolean;
|
|
96
|
-
* raw: string;
|
|
97
|
-
* national: string;
|
|
98
|
-
* international: string;
|
|
99
|
-
* e164: string;
|
|
100
|
-
* timezone: PossiblePhoneTimezone;
|
|
101
|
-
* }} - An object representation of the phone number.
|
|
102
|
-
*/
|
|
103
|
-
toObject(): {
|
|
104
|
-
/**
|
|
105
|
-
* The phone number as a string stripped of all non-numeric characters.
|
|
106
|
-
*/
|
|
107
|
-
phone: string;
|
|
108
|
-
/**
|
|
109
|
-
* The country code of the phone number.
|
|
110
|
-
* @remarks
|
|
111
|
-
* In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used.
|
|
112
|
-
* @type {CountryOrUnknown}
|
|
113
|
-
*/
|
|
114
|
-
country: CountryOrUnknown;
|
|
115
|
-
/**
|
|
116
|
-
* Whether the phone number uses a valid format for the parsed country or not.
|
|
117
|
-
* @type {boolean}
|
|
118
|
-
*/
|
|
119
|
-
valid: boolean;
|
|
120
|
-
/**
|
|
121
|
-
* The type of the phone number.
|
|
122
|
-
* @type {PhoneTypes}
|
|
123
|
-
*/
|
|
124
|
-
type: PhoneTypes;
|
|
125
|
-
/**
|
|
126
|
-
* Whether the phone number is possibly a mobile number or not.
|
|
127
|
-
* @type {boolean}
|
|
128
|
-
*/
|
|
129
|
-
mobile: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* The phone number as a string stripped of all non-numeric characters.
|
|
132
|
-
* @type {string}
|
|
133
|
-
*/
|
|
134
|
-
raw: string;
|
|
135
|
-
/**
|
|
136
|
-
* The phone number as a string in the national format for the parsed country.
|
|
137
|
-
* @type {string}
|
|
138
|
-
*/
|
|
139
|
-
national: string;
|
|
140
|
-
/**
|
|
141
|
-
* The phone number as a string in the international format for the parsed country.
|
|
142
|
-
* @type {string}
|
|
143
|
-
*/
|
|
144
|
-
international: string;
|
|
145
|
-
/**
|
|
146
|
-
* The phone number as a string in the E.164 format.
|
|
147
|
-
* @type {string}
|
|
148
|
-
*/
|
|
149
|
-
e164: string;
|
|
150
|
-
/**
|
|
151
|
-
* The estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`.
|
|
152
|
-
*/
|
|
153
|
-
timezone: PossiblePhoneTimezone;
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* Returns a JSON representation of the phone number.
|
|
157
|
-
* @returns {{
|
|
158
|
-
* phone: string;
|
|
159
|
-
* country: string;
|
|
160
|
-
* valid: boolean;
|
|
161
|
-
* type: PhoneTypes;
|
|
162
|
-
* mobile: boolean;
|
|
163
|
-
* raw: string;
|
|
164
|
-
* national: string;
|
|
165
|
-
* international: string;
|
|
166
|
-
* e164: string;
|
|
167
|
-
* timezone: PossiblePhoneTimezone;
|
|
168
|
-
* }} - A JSON-safe representation of the phone number.
|
|
169
|
-
*/
|
|
170
|
-
toJSON(): {
|
|
171
|
-
/**
|
|
172
|
-
* The phone number as a string stripped of all non-numeric characters.
|
|
173
|
-
*/
|
|
174
|
-
phone: string;
|
|
175
|
-
/**
|
|
176
|
-
* The country code of the phone number.
|
|
177
|
-
* @remarks
|
|
178
|
-
* In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used.
|
|
179
|
-
* @type {CountryOrUnknown}
|
|
180
|
-
*/
|
|
181
|
-
country: CountryOrUnknown;
|
|
182
|
-
/**
|
|
183
|
-
* Whether the phone number uses a valid format for the parsed country or not.
|
|
184
|
-
* @type {boolean}
|
|
185
|
-
*/
|
|
186
|
-
valid: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* The type of the phone number.
|
|
189
|
-
* @type {PhoneTypes}
|
|
190
|
-
*/
|
|
191
|
-
type: PhoneTypes;
|
|
192
|
-
/**
|
|
193
|
-
* Whether the phone number is possibly a mobile number or not.
|
|
194
|
-
* @type {boolean}
|
|
195
|
-
*/
|
|
196
|
-
mobile: boolean;
|
|
197
|
-
/**
|
|
198
|
-
* The phone number as a string stripped of all non-numeric characters.
|
|
199
|
-
* @type {string}
|
|
200
|
-
*/
|
|
201
|
-
raw: string;
|
|
202
|
-
/**
|
|
203
|
-
* The phone number as a string in the national format for the parsed country.
|
|
204
|
-
* @type {string}
|
|
205
|
-
*/
|
|
206
|
-
national: string;
|
|
207
|
-
/**
|
|
208
|
-
* The phone number as a string in the international format for the parsed country.
|
|
209
|
-
* @type {string}
|
|
210
|
-
*/
|
|
211
|
-
international: string;
|
|
212
|
-
/**
|
|
213
|
-
* The phone number as a string in the E.164 format.
|
|
214
|
-
* @type {string}
|
|
215
|
-
*/
|
|
216
|
-
e164: string;
|
|
217
|
-
/**
|
|
218
|
-
* The estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`.
|
|
219
|
-
*/
|
|
220
|
-
timezone: PossiblePhoneTimezone;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* Returns the E.164 format of the phone number as a string.
|
|
224
|
-
* @returns {string} - The E.164 format of the phone number.
|
|
225
|
-
*/
|
|
226
|
-
toString(): string;
|
|
227
|
-
/**
|
|
228
|
-
* Returns a stringified representation of the phone number.
|
|
229
|
-
* @returns {string} - A string representation of the phone number.
|
|
230
|
-
*/
|
|
231
|
-
inspect(): string;
|
|
232
|
-
/**
|
|
233
|
-
* Serializes the phone object to an obfuscated string which can be used to recreate the phone object from the `Phone.deserialize` method.
|
|
234
|
-
* @returns {string} - The serialized phone object.
|
|
235
|
-
*/
|
|
236
|
-
serialize(): string;
|
|
237
|
-
/**
|
|
238
|
-
* Creates a new phone object from a serialized phone object.
|
|
239
|
-
* @param serialized The serialized phone object returned from the `Phone.serialize` method.
|
|
240
|
-
* @returns A Phone instance with the same properties as the original phone object.
|
|
241
|
-
* @throws An error if the serialized phone object is not valid.
|
|
242
|
-
*/
|
|
243
|
-
static deserialize(serialized: string): Phone;
|
|
244
|
-
}
|
package/lib/phone/types.d.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import libPhoneNumber from 'google-libphonenumber';
|
|
2
|
-
import type { Country, CountryOrUnknown, CountryTimezone } from '../countries';
|
|
3
|
-
/**
|
|
4
|
-
* The `RawPhoneType` type represents the phone number which should be parsed. It can be either a string or a number.
|
|
5
|
-
* @typedef {string | number} RawPhoneType
|
|
6
|
-
*/
|
|
7
|
-
export type RawPhoneType = string | number;
|
|
8
|
-
/**
|
|
9
|
-
* The `RawCountryType` type represents the country which should be used to parse the phone number. It is of type `Country`.
|
|
10
|
-
* @typedef {Country} RawCountryType
|
|
11
|
-
*/
|
|
12
|
-
export type RawCountryType = Country;
|
|
13
|
-
/**
|
|
14
|
-
* The `PossiblePhoneTimezone` type represents the estimated timezone of a phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`.
|
|
15
|
-
* @typedef {CountryTimezone | 'UTC'} PossiblePhoneTimezone
|
|
16
|
-
* @remarks
|
|
17
|
-
*
|
|
18
|
-
* In cases where the phone number's country has several timezones, the timezone with the greatest population is used.
|
|
19
|
-
* In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used.
|
|
20
|
-
*/
|
|
21
|
-
export type PossiblePhoneTimezone = CountryTimezone | 'UTC';
|
|
22
|
-
/**
|
|
23
|
-
* The `PhoneTypes` type represents the possible types of a phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid.
|
|
24
|
-
* @typedef {keyof typeof libPhoneNumber.PhoneNumberType | 'INVALID'} PhoneTypes
|
|
25
|
-
*/
|
|
26
|
-
export type PhoneTypes = keyof typeof libPhoneNumber.PhoneNumberType | 'INVALID';
|
|
27
|
-
/**
|
|
28
|
-
* The `PhoneModelInstanceObject` interface represents the properties of a `Phone` instance.
|
|
29
|
-
* @interface
|
|
30
|
-
*/
|
|
31
|
-
export interface PhoneModelInstanceObject {
|
|
32
|
-
/**
|
|
33
|
-
* The `phone` property represents the raw phone number string that was used to create the `Phone` instance.
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
36
|
-
phone: string;
|
|
37
|
-
/**
|
|
38
|
-
* The `country` property represents the country that was used to create the `Phone` instance.
|
|
39
|
-
* @type {CountryOrUnknown}
|
|
40
|
-
* @remarks
|
|
41
|
-
*
|
|
42
|
-
* In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used.
|
|
43
|
-
*/
|
|
44
|
-
country: CountryOrUnknown;
|
|
45
|
-
/**
|
|
46
|
-
* The `valid` property represents whether the phone number uses a valid format for the parsed country or not.
|
|
47
|
-
* @type {boolean}
|
|
48
|
-
*/
|
|
49
|
-
valid: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* The `type` property represents the type of the phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid.
|
|
52
|
-
* @type {PhoneTypes}
|
|
53
|
-
*/
|
|
54
|
-
type: PhoneTypes;
|
|
55
|
-
/**
|
|
56
|
-
* The `mobile` property represents whether the phone number is possibly a mobile phone number or not.
|
|
57
|
-
* @type {boolean}
|
|
58
|
-
* @remarks
|
|
59
|
-
*
|
|
60
|
-
* This property is `true` if the phone number type is either `'MOBILE'` or `'FIXED_LINE_OR_MOBILE'`.
|
|
61
|
-
* This covers cases like in the United States and Canada where it is not possible to tell if a phone number is a mobile phone number or not based on the phone number alone.
|
|
62
|
-
*/
|
|
63
|
-
mobile: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* The `raw` property represents the phone number as a string stripped of all non-numeric characters.
|
|
66
|
-
* @type {string}
|
|
67
|
-
*/
|
|
68
|
-
raw: string;
|
|
69
|
-
/**
|
|
70
|
-
* The `national` property represents the phone number as a string in the national format for the parsed country.
|
|
71
|
-
* @type {string}
|
|
72
|
-
*/
|
|
73
|
-
national: string;
|
|
74
|
-
/**
|
|
75
|
-
* The `international` property represents the phone number as a string in the international format for the parsed country.
|
|
76
|
-
* @type {string}
|
|
77
|
-
*/
|
|
78
|
-
international: string;
|
|
79
|
-
/**
|
|
80
|
-
* The `e164` property represents the phone number as a string in the E.164 format.
|
|
81
|
-
* @type {string}
|
|
82
|
-
*/
|
|
83
|
-
e164: string;
|
|
84
|
-
/**
|
|
85
|
-
* The `timezone` property represents the estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`.
|
|
86
|
-
* @type {PossiblePhoneTimezone}
|
|
87
|
-
* @remarks
|
|
88
|
-
*
|
|
89
|
-
* In cases where the phone number's country has several timezones, the timezone with the greatest population is used.
|
|
90
|
-
* In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used.
|
|
91
|
-
*/
|
|
92
|
-
timezone: PossiblePhoneTimezone;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* The `PhoneModel` interface represents a phone number object with various properties and methods.
|
|
96
|
-
* @interface
|
|
97
|
-
*/
|
|
98
|
-
export interface PhoneModel {
|
|
99
|
-
/**
|
|
100
|
-
* The `country` property represents the country that was used to create the `Phone` instance.
|
|
101
|
-
* @type {CountryOrUnknown}
|
|
102
|
-
* @remarks
|
|
103
|
-
*
|
|
104
|
-
* In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used.
|
|
105
|
-
*/
|
|
106
|
-
country: CountryOrUnknown;
|
|
107
|
-
/**
|
|
108
|
-
* The `valid` property represents whether the phone number uses a valid format for the parsed country or not.
|
|
109
|
-
* @type {boolean}
|
|
110
|
-
*/
|
|
111
|
-
valid: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* The `type` property represents the type of the phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid.
|
|
114
|
-
* @type {PhoneTypes}
|
|
115
|
-
*/
|
|
116
|
-
type: PhoneTypes;
|
|
117
|
-
/**
|
|
118
|
-
* The `mobile` property represents whether the phone number is possibly a mobile phone number or not.
|
|
119
|
-
* @type {boolean}
|
|
120
|
-
* @remarks
|
|
121
|
-
*
|
|
122
|
-
* This property is `true` if the phone number type is either `'MOBILE'` or `'FIXED_LINE_OR_MOBILE'`.
|
|
123
|
-
* This covers cases like in the United States and Canada where it is not possible to tell if a phone number is a mobile phone number or not based on the phone number alone.
|
|
124
|
-
*/
|
|
125
|
-
mobile: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* The `raw` property represents the phone number as a string stripped of all non-numeric characters.
|
|
128
|
-
* @type {string}
|
|
129
|
-
*/
|
|
130
|
-
raw: string;
|
|
131
|
-
/**
|
|
132
|
-
* The `national` property represents the phone number as a string in the national format for the parsed country.
|
|
133
|
-
* @type {string}
|
|
134
|
-
*/
|
|
135
|
-
national: string;
|
|
136
|
-
/**
|
|
137
|
-
* The `international` property represents the phone number as a string in the international format for the parsed country.
|
|
138
|
-
* @type {string}
|
|
139
|
-
*/
|
|
140
|
-
international: string;
|
|
141
|
-
/**
|
|
142
|
-
* The `e164` property represents the phone number as a string in the E.164 format.
|
|
143
|
-
* @type {string}
|
|
144
|
-
*/
|
|
145
|
-
e164: string;
|
|
146
|
-
/**
|
|
147
|
-
* The `timezone` property represents the estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`.
|
|
148
|
-
* @type {PossiblePhoneTimezone}
|
|
149
|
-
* @remarks
|
|
150
|
-
*
|
|
151
|
-
* In cases where the phone number's country has several timezones, the timezone with the greatest population is used.
|
|
152
|
-
* In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used.
|
|
153
|
-
*/
|
|
154
|
-
timezone: PossiblePhoneTimezone;
|
|
155
|
-
/**
|
|
156
|
-
* The `toObject` method returns an object with the same properties as the `PhoneModelInstanceObject` interface.
|
|
157
|
-
* @returns {PhoneModelInstanceObject}
|
|
158
|
-
*/
|
|
159
|
-
toObject(): PhoneModelInstanceObject;
|
|
160
|
-
/**
|
|
161
|
-
* The `toJSON` method returns an object with the same properties as the `PhoneModelInstanceObject` interface.
|
|
162
|
-
* @returns {PhoneModelInstanceObject}
|
|
163
|
-
*/
|
|
164
|
-
toJSON(): PhoneModelInstanceObject;
|
|
165
|
-
/**
|
|
166
|
-
* The `toString` method returns the phone number as a string in the international format for the parsed country.
|
|
167
|
-
* @returns {string}
|
|
168
|
-
*/
|
|
169
|
-
toString(): string;
|
|
170
|
-
}
|