libphonenumber-js 1.10.64 → 1.11.1
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/CHANGELOG.md +5 -0
- package/custom.d.ts +71 -60
- package/index.d.cts +88 -81
- package/index.d.ts +88 -81
- package/package.json +1 -1
- package/types.d.cts +2 -1
- package/types.d.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -67,6 +67,11 @@ And edit the README:
|
|
|
67
67
|
|
|
68
68
|
This changelog [only](https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/16#note_594165443) mentions the changes in the code. See [Google's changelog](https://github.com/google/libphonenumber/blob/master/release_notes.txt) for metadata changes.
|
|
69
69
|
|
|
70
|
+
1.11.00 / 06.05.2024
|
|
71
|
+
====================
|
|
72
|
+
|
|
73
|
+
* (TypeScript) Fixed Tagged type to be more strict, as suggested in an [issue](https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/144) by Islam Sharabash.
|
|
74
|
+
|
|
70
75
|
1.10.17 / 08.01.2023
|
|
71
76
|
==================
|
|
72
77
|
|
package/custom.d.ts
CHANGED
|
@@ -60,65 +60,8 @@ export function parsePhoneNumberFromString(text: string, defaultCountry: Country
|
|
|
60
60
|
|
|
61
61
|
export default parsePhoneNumberFromString;
|
|
62
62
|
|
|
63
|
-
export function parse(text: string, metadata: MetadataJson): ParsedNumber;
|
|
64
|
-
export function parse(text: string, options: CountryCode | ParseNumberOptions, metadata: MetadataJson): ParsedNumber;
|
|
65
|
-
|
|
66
|
-
export function parseNumber(text: string, metadata: MetadataJson): ParsedNumber | {};
|
|
67
|
-
export function parseNumber(text: string, options: CountryCode | ParseNumberOptions, metadata: MetadataJson): ParsedNumber | {};
|
|
68
|
-
|
|
69
|
-
// `format()` and `formatCustom` are deprecated.
|
|
70
|
-
// Use `formatNumber()` and `formatNumberCustom()` instead.
|
|
71
|
-
export function format(parsedNumber: ParsedNumber, format: NumberFormat, metadata: MetadataJson): string;
|
|
72
|
-
export function format(phone: NationalNumber, format: NumberFormat, metadata: MetadataJson): string;
|
|
73
|
-
export function format(phone: NationalNumber, country: CountryCode, format: NumberFormat, metadata: MetadataJson): string;
|
|
74
|
-
|
|
75
|
-
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, metadata: MetadataJson): string;
|
|
76
|
-
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, options: FormatNumberOptions, metadata: MetadataJson): string;
|
|
77
|
-
|
|
78
|
-
export function formatNumber(phone: NationalNumber, format: NumberFormat, metadata: MetadataJson): string;
|
|
79
|
-
export function formatNumber(phone: NationalNumber, format: NumberFormat, options: FormatNumberOptions, metadata: MetadataJson): string;
|
|
80
|
-
|
|
81
|
-
export function formatNumber(phone: NationalNumber, country: CountryCode, format: NumberFormat, metadata: MetadataJson): string;
|
|
82
|
-
export function formatNumber(phone: NationalNumber, country: CountryCode, format: NumberFormat, options: FormatNumberOptions, metadata: MetadataJson): string;
|
|
83
|
-
|
|
84
|
-
export function getNumberType(parsedNumber: ParsedNumber, metadata: MetadataJson): NumberType;
|
|
85
|
-
export function getNumberType(phone: NationalNumber, metadata: MetadataJson): NumberType;
|
|
86
|
-
export function getNumberType(phone: NationalNumber, country: CountryCode, metadata: MetadataJson): NumberType;
|
|
87
|
-
|
|
88
63
|
export function getExampleNumber(country: CountryCode, examples: Examples, metadata: MetadataJson): PhoneNumber | undefined;
|
|
89
64
|
|
|
90
|
-
export function isPossibleNumber(parsedNumber: ParsedNumber, metadata: MetadataJson): boolean;
|
|
91
|
-
export function isPossibleNumber(phone: NationalNumber, metadata: MetadataJson): boolean;
|
|
92
|
-
export function isPossibleNumber(phone: NationalNumber, country: CountryCode, metadata: MetadataJson): boolean;
|
|
93
|
-
|
|
94
|
-
export function isValidNumber(parsedNumber: ParsedNumber, metadata: MetadataJson): boolean;
|
|
95
|
-
export function isValidNumber(phone: NationalNumber, metadata: MetadataJson): boolean;
|
|
96
|
-
export function isValidNumber(phone: NationalNumber, country: CountryCode, metadata: MetadataJson): boolean;
|
|
97
|
-
|
|
98
|
-
export function isValidNumberForRegion(phone: NationalNumber, country: CountryCode, metadata: MetadataJson): boolean;
|
|
99
|
-
|
|
100
|
-
// Deprecated.
|
|
101
|
-
export function findParsedNumbers(text: string, metadata: MetadataJson): NumberFoundLegacy[];
|
|
102
|
-
export function findParsedNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode }, metadata: MetadataJson): NumberFoundLegacy[];
|
|
103
|
-
|
|
104
|
-
// Deprecated.
|
|
105
|
-
export function searchParsedNumbers(text: string, metadata: MetadataJson): IterableIterator<NumberFoundLegacy>;
|
|
106
|
-
export function searchParsedNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode }, metadata: MetadataJson): IterableIterator<NumberFoundLegacy>;
|
|
107
|
-
|
|
108
|
-
// Deprecated.
|
|
109
|
-
export class ParsedNumberSearch {
|
|
110
|
-
constructor(text: string, metadata: MetadataJson);
|
|
111
|
-
constructor(text: string, options: { defaultCountry?: CountryCode }, metadata: MetadataJson);
|
|
112
|
-
hasNext(): boolean;
|
|
113
|
-
next(): NumberFoundLegacy | undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function findNumbers(text: string, metadata: MetadataJson): NumberFoundLegacy[];
|
|
117
|
-
export function findNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode, v2: true }, metadata: MetadataJson): NumberFound[];
|
|
118
|
-
|
|
119
|
-
export function searchNumbers(text: string, metadata: MetadataJson): IterableIterator<NumberFoundLegacy>;
|
|
120
|
-
export function searchNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode, v2: true }, metadata: MetadataJson): IterableIterator<NumberFound>;
|
|
121
|
-
|
|
122
65
|
export function findPhoneNumbersInText(text: string, metadata: MetadataJson): NumberFound[];
|
|
123
66
|
export function findPhoneNumbersInText(text: string, options: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extended?: boolean }, metadata: MetadataJson): NumberFound[];
|
|
124
67
|
|
|
@@ -134,8 +77,6 @@ export class PhoneNumberMatcher {
|
|
|
134
77
|
|
|
135
78
|
export function getCountries(metadata: MetadataJson): CountryCode[];
|
|
136
79
|
export function getCountryCallingCode(countryCode: CountryCode, metadata: MetadataJson): CountryCallingCode;
|
|
137
|
-
// Deprecated
|
|
138
|
-
export function getPhoneCode(countryCode: CountryCode, metadata: MetadataJson): CountryCallingCode;
|
|
139
80
|
export function getExtPrefix(countryCode: CountryCode, metadata: MetadataJson): string;
|
|
140
81
|
export function isSupportedCountry(countryCode: CountryCode, metadata: MetadataJson): boolean;
|
|
141
82
|
|
|
@@ -166,4 +107,74 @@ export class Metadata {
|
|
|
166
107
|
constructor(metadata: MetadataJson);
|
|
167
108
|
selectNumberingPlan(country: CountryCode): void;
|
|
168
109
|
numberingPlan?: NumberingPlan;
|
|
169
|
-
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Deprecated
|
|
113
|
+
export function parse(text: string, metadata: MetadataJson): ParsedNumber;
|
|
114
|
+
export function parse(text: string, options: CountryCode | ParseNumberOptions, metadata: MetadataJson): ParsedNumber;
|
|
115
|
+
|
|
116
|
+
// Deprecated
|
|
117
|
+
export function parseNumber(text: string, metadata: MetadataJson): ParsedNumber | {};
|
|
118
|
+
export function parseNumber(text: string, options: CountryCode | ParseNumberOptions, metadata: MetadataJson): ParsedNumber | {};
|
|
119
|
+
|
|
120
|
+
// Deprecated
|
|
121
|
+
export function format(parsedNumber: ParsedNumber, format: NumberFormat, metadata: MetadataJson): string;
|
|
122
|
+
export function format(phone: string, format: NumberFormat, metadata: MetadataJson): string;
|
|
123
|
+
export function format(phone: string, country: CountryCode, format: NumberFormat, metadata: MetadataJson): string;
|
|
124
|
+
|
|
125
|
+
// Deprecated
|
|
126
|
+
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, metadata: MetadataJson): string;
|
|
127
|
+
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, options: FormatNumberOptions, metadata: MetadataJson): string;
|
|
128
|
+
|
|
129
|
+
// Deprecated
|
|
130
|
+
export function formatNumber(phone: string, format: NumberFormat, metadata: MetadataJson): string;
|
|
131
|
+
export function formatNumber(phone: string, format: NumberFormat, options: FormatNumberOptions, metadata: MetadataJson): string;
|
|
132
|
+
|
|
133
|
+
// Deprecated
|
|
134
|
+
export function formatNumber(phone: string, country: CountryCode, format: NumberFormat, metadata: MetadataJson): string;
|
|
135
|
+
export function formatNumber(phone: string, country: CountryCode, format: NumberFormat, options: FormatNumberOptions, metadata: MetadataJson): string;
|
|
136
|
+
|
|
137
|
+
// Deprecated
|
|
138
|
+
export function getNumberType(parsedNumber: ParsedNumber, metadata: MetadataJson): NumberType;
|
|
139
|
+
export function getNumberType(phone: string, metadata: MetadataJson): NumberType;
|
|
140
|
+
export function getNumberType(phone: string, country: CountryCode, metadata: MetadataJson): NumberType;
|
|
141
|
+
|
|
142
|
+
// Deprecated
|
|
143
|
+
export function isPossibleNumber(parsedNumber: ParsedNumber, metadata: MetadataJson): boolean;
|
|
144
|
+
export function isPossibleNumber(phone: string, metadata: MetadataJson): boolean;
|
|
145
|
+
export function isPossibleNumber(phone: string, country: CountryCode, metadata: MetadataJson): boolean;
|
|
146
|
+
|
|
147
|
+
// Deprecated
|
|
148
|
+
export function isValidNumber(parsedNumber: ParsedNumber, metadata: MetadataJson): boolean;
|
|
149
|
+
export function isValidNumber(phone: string, metadata: MetadataJson): boolean;
|
|
150
|
+
export function isValidNumber(phone: string, country: CountryCode, metadata: MetadataJson): boolean;
|
|
151
|
+
|
|
152
|
+
// Deprecated
|
|
153
|
+
export function isValidNumberForRegion(phone: string, country: CountryCode, metadata: MetadataJson): boolean;
|
|
154
|
+
|
|
155
|
+
// Deprecated
|
|
156
|
+
export function findParsedNumbers(text: string, metadata: MetadataJson): NumberFoundLegacy[];
|
|
157
|
+
export function findParsedNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode }, metadata: MetadataJson): NumberFoundLegacy[];
|
|
158
|
+
|
|
159
|
+
// Deprecated
|
|
160
|
+
export function searchParsedNumbers(text: string, metadata: MetadataJson): IterableIterator<NumberFoundLegacy>;
|
|
161
|
+
export function searchParsedNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode }, metadata: MetadataJson): IterableIterator<NumberFoundLegacy>;
|
|
162
|
+
|
|
163
|
+
// Deprecated
|
|
164
|
+
export class ParsedNumberSearch {
|
|
165
|
+
constructor(text: string, metadata: MetadataJson);
|
|
166
|
+
constructor(text: string, options: { defaultCountry?: CountryCode }, metadata: MetadataJson);
|
|
167
|
+
hasNext(): boolean;
|
|
168
|
+
next(): NumberFoundLegacy | undefined;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Deprecated
|
|
172
|
+
export function findNumbers(text: string, metadata: MetadataJson): NumberFoundLegacy[];
|
|
173
|
+
export function findNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode, v2: true }, metadata: MetadataJson): NumberFound[];
|
|
174
|
+
|
|
175
|
+
// Deprecated
|
|
176
|
+
export function searchNumbers(text: string, metadata: MetadataJson): IterableIterator<NumberFoundLegacy>;
|
|
177
|
+
export function searchNumbers(text: string, options: CountryCode | { defaultCountry?: CountryCode, v2: true }, metadata: MetadataJson): IterableIterator<NumberFound>;
|
|
178
|
+
|
|
179
|
+
// Deprecated
|
|
180
|
+
export function getPhoneCode(countryCode: CountryCode, metadata: MetadataJson): CountryCallingCode;
|
package/index.d.cts
CHANGED
|
@@ -36,94 +36,19 @@ export {
|
|
|
36
36
|
ValidatePhoneNumberLengthResult
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
type FormatExtension = (number: string, extension: string, metadata: MetadataJson) => string
|
|
40
|
-
|
|
41
|
-
type FormatNumberOptionsWithoutIDD = {
|
|
42
|
-
v2?: boolean;
|
|
43
|
-
formatExtension?: FormatExtension;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type FormatNumberOptions = {
|
|
47
|
-
v2?: boolean;
|
|
48
|
-
fromCountry?: CountryCode;
|
|
49
|
-
humanReadable?: boolean;
|
|
50
|
-
formatExtension?: FormatExtension;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Legacy.
|
|
54
|
-
export type ParseNumberOptions = {
|
|
55
|
-
defaultCountry?: CountryCode;
|
|
56
|
-
extended?: boolean;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export interface ParsedNumber {
|
|
60
|
-
countryCallingCode?: CountryCallingCode;
|
|
61
|
-
country: CountryCode;
|
|
62
|
-
phone: NationalNumber;
|
|
63
|
-
ext?: Extension;
|
|
64
|
-
possible?: boolean;
|
|
65
|
-
valid?: boolean;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
|
|
69
|
-
export function parsePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
70
|
-
export function parsePhoneNumberWithError(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
71
|
-
|
|
72
39
|
// `parsePhoneNumberFromString()` named export is now considered legacy:
|
|
73
40
|
// it has been promoted to a default export due to being too verbose.
|
|
74
41
|
export function parsePhoneNumberFromString(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber | undefined;
|
|
75
42
|
|
|
76
43
|
export default parsePhoneNumberFromString;
|
|
77
44
|
|
|
78
|
-
export function
|
|
79
|
-
export function isPossiblePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
80
|
-
export function validatePhoneNumberLength(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): ValidatePhoneNumberLengthResult | undefined;
|
|
81
|
-
|
|
82
|
-
// `parse()` and `parseCustom` are deprecated.
|
|
83
|
-
// Use `parseNumber()` and `parseNumberCustom()` instead.
|
|
84
|
-
export function parse(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber;
|
|
85
|
-
|
|
86
|
-
export function parseNumber(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber | {};
|
|
87
|
-
|
|
88
|
-
// `format()` and `formatCustom` are deprecated.
|
|
89
|
-
// Use `formatNumber()` and `formatNumberCustom()` instead.
|
|
90
|
-
export function format(parsedNumber: ParsedNumber, format: NumberFormat): string;
|
|
91
|
-
export function format(phone: NationalNumber, format: NumberFormat): string;
|
|
92
|
-
export function format(phone: NationalNumber, country: CountryCode, format: NumberFormat): string;
|
|
93
|
-
|
|
94
|
-
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
95
|
-
export function formatNumber(phone: NationalNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
96
|
-
export function formatNumber(phone: NationalNumber, country: CountryCode, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
97
|
-
|
|
98
|
-
export function getNumberType(parsedNumber: ParsedNumber): NumberType;
|
|
99
|
-
export function getNumberType(phone: NationalNumber, country?: CountryCode): NumberType;
|
|
45
|
+
export function parsePhoneNumberWithError(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
100
46
|
|
|
101
47
|
export function getExampleNumber(country: CountryCode, examples: Examples): PhoneNumber | undefined;
|
|
102
48
|
|
|
103
|
-
export function
|
|
104
|
-
export function
|
|
105
|
-
|
|
106
|
-
export function isValidNumber(parsedNumber: ParsedNumber): boolean;
|
|
107
|
-
export function isValidNumber(phone: NationalNumber, country?: CountryCode): boolean;
|
|
108
|
-
|
|
109
|
-
export function isValidNumberForRegion(phone: NationalNumber, country: CountryCode): boolean;
|
|
110
|
-
|
|
111
|
-
// Deprecated.
|
|
112
|
-
export function findParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): NumberFoundLegacy[];
|
|
113
|
-
export function searchParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): IterableIterator<NumberFoundLegacy>;
|
|
114
|
-
|
|
115
|
-
// Deprecated.
|
|
116
|
-
export class ParsedNumberSearch {
|
|
117
|
-
constructor(text: string, options?: { defaultCountry?: CountryCode });
|
|
118
|
-
hasNext(): boolean;
|
|
119
|
-
next(): NumberFoundLegacy | undefined;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function findNumbers(text: string, options?: CountryCode): NumberFoundLegacy[];
|
|
123
|
-
export function searchNumbers(text: string, options?: CountryCode): IterableIterator<NumberFoundLegacy>;
|
|
124
|
-
|
|
125
|
-
export function findNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): NumberFound[];
|
|
126
|
-
export function searchNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): IterableIterator<NumberFound>;
|
|
49
|
+
export function isValidPhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
50
|
+
export function isPossiblePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
51
|
+
export function validatePhoneNumberLength(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): ValidatePhoneNumberLengthResult | undefined;
|
|
127
52
|
|
|
128
53
|
export function findPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extended?: boolean }): NumberFound[];
|
|
129
54
|
export function searchPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extended?: boolean }): IterableIterator<NumberFound>;
|
|
@@ -136,8 +61,6 @@ export class PhoneNumberMatcher {
|
|
|
136
61
|
|
|
137
62
|
export function getCountries(): CountryCode[];
|
|
138
63
|
export function getCountryCallingCode(countryCode: CountryCode): CountryCallingCode;
|
|
139
|
-
// Deprecated.
|
|
140
|
-
export function getPhoneCode(countryCode: CountryCode): CountryCallingCode;
|
|
141
64
|
export function getExtPrefix(countryCode: CountryCode): string;
|
|
142
65
|
export function isSupportedCountry(countryCode: string): countryCode is CountryCode;
|
|
143
66
|
|
|
@@ -169,3 +92,87 @@ export class Metadata {
|
|
|
169
92
|
selectNumberingPlan(country: CountryCode): void;
|
|
170
93
|
numberingPlan?: NumberingPlan;
|
|
171
94
|
}
|
|
95
|
+
|
|
96
|
+
// Deprecated
|
|
97
|
+
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
|
|
98
|
+
export function parsePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
99
|
+
|
|
100
|
+
// Deprecated
|
|
101
|
+
export interface ParsedNumber {
|
|
102
|
+
countryCallingCode?: CountryCallingCode;
|
|
103
|
+
country: CountryCode;
|
|
104
|
+
phone: NationalNumber;
|
|
105
|
+
ext?: Extension;
|
|
106
|
+
possible?: boolean;
|
|
107
|
+
valid?: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Deprecated
|
|
111
|
+
export type ParseNumberOptions = {
|
|
112
|
+
defaultCountry?: CountryCode;
|
|
113
|
+
extended?: boolean;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// Deprecated
|
|
117
|
+
export function parse(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber;
|
|
118
|
+
|
|
119
|
+
// Deprecated
|
|
120
|
+
export function parseNumber(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber | {};
|
|
121
|
+
|
|
122
|
+
// Deprecated
|
|
123
|
+
type FormatExtension = (number: string, extension: string, metadata: MetadataJson) => string
|
|
124
|
+
|
|
125
|
+
// Deprecated
|
|
126
|
+
export type FormatNumberOptions = {
|
|
127
|
+
v2?: boolean;
|
|
128
|
+
fromCountry?: CountryCode;
|
|
129
|
+
humanReadable?: boolean;
|
|
130
|
+
formatExtension?: FormatExtension;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Deprecated
|
|
134
|
+
export function format(parsedNumber: ParsedNumber, format: NumberFormat): string;
|
|
135
|
+
export function format(phone: string, format: NumberFormat): string;
|
|
136
|
+
export function format(phone: string, country: CountryCode, format: NumberFormat): string;
|
|
137
|
+
|
|
138
|
+
// Deprecated
|
|
139
|
+
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
140
|
+
export function formatNumber(phone: string, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
141
|
+
export function formatNumber(phone: string, country: CountryCode, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
142
|
+
|
|
143
|
+
// Deprecated
|
|
144
|
+
export function getNumberType(parsedNumber: ParsedNumber): NumberType;
|
|
145
|
+
export function getNumberType(phone: string, country?: CountryCode): NumberType;
|
|
146
|
+
|
|
147
|
+
// Deprecated
|
|
148
|
+
export function isPossibleNumber(parsedNumber: ParsedNumber): boolean;
|
|
149
|
+
export function isPossibleNumber(phone: string, country?: CountryCode): boolean;
|
|
150
|
+
|
|
151
|
+
// Deprecated
|
|
152
|
+
export function isValidNumber(parsedNumber: ParsedNumber): boolean;
|
|
153
|
+
export function isValidNumber(phone: string, country?: CountryCode): boolean;
|
|
154
|
+
|
|
155
|
+
// Deprecated
|
|
156
|
+
export function isValidNumberForRegion(phone: string, country: CountryCode): boolean;
|
|
157
|
+
|
|
158
|
+
// Deprecated
|
|
159
|
+
export function findParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): NumberFoundLegacy[];
|
|
160
|
+
export function searchParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): IterableIterator<NumberFoundLegacy>;
|
|
161
|
+
|
|
162
|
+
// Deprecated
|
|
163
|
+
export class ParsedNumberSearch {
|
|
164
|
+
constructor(text: string, options?: { defaultCountry?: CountryCode });
|
|
165
|
+
hasNext(): boolean;
|
|
166
|
+
next(): NumberFoundLegacy | undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Deprecated
|
|
170
|
+
export function findNumbers(text: string, options?: CountryCode): NumberFoundLegacy[];
|
|
171
|
+
export function searchNumbers(text: string, options?: CountryCode): IterableIterator<NumberFoundLegacy>;
|
|
172
|
+
|
|
173
|
+
// Deprecated
|
|
174
|
+
export function findNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): NumberFound[];
|
|
175
|
+
export function searchNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): IterableIterator<NumberFound>;
|
|
176
|
+
|
|
177
|
+
// Deprecated
|
|
178
|
+
export function getPhoneCode(countryCode: CountryCode): CountryCallingCode;
|
package/index.d.ts
CHANGED
|
@@ -36,94 +36,19 @@ export {
|
|
|
36
36
|
ValidatePhoneNumberLengthResult
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
type FormatExtension = (number: string, extension: string, metadata: MetadataJson) => string
|
|
40
|
-
|
|
41
|
-
type FormatNumberOptionsWithoutIDD = {
|
|
42
|
-
v2?: boolean;
|
|
43
|
-
formatExtension?: FormatExtension;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type FormatNumberOptions = {
|
|
47
|
-
v2?: boolean;
|
|
48
|
-
fromCountry?: CountryCode;
|
|
49
|
-
humanReadable?: boolean;
|
|
50
|
-
formatExtension?: FormatExtension;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Legacy.
|
|
54
|
-
export type ParseNumberOptions = {
|
|
55
|
-
defaultCountry?: CountryCode;
|
|
56
|
-
extended?: boolean;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export interface ParsedNumber {
|
|
60
|
-
countryCallingCode?: CountryCallingCode;
|
|
61
|
-
country: CountryCode;
|
|
62
|
-
phone: NationalNumber;
|
|
63
|
-
ext?: Extension;
|
|
64
|
-
possible?: boolean;
|
|
65
|
-
valid?: boolean;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
|
|
69
|
-
export function parsePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
70
|
-
export function parsePhoneNumberWithError(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
71
|
-
|
|
72
39
|
// `parsePhoneNumberFromString()` named export is now considered legacy:
|
|
73
40
|
// it has been promoted to a default export due to being too verbose.
|
|
74
41
|
export function parsePhoneNumberFromString(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber | undefined;
|
|
75
42
|
|
|
76
43
|
export default parsePhoneNumberFromString;
|
|
77
44
|
|
|
78
|
-
export function
|
|
79
|
-
export function isPossiblePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
80
|
-
export function validatePhoneNumberLength(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): ValidatePhoneNumberLengthResult | undefined;
|
|
81
|
-
|
|
82
|
-
// `parse()` and `parseCustom` are deprecated.
|
|
83
|
-
// Use `parseNumber()` and `parseNumberCustom()` instead.
|
|
84
|
-
export function parse(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber;
|
|
85
|
-
|
|
86
|
-
export function parseNumber(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber | {};
|
|
87
|
-
|
|
88
|
-
// `format()` and `formatCustom` are deprecated.
|
|
89
|
-
// Use `formatNumber()` and `formatNumberCustom()` instead.
|
|
90
|
-
export function format(parsedNumber: ParsedNumber, format: NumberFormat): string;
|
|
91
|
-
export function format(phone: NationalNumber, format: NumberFormat): string;
|
|
92
|
-
export function format(phone: NationalNumber, country: CountryCode, format: NumberFormat): string;
|
|
93
|
-
|
|
94
|
-
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
95
|
-
export function formatNumber(phone: NationalNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
96
|
-
export function formatNumber(phone: NationalNumber, country: CountryCode, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
97
|
-
|
|
98
|
-
export function getNumberType(parsedNumber: ParsedNumber): NumberType;
|
|
99
|
-
export function getNumberType(phone: NationalNumber, country?: CountryCode): NumberType;
|
|
45
|
+
export function parsePhoneNumberWithError(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
100
46
|
|
|
101
47
|
export function getExampleNumber(country: CountryCode, examples: Examples): PhoneNumber | undefined;
|
|
102
48
|
|
|
103
|
-
export function
|
|
104
|
-
export function
|
|
105
|
-
|
|
106
|
-
export function isValidNumber(parsedNumber: ParsedNumber): boolean;
|
|
107
|
-
export function isValidNumber(phone: NationalNumber, country?: CountryCode): boolean;
|
|
108
|
-
|
|
109
|
-
export function isValidNumberForRegion(phone: NationalNumber, country: CountryCode): boolean;
|
|
110
|
-
|
|
111
|
-
// Deprecated.
|
|
112
|
-
export function findParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): NumberFoundLegacy[];
|
|
113
|
-
export function searchParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): IterableIterator<NumberFoundLegacy>;
|
|
114
|
-
|
|
115
|
-
// Deprecated.
|
|
116
|
-
export class ParsedNumberSearch {
|
|
117
|
-
constructor(text: string, options?: { defaultCountry?: CountryCode });
|
|
118
|
-
hasNext(): boolean;
|
|
119
|
-
next(): NumberFoundLegacy | undefined;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function findNumbers(text: string, options?: CountryCode): NumberFoundLegacy[];
|
|
123
|
-
export function searchNumbers(text: string, options?: CountryCode): IterableIterator<NumberFoundLegacy>;
|
|
124
|
-
|
|
125
|
-
export function findNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): NumberFound[];
|
|
126
|
-
export function searchNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): IterableIterator<NumberFound>;
|
|
49
|
+
export function isValidPhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
50
|
+
export function isPossiblePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
51
|
+
export function validatePhoneNumberLength(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): ValidatePhoneNumberLengthResult | undefined;
|
|
127
52
|
|
|
128
53
|
export function findPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extended?: boolean }): NumberFound[];
|
|
129
54
|
export function searchPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extended?: boolean }): IterableIterator<NumberFound>;
|
|
@@ -136,8 +61,6 @@ export class PhoneNumberMatcher {
|
|
|
136
61
|
|
|
137
62
|
export function getCountries(): CountryCode[];
|
|
138
63
|
export function getCountryCallingCode(countryCode: CountryCode): CountryCallingCode;
|
|
139
|
-
// Deprecated.
|
|
140
|
-
export function getPhoneCode(countryCode: CountryCode): CountryCallingCode;
|
|
141
64
|
export function getExtPrefix(countryCode: CountryCode): string;
|
|
142
65
|
export function isSupportedCountry(countryCode: string): countryCode is CountryCode;
|
|
143
66
|
|
|
@@ -169,3 +92,87 @@ export class Metadata {
|
|
|
169
92
|
selectNumberingPlan(country: CountryCode): void;
|
|
170
93
|
numberingPlan?: NumberingPlan;
|
|
171
94
|
}
|
|
95
|
+
|
|
96
|
+
// Deprecated
|
|
97
|
+
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
|
|
98
|
+
export function parsePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber;
|
|
99
|
+
|
|
100
|
+
// Deprecated
|
|
101
|
+
export interface ParsedNumber {
|
|
102
|
+
countryCallingCode?: CountryCallingCode;
|
|
103
|
+
country: CountryCode;
|
|
104
|
+
phone: NationalNumber;
|
|
105
|
+
ext?: Extension;
|
|
106
|
+
possible?: boolean;
|
|
107
|
+
valid?: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Deprecated
|
|
111
|
+
export type ParseNumberOptions = {
|
|
112
|
+
defaultCountry?: CountryCode;
|
|
113
|
+
extended?: boolean;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// Deprecated
|
|
117
|
+
export function parse(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber;
|
|
118
|
+
|
|
119
|
+
// Deprecated
|
|
120
|
+
export function parseNumber(text: string, options?: CountryCode | ParseNumberOptions): ParsedNumber | {};
|
|
121
|
+
|
|
122
|
+
// Deprecated
|
|
123
|
+
type FormatExtension = (number: string, extension: string, metadata: MetadataJson) => string
|
|
124
|
+
|
|
125
|
+
// Deprecated
|
|
126
|
+
export type FormatNumberOptions = {
|
|
127
|
+
v2?: boolean;
|
|
128
|
+
fromCountry?: CountryCode;
|
|
129
|
+
humanReadable?: boolean;
|
|
130
|
+
formatExtension?: FormatExtension;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Deprecated
|
|
134
|
+
export function format(parsedNumber: ParsedNumber, format: NumberFormat): string;
|
|
135
|
+
export function format(phone: string, format: NumberFormat): string;
|
|
136
|
+
export function format(phone: string, country: CountryCode, format: NumberFormat): string;
|
|
137
|
+
|
|
138
|
+
// Deprecated
|
|
139
|
+
export function formatNumber(parsedNumber: ParsedNumber, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
140
|
+
export function formatNumber(phone: string, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
141
|
+
export function formatNumber(phone: string, country: CountryCode, format: NumberFormat, options?: FormatNumberOptions): string;
|
|
142
|
+
|
|
143
|
+
// Deprecated
|
|
144
|
+
export function getNumberType(parsedNumber: ParsedNumber): NumberType;
|
|
145
|
+
export function getNumberType(phone: string, country?: CountryCode): NumberType;
|
|
146
|
+
|
|
147
|
+
// Deprecated
|
|
148
|
+
export function isPossibleNumber(parsedNumber: ParsedNumber): boolean;
|
|
149
|
+
export function isPossibleNumber(phone: string, country?: CountryCode): boolean;
|
|
150
|
+
|
|
151
|
+
// Deprecated
|
|
152
|
+
export function isValidNumber(parsedNumber: ParsedNumber): boolean;
|
|
153
|
+
export function isValidNumber(phone: string, country?: CountryCode): boolean;
|
|
154
|
+
|
|
155
|
+
// Deprecated
|
|
156
|
+
export function isValidNumberForRegion(phone: string, country: CountryCode): boolean;
|
|
157
|
+
|
|
158
|
+
// Deprecated
|
|
159
|
+
export function findParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): NumberFoundLegacy[];
|
|
160
|
+
export function searchParsedNumbers(text: string, options?: CountryCode | { defaultCountry?: CountryCode }): IterableIterator<NumberFoundLegacy>;
|
|
161
|
+
|
|
162
|
+
// Deprecated
|
|
163
|
+
export class ParsedNumberSearch {
|
|
164
|
+
constructor(text: string, options?: { defaultCountry?: CountryCode });
|
|
165
|
+
hasNext(): boolean;
|
|
166
|
+
next(): NumberFoundLegacy | undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Deprecated
|
|
170
|
+
export function findNumbers(text: string, options?: CountryCode): NumberFoundLegacy[];
|
|
171
|
+
export function searchNumbers(text: string, options?: CountryCode): IterableIterator<NumberFoundLegacy>;
|
|
172
|
+
|
|
173
|
+
// Deprecated
|
|
174
|
+
export function findNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): NumberFound[];
|
|
175
|
+
export function searchNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): IterableIterator<NumberFound>;
|
|
176
|
+
|
|
177
|
+
// Deprecated
|
|
178
|
+
export function getPhoneCode(countryCode: CountryCode): CountryCallingCode;
|
package/package.json
CHANGED
package/types.d.cts
CHANGED
|
@@ -86,7 +86,7 @@ export type NumberType = undefined | 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST
|
|
|
86
86
|
// How would it cast it to an `E164Number`? Using `as` keyword?
|
|
87
87
|
// In that case it wouldn't really make any difference from allowing it to assign a `string` to a `E164Number` variable directly.
|
|
88
88
|
//
|
|
89
|
-
type Tagged<A, T> = A & { __tag
|
|
89
|
+
type Tagged<A, T> = A & { __tag: T };
|
|
90
90
|
|
|
91
91
|
export type E164Number = Tagged<string, "E164Number">;
|
|
92
92
|
export type NationalNumber = Tagged<string, "NationalNumber">;
|
|
@@ -139,6 +139,7 @@ export interface NumberFound {
|
|
|
139
139
|
endsAt: number;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
// Deprecated
|
|
142
143
|
export interface NumberFoundLegacy {
|
|
143
144
|
country: CountryCode;
|
|
144
145
|
phone: NationalNumber;
|
package/types.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export type NumberType = undefined | 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST
|
|
|
86
86
|
// How would it cast it to an `E164Number`? Using `as` keyword?
|
|
87
87
|
// In that case it wouldn't really make any difference from allowing it to assign a `string` to a `E164Number` variable directly.
|
|
88
88
|
//
|
|
89
|
-
type Tagged<A, T> = A & { __tag
|
|
89
|
+
type Tagged<A, T> = A & { __tag: T };
|
|
90
90
|
|
|
91
91
|
export type E164Number = Tagged<string, "E164Number">;
|
|
92
92
|
export type NationalNumber = Tagged<string, "NationalNumber">;
|
|
@@ -139,6 +139,7 @@ export interface NumberFound {
|
|
|
139
139
|
endsAt: number;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
// Deprecated
|
|
142
143
|
export interface NumberFoundLegacy {
|
|
143
144
|
country: CountryCode;
|
|
144
145
|
phone: NationalNumber;
|