libphonenumber-js 1.11.0 → 1.11.2

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.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 isValidPhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
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 isPossibleNumber(parsedNumber: ParsedNumber): boolean;
104
- export function isPossibleNumber(phone: NationalNumber, country?: CountryCode): boolean;
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;