@indodev/toolkit 0.4.0 → 0.4.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/README.md +19 -3
- package/dist/index.cjs +66 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +66 -49
- package/dist/index.js.map +1 -1
- package/dist/parse-BDfy3aQw.d.cts +542 -0
- package/dist/parse-BDfy3aQw.d.ts +542 -0
- package/dist/phone/index.cjs +82 -49
- package/dist/phone/index.cjs.map +1 -1
- package/dist/phone/index.d.cts +38 -485
- package/dist/phone/index.d.ts +38 -485
- package/dist/phone/index.js +80 -50
- package/dist/phone/index.js.map +1 -1
- package/package.json +1 -1
package/dist/phone/index.d.ts
CHANGED
|
@@ -1,528 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
* Validates an Indonesian phone number format.
|
|
3
|
-
*
|
|
4
|
-
* Accepts multiple input formats:
|
|
5
|
-
* - National format: 08xx-xxxx-xxxx or 08xxxxxxxxxx
|
|
6
|
-
* - International with +: +62 8xx-xxxx-xxxx or +628xxxxxxxxxx
|
|
7
|
-
* - International without +: 62 8xx-xxxx-xxxx or 628xxxxxxxxxx
|
|
8
|
-
*
|
|
9
|
-
* For mobile numbers, validates:
|
|
10
|
-
* - Starts with 08 (national) or 628 (international)
|
|
11
|
-
* - Has valid operator prefix (0811, 0812, 0817, etc.)
|
|
12
|
-
* - Total length is 10-13 digits (after removing non-digits)
|
|
13
|
-
*
|
|
14
|
-
* For landline numbers, validates:
|
|
15
|
-
* - Starts with 0 followed by area code (021, 022, etc.)
|
|
16
|
-
* - Total length is appropriate for landline
|
|
17
|
-
*
|
|
18
|
-
* @param phone - The phone number string to validate
|
|
19
|
-
* @returns `true` if the phone number is valid, `false` otherwise
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* Valid mobile number (national):
|
|
23
|
-
* ```typescript
|
|
24
|
-
* validatePhoneNumber('081234567890'); // true
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* Valid mobile number (international):
|
|
29
|
-
* ```typescript
|
|
30
|
-
* validatePhoneNumber('+6281234567890'); // true
|
|
31
|
-
* validatePhoneNumber('6281234567890'); // true
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* With separators:
|
|
36
|
-
* ```typescript
|
|
37
|
-
* validatePhoneNumber('0812-3456-7890'); // true
|
|
38
|
-
* validatePhoneNumber('+62 812-3456-7890'); // true
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* Invalid numbers:
|
|
43
|
-
* ```typescript
|
|
44
|
-
* validatePhoneNumber('1234'); // false - too short
|
|
45
|
-
* validatePhoneNumber('08001234567'); // false - invalid prefix
|
|
46
|
-
* validatePhoneNumber('+1234567890'); // false - wrong country code
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
declare function validatePhoneNumber(phone: string): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Checks if a phone number is a mobile number.
|
|
54
|
-
*
|
|
55
|
-
* @param phone - The phone number to check
|
|
56
|
-
* @returns `true` if it's a mobile number (08xx), `false` otherwise
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* isMobileNumber('081234567890'); // true
|
|
61
|
-
* isMobileNumber('+6281234567890'); // true
|
|
62
|
-
* isMobileNumber('0212345678'); // false (landline)
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
|
-
declare function isMobileNumber(phone: string): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Checks if a phone number is a landline number.
|
|
70
|
-
*
|
|
71
|
-
* @param phone - The phone number to check
|
|
72
|
-
* @returns `true` if it's a landline number, `false` otherwise
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* isLandlineNumber('0212345678'); // true
|
|
77
|
-
* isLandlineNumber('081234567890'); // false (mobile)
|
|
78
|
-
* ```
|
|
79
|
-
*
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
declare function isLandlineNumber(phone: string): boolean;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Format types for Indonesian phone numbers.
|
|
86
|
-
*
|
|
87
|
-
* - `international`: +62 format with spaces (e.g., '+62 812-3456-7890')
|
|
88
|
-
* - `national`: 08xx format with dashes (e.g., '0812-3456-7890')
|
|
89
|
-
* - `e164`: International format without spaces (e.g., '6281234567890')
|
|
90
|
-
* - `display`: Formatted for display with separators (same as national)
|
|
91
|
-
*
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
|
-
type PhoneFormat = 'international' | 'national' | 'e164' | 'display';
|
|
95
|
-
/**
|
|
96
|
-
* Information extracted from a valid Indonesian phone number.
|
|
97
|
-
*
|
|
98
|
-
* Contains parsed data including country code, operator, formatted variants,
|
|
99
|
-
* and validation status.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* const info: PhoneInfo = {
|
|
104
|
-
* countryCode: '62',
|
|
105
|
-
* operator: 'Telkomsel',
|
|
106
|
-
* number: '81234567890',
|
|
107
|
-
* formatted: {
|
|
108
|
-
* international: '+62 812-3456-7890',
|
|
109
|
-
* national: '0812-3456-7890',
|
|
110
|
-
* e164: '6281234567890',
|
|
111
|
-
* },
|
|
112
|
-
* isValid: true,
|
|
113
|
-
* isMobile: true,
|
|
114
|
-
* isLandline: false,
|
|
115
|
-
* };
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* @public
|
|
119
|
-
*/
|
|
120
|
-
interface PhoneInfo {
|
|
121
|
-
/**
|
|
122
|
-
* Country code (always '62' for Indonesia).
|
|
123
|
-
*/
|
|
124
|
-
countryCode: string;
|
|
125
|
-
/**
|
|
126
|
-
* Mobile operator name, or `null` if not detected.
|
|
127
|
-
*
|
|
128
|
-
* Possible values: 'Telkomsel', 'XL', 'Indosat', 'Tri', 'Smartfren', 'Axis'
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```typescript
|
|
132
|
-
* 'Telkomsel' // for 0812, 0813, 0821, 0822, 0851, 0852, 0853
|
|
133
|
-
* 'XL' // for 0817, 0818, 0819, 0859, 0877, 0878
|
|
134
|
-
* null // if operator cannot be determined
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
operator: string | null;
|
|
138
|
-
/**
|
|
139
|
-
* Raw phone number without country code or leading zero.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```typescript
|
|
143
|
-
* '81234567890' // from '081234567890' or '+6281234567890'
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
number: string;
|
|
147
|
-
/**
|
|
148
|
-
* Phone number in various formatted styles.
|
|
149
|
-
*/
|
|
150
|
-
formatted: {
|
|
151
|
-
/** International format with country code: '+62 812-3456-7890' */
|
|
152
|
-
international: string;
|
|
153
|
-
/** National format with leading zero: '0812-3456-7890' */
|
|
154
|
-
national: string;
|
|
155
|
-
/** E.164 format (no spaces/dashes): '6281234567890' */
|
|
156
|
-
e164: string;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Whether the phone number passed validation checks.
|
|
160
|
-
*/
|
|
161
|
-
isValid: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Whether this is a mobile number (08xx).
|
|
164
|
-
*/
|
|
165
|
-
isMobile: boolean;
|
|
166
|
-
/**
|
|
167
|
-
* Whether this is a landline number (02x, 04x, etc).
|
|
168
|
-
*/
|
|
169
|
-
isLandline: boolean;
|
|
170
|
-
/**
|
|
171
|
-
* Region name for landline numbers, or `null` for mobile.
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* ```typescript
|
|
175
|
-
* 'Jakarta' // for 021 area code
|
|
176
|
-
* 'Bandung' // for 022 area code
|
|
177
|
-
* null // for mobile numbers
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
region?: string | null;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Options for masking phone numbers.
|
|
184
|
-
*
|
|
185
|
-
* Controls how many digits to show at the start and end,
|
|
186
|
-
* what character to use for masking, and optional separators.
|
|
187
|
-
*
|
|
188
|
-
* @example
|
|
189
|
-
* Default masking:
|
|
190
|
-
* ```typescript
|
|
191
|
-
* { start: 4, end: 4, char: '*' }
|
|
192
|
-
* // '0812****7890'
|
|
193
|
-
* ```
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* With separator:
|
|
197
|
-
* ```typescript
|
|
198
|
-
* { start: 4, end: 4, char: '*', separator: '-' }
|
|
199
|
-
* // '0812-****-7890'
|
|
200
|
-
* ```
|
|
201
|
-
*
|
|
202
|
-
* @public
|
|
203
|
-
*/
|
|
204
|
-
interface MaskOptions {
|
|
205
|
-
/**
|
|
206
|
-
* Number of digits to show at the start.
|
|
207
|
-
*
|
|
208
|
-
* @defaultValue 4
|
|
209
|
-
*/
|
|
210
|
-
start?: number;
|
|
211
|
-
/**
|
|
212
|
-
* Number of digits to show at the end.
|
|
213
|
-
*
|
|
214
|
-
* @defaultValue 4
|
|
215
|
-
*/
|
|
216
|
-
end?: number;
|
|
217
|
-
/**
|
|
218
|
-
* Character to use for masking hidden digits.
|
|
219
|
-
*
|
|
220
|
-
* @defaultValue '*'
|
|
221
|
-
*/
|
|
222
|
-
char?: string;
|
|
223
|
-
/**
|
|
224
|
-
* Optional separator to add between groups of digits.
|
|
225
|
-
*
|
|
226
|
-
* @defaultValue undefined
|
|
227
|
-
*/
|
|
228
|
-
separator?: string;
|
|
229
|
-
}
|
|
1
|
+
export { M as MaskOptions, O as OperatorName, P as PhoneFormat, l as PhoneInfo, d as cleanPhoneNumber, f as formatPhoneNumber, h as generateSmsLink, j as generateTelLink, e as generateWALink, g as getOperator, a as isLandlineNumber, i as isMobileNumber, k as isProvider, m as maskPhoneNumber, p as parsePhoneNumber, c as toE164, t as toInternational, b as toNational, v as validatePhoneNumber } from '../parse-BDfy3aQw.js';
|
|
230
2
|
|
|
231
3
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* Accepts various input formats and converts to the desired output format.
|
|
235
|
-
* Automatically adds appropriate separators for readability.
|
|
236
|
-
*
|
|
237
|
-
* @param phone - The phone number to format
|
|
238
|
-
* @param format - Target format ('international', 'national', 'e164', 'display')
|
|
239
|
-
* @returns Formatted phone number, or original string if invalid
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* International format:
|
|
243
|
-
* ```typescript
|
|
244
|
-
* formatPhoneNumber('081234567890', 'international');
|
|
245
|
-
* // '+62 812-3456-7890'
|
|
246
|
-
* ```
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* National format:
|
|
250
|
-
* ```typescript
|
|
251
|
-
* formatPhoneNumber('+6281234567890', 'national');
|
|
252
|
-
* // '0812-3456-7890'
|
|
253
|
-
* ```
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* E.164 format (no spaces/dashes):
|
|
257
|
-
* ```typescript
|
|
258
|
-
* formatPhoneNumber('0812-3456-7890', 'e164');
|
|
259
|
-
* // '6281234567890'
|
|
260
|
-
* ```
|
|
261
|
-
*
|
|
262
|
-
* @public
|
|
263
|
-
*/
|
|
264
|
-
declare function formatPhoneNumber(phone: string, format?: PhoneFormat): string;
|
|
265
|
-
/**
|
|
266
|
-
* Converts a phone number to international format (+62 xxx-xxxx-xxxx).
|
|
267
|
-
*
|
|
268
|
-
* @param phone - The phone number to convert
|
|
269
|
-
* @returns Phone number in international format with separators
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* ```typescript
|
|
273
|
-
* toInternational('081234567890');
|
|
274
|
-
* // '+62 812-3456-7890'
|
|
275
|
-
* ```
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
* Already international:
|
|
279
|
-
* ```typescript
|
|
280
|
-
* toInternational('+6281234567890');
|
|
281
|
-
* // '+62 812-3456-7890'
|
|
282
|
-
* ```
|
|
283
|
-
*
|
|
284
|
-
* @public
|
|
285
|
-
*/
|
|
286
|
-
declare function toInternational(phone: string): string;
|
|
287
|
-
/**
|
|
288
|
-
* Converts a phone number to national format (08xx-xxxx-xxxx).
|
|
289
|
-
*
|
|
290
|
-
* @param phone - The phone number to convert
|
|
291
|
-
* @returns Phone number in national format with dashes
|
|
292
|
-
*
|
|
293
|
-
* @example
|
|
294
|
-
* ```typescript
|
|
295
|
-
* toNational('+6281234567890');
|
|
296
|
-
* // '0812-3456-7890'
|
|
297
|
-
* ```
|
|
298
|
-
*
|
|
299
|
-
* @example
|
|
300
|
-
* Already national:
|
|
301
|
-
* ```typescript
|
|
302
|
-
* toNational('081234567890');
|
|
303
|
-
* // '0812-3456-7890'
|
|
304
|
-
* ```
|
|
305
|
-
*
|
|
306
|
-
* @public
|
|
307
|
-
*/
|
|
308
|
-
declare function toNational(phone: string): string;
|
|
309
|
-
/**
|
|
310
|
-
* Converts a phone number to E.164 format (6281234567890).
|
|
311
|
-
*
|
|
312
|
-
* E.164 is the international standard format without spaces or dashes.
|
|
313
|
-
* Suitable for API calls and database storage.
|
|
314
|
-
*
|
|
315
|
-
* @param phone - The phone number to convert
|
|
316
|
-
* @returns Phone number in E.164 format
|
|
317
|
-
*
|
|
318
|
-
* @example
|
|
319
|
-
* ```typescript
|
|
320
|
-
* toE164('0812-3456-7890');
|
|
321
|
-
* // '6281234567890'
|
|
322
|
-
* ```
|
|
323
|
-
*
|
|
324
|
-
* @example
|
|
325
|
-
* From international format:
|
|
326
|
-
* ```typescript
|
|
327
|
-
* toE164('+62 812-3456-7890');
|
|
328
|
-
* // '6281234567890'
|
|
329
|
-
* ```
|
|
330
|
-
*
|
|
331
|
-
* @public
|
|
332
|
-
*/
|
|
333
|
-
declare function toE164(phone: string): string;
|
|
334
|
-
/**
|
|
335
|
-
* Removes all non-digit characters from a phone number, preserving leading +.
|
|
336
|
-
*
|
|
337
|
-
* @param phone - The phone number to clean
|
|
338
|
-
* @returns Cleaned phone number with only digits (and optional leading +)
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* ```typescript
|
|
342
|
-
* cleanPhoneNumber('0812-3456-7890');
|
|
343
|
-
* // '081234567890'
|
|
344
|
-
* ```
|
|
345
|
-
*
|
|
346
|
-
* @example
|
|
347
|
-
* ```typescript
|
|
348
|
-
* cleanPhoneNumber('+62 812 3456 7890');
|
|
349
|
-
* // '+6281234567890'
|
|
350
|
-
* ```
|
|
351
|
-
*
|
|
352
|
-
* @public
|
|
353
|
-
*/
|
|
354
|
-
declare function cleanPhoneNumber(phone: string): string;
|
|
355
|
-
/**
|
|
356
|
-
* Masks a phone number for privacy protection.
|
|
4
|
+
* Normalizes a cleaned phone number to national format (0xxx).
|
|
357
5
|
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
6
|
+
* Accepts pre-cleaned phone string (digits only, optional leading +).
|
|
7
|
+
* Use `cleanPhoneNumber()` first if input may contain separators.
|
|
360
8
|
*
|
|
361
|
-
* @param phone -
|
|
362
|
-
* @
|
|
363
|
-
* @returns Masked phone number, or original string if invalid
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* Default masking:
|
|
367
|
-
* ```typescript
|
|
368
|
-
* maskPhoneNumber('081234567890');
|
|
369
|
-
* // '0812****7890'
|
|
370
|
-
* ```
|
|
9
|
+
* @param phone - Cleaned phone number string
|
|
10
|
+
* @returns Phone number in 08xx format, or empty string if invalid
|
|
371
11
|
*
|
|
372
12
|
* @example
|
|
373
|
-
* Custom mask character:
|
|
374
13
|
* ```typescript
|
|
375
|
-
*
|
|
376
|
-
* // '
|
|
14
|
+
* normalizePhoneNumber('+6281234567890'); // '081234567890'
|
|
15
|
+
* normalizePhoneNumber('6281234567890'); // '081234567890'
|
|
16
|
+
* normalizePhoneNumber('081234567890'); // '081234567890'
|
|
377
17
|
* ```
|
|
378
18
|
*
|
|
379
19
|
* @example
|
|
380
|
-
*
|
|
20
|
+
* Invalid inputs return empty string:
|
|
381
21
|
* ```typescript
|
|
382
|
-
*
|
|
383
|
-
* // '
|
|
22
|
+
* normalizePhoneNumber(''); // ''
|
|
23
|
+
* normalizePhoneNumber('620812345678'); // '' (620 is not valid country code pattern)
|
|
24
|
+
* normalizePhoneNumber('invalid'); // ''
|
|
384
25
|
* ```
|
|
385
26
|
*
|
|
386
27
|
* @public
|
|
387
28
|
*/
|
|
388
|
-
declare function
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Generates a WhatsApp click-to-chat link.
|
|
392
|
-
*
|
|
393
|
-
* @param phone - The Indonesian phone number
|
|
394
|
-
* @param message - Optional pre-filled message
|
|
395
|
-
* @returns WhatsApp link, or empty string if phone is invalid
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* ```typescript
|
|
399
|
-
* generateWALink('081234567890', 'Halo!');
|
|
400
|
-
* // 'https://wa.me/6281234567890?text=Halo%21'
|
|
401
|
-
* ```
|
|
402
|
-
*/
|
|
403
|
-
declare function generateWALink(phone: string, message?: string): string;
|
|
404
|
-
/**
|
|
405
|
-
* Generates an SMS link (sms:).
|
|
406
|
-
*
|
|
407
|
-
* @param phone - The Indonesian phone number
|
|
408
|
-
* @param body - Optional SMS body
|
|
409
|
-
* @returns SMS link, or empty string if phone is invalid
|
|
410
|
-
*
|
|
411
|
-
* @example
|
|
412
|
-
* ```typescript
|
|
413
|
-
* generateSmsLink('081234567890', 'Pesan ini');
|
|
414
|
-
* // 'sms:+6281234567890?body=Pesan%20ini'
|
|
415
|
-
* ```
|
|
416
|
-
*/
|
|
417
|
-
declare function generateSmsLink(phone: string, body?: string): string;
|
|
418
|
-
/**
|
|
419
|
-
* Generates a telephone link (tel:).
|
|
420
|
-
*
|
|
421
|
-
* @param phone - The Indonesian phone number
|
|
422
|
-
* @returns Tel link, or empty string if phone is invalid
|
|
423
|
-
*
|
|
424
|
-
* @example
|
|
425
|
-
* ```typescript
|
|
426
|
-
* generateTelLink('081234567890');
|
|
427
|
-
* // 'tel:+6281234567890'
|
|
428
|
-
* ```
|
|
429
|
-
*/
|
|
430
|
-
declare function generateTelLink(phone: string): string;
|
|
431
|
-
|
|
29
|
+
declare function normalizePhoneNumber(phone: string): string;
|
|
432
30
|
/**
|
|
433
|
-
*
|
|
31
|
+
* Compares two phone numbers regardless of format.
|
|
434
32
|
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
33
|
+
* Both inputs are normalized to national format for comparison.
|
|
34
|
+
* Returns false if either input is invalid.
|
|
437
35
|
*
|
|
438
|
-
* @param
|
|
439
|
-
* @
|
|
36
|
+
* @param phoneA - First phone number in any format
|
|
37
|
+
* @param phoneB - Second phone number in any format
|
|
38
|
+
* @returns true if both represent the same number, false otherwise
|
|
440
39
|
*
|
|
441
40
|
* @example
|
|
442
|
-
*
|
|
41
|
+
* Same number in different formats:
|
|
443
42
|
* ```typescript
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* // {
|
|
447
|
-
* // countryCode: '62',
|
|
448
|
-
* // operator: 'Telkomsel',
|
|
449
|
-
* // number: '81234567890',
|
|
450
|
-
* // formatted: {
|
|
451
|
-
* // international: '+62 812-3456-7890',
|
|
452
|
-
* // national: '0812-3456-7890',
|
|
453
|
-
* // e164: '6281234567890'
|
|
454
|
-
* // },
|
|
455
|
-
* // isValid: true,
|
|
456
|
-
* // isMobile: true,
|
|
457
|
-
* // isLandline: false
|
|
458
|
-
* // }
|
|
43
|
+
* comparePhones('081234567890', '+6281234567890'); // true
|
|
44
|
+
* comparePhones('0812-3456-7890', '6281234567890'); // true
|
|
459
45
|
* ```
|
|
460
46
|
*
|
|
461
47
|
* @example
|
|
462
|
-
*
|
|
48
|
+
* Different numbers:
|
|
463
49
|
* ```typescript
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* console.log(info.formatted.national); // '0812-3456-7890'
|
|
50
|
+
* comparePhones('081234567890', '081234567891'); // false
|
|
51
|
+
* comparePhones('0212345678', '0221234567'); // false
|
|
467
52
|
* ```
|
|
468
53
|
*
|
|
469
54
|
* @example
|
|
470
|
-
*
|
|
55
|
+
* Invalid inputs return false:
|
|
471
56
|
* ```typescript
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
* console.log(info.isLandline); // true
|
|
57
|
+
* comparePhones('invalid', '081234567890'); // false
|
|
58
|
+
* comparePhones('', ''); // false
|
|
475
59
|
* ```
|
|
476
60
|
*
|
|
477
61
|
* @public
|
|
478
62
|
*/
|
|
479
|
-
declare function
|
|
63
|
+
declare function comparePhones(phoneA: string, phoneB: string): boolean;
|
|
480
64
|
/**
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
* Identifies the operator based on the phone number prefix.
|
|
484
|
-
* Returns `null` if the operator cannot be determined or if it's not a mobile number.
|
|
485
|
-
*
|
|
486
|
-
* @param phone - The phone number to check
|
|
487
|
-
* @returns Operator name, or `null` if not detected
|
|
65
|
+
* Gets the region name for a landline number.
|
|
488
66
|
*
|
|
489
|
-
* @
|
|
490
|
-
*
|
|
491
|
-
* ```typescript
|
|
492
|
-
* getOperator('081234567890'); // 'Telkomsel'
|
|
493
|
-
* getOperator('0812-3456-7890'); // 'Telkomsel'
|
|
494
|
-
* getOperator('+6281234567890'); // 'Telkomsel'
|
|
495
|
-
* ```
|
|
67
|
+
* @param phone - Landline phone number in national format
|
|
68
|
+
* @returns Region name, or null if not found
|
|
496
69
|
*
|
|
497
70
|
* @example
|
|
498
|
-
* XL numbers:
|
|
499
71
|
* ```typescript
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* Non-mobile or invalid:
|
|
505
|
-
* ```typescript
|
|
506
|
-
* getOperator('0212345678'); // null (landline)
|
|
507
|
-
* getOperator('1234'); // null (invalid)
|
|
72
|
+
* getLandlineRegion('0212345678'); // 'Jakarta'
|
|
73
|
+
* getLandlineRegion('+62212345678'); // 'Jakarta'
|
|
74
|
+
* getLandlineRegion('081234567890'); // null (mobile)
|
|
508
75
|
* ```
|
|
509
76
|
*
|
|
510
77
|
* @public
|
|
511
78
|
*/
|
|
512
|
-
declare function
|
|
513
|
-
/**
|
|
514
|
-
* Checks if a phone number belongs to a specific provider.
|
|
515
|
-
*
|
|
516
|
-
* @param phone - The phone number to check
|
|
517
|
-
* @param providerName - The provider name to match (case-insensitive)
|
|
518
|
-
* @returns `true` if it matches, `false` otherwise
|
|
519
|
-
*
|
|
520
|
-
* @example
|
|
521
|
-
* ```typescript
|
|
522
|
-
* isProvider('081234567890', 'Telkomsel'); // true
|
|
523
|
-
* isProvider('081734567890', 'xl'); // true
|
|
524
|
-
* ```
|
|
525
|
-
*/
|
|
526
|
-
declare function isProvider(phone: string, providerName: string): boolean;
|
|
79
|
+
declare function getLandlineRegion(phone: string): string | null;
|
|
527
80
|
|
|
528
|
-
export {
|
|
81
|
+
export { comparePhones, getLandlineRegion, normalizePhoneNumber };
|