@yext/phonenumber-util 0.1.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.
@@ -0,0 +1,417 @@
1
+ export const AREA_CODE_LIST = [
2
+ '201',
3
+ '202',
4
+ '203',
5
+ '204',
6
+ '205',
7
+ '206',
8
+ '207',
9
+ '208',
10
+ '209',
11
+ '210',
12
+ '212',
13
+ '213',
14
+ '214',
15
+ '215',
16
+ '216',
17
+ '217',
18
+ '218',
19
+ '219',
20
+ '220',
21
+ '223',
22
+ '224',
23
+ '225',
24
+ '228',
25
+ '229',
26
+ '231',
27
+ '234',
28
+ '236',
29
+ '239',
30
+ '240',
31
+ '242',
32
+ '246',
33
+ '248',
34
+ '250',
35
+ '251',
36
+ '252',
37
+ '253',
38
+ '254',
39
+ '256',
40
+ '260',
41
+ '262',
42
+ '264',
43
+ '267',
44
+ '268',
45
+ '269',
46
+ '270',
47
+ '272',
48
+ '276',
49
+ '279',
50
+ '281',
51
+ '284',
52
+ '289',
53
+ '301',
54
+ '302',
55
+ '303',
56
+ '304',
57
+ '305',
58
+ '306',
59
+ '307',
60
+ '308',
61
+ '309',
62
+ '310',
63
+ '312',
64
+ '313',
65
+ '314',
66
+ '315',
67
+ '316',
68
+ '317',
69
+ '318',
70
+ '319',
71
+ '320',
72
+ '321',
73
+ '323',
74
+ '325',
75
+ '326',
76
+ '330',
77
+ '331',
78
+ '332',
79
+ '334',
80
+ '336',
81
+ '337',
82
+ '339',
83
+ '340',
84
+ '341',
85
+ '343',
86
+ '345',
87
+ '346',
88
+ '347',
89
+ '350',
90
+ '351',
91
+ '352',
92
+ '360',
93
+ '361',
94
+ '363',
95
+ '364',
96
+ '365',
97
+ '380',
98
+ '385',
99
+ '386',
100
+ '387',
101
+ '401',
102
+ '402',
103
+ '403',
104
+ '404',
105
+ '405',
106
+ '406',
107
+ '407',
108
+ '408',
109
+ '409',
110
+ '410',
111
+ '412',
112
+ '413',
113
+ '414',
114
+ '415',
115
+ '416',
116
+ '417',
117
+ '418',
118
+ '419',
119
+ '423',
120
+ '424',
121
+ '425',
122
+ '430',
123
+ '431',
124
+ '432',
125
+ '434',
126
+ '435',
127
+ '437',
128
+ '438',
129
+ '440',
130
+ '441',
131
+ '442',
132
+ '443',
133
+ '445',
134
+ '447',
135
+ '448',
136
+ '450',
137
+ '458',
138
+ '463',
139
+ '464',
140
+ '469',
141
+ '470',
142
+ '472',
143
+ '473',
144
+ '475',
145
+ '478',
146
+ '479',
147
+ '480',
148
+ '484',
149
+ '501',
150
+ '502',
151
+ '503',
152
+ '504',
153
+ '505',
154
+ '506',
155
+ '507',
156
+ '508',
157
+ '509',
158
+ '510',
159
+ '512',
160
+ '513',
161
+ '514',
162
+ '515',
163
+ '516',
164
+ '517',
165
+ '518',
166
+ '519',
167
+ '520',
168
+ '530',
169
+ '531',
170
+ '534',
171
+ '539',
172
+ '540',
173
+ '541',
174
+ '548',
175
+ '551',
176
+ '557',
177
+ '559',
178
+ '561',
179
+ '562',
180
+ '563',
181
+ '564',
182
+ '567',
183
+ '570',
184
+ '571',
185
+ '572',
186
+ '573',
187
+ '574',
188
+ '575',
189
+ '579',
190
+ '580',
191
+ '581',
192
+ '582',
193
+ '585',
194
+ '586',
195
+ '587',
196
+ '601',
197
+ '602',
198
+ '603',
199
+ '604',
200
+ '605',
201
+ '606',
202
+ '607',
203
+ '608',
204
+ '609',
205
+ '610',
206
+ '612',
207
+ '613',
208
+ '614',
209
+ '615',
210
+ '616',
211
+ '617',
212
+ '618',
213
+ '619',
214
+ '620',
215
+ '623',
216
+ '626',
217
+ '628',
218
+ '629',
219
+ '630',
220
+ '631',
221
+ '636',
222
+ '639',
223
+ '640',
224
+ '641',
225
+ '646',
226
+ '647',
227
+ '649',
228
+ '650',
229
+ '651',
230
+ '656',
231
+ '657',
232
+ '658',
233
+ '659',
234
+ '660',
235
+ '661',
236
+ '662',
237
+ '664',
238
+ '667',
239
+ '669',
240
+ '670',
241
+ '671',
242
+ '672',
243
+ '678',
244
+ '680',
245
+ '681',
246
+ '682',
247
+ '684',
248
+ '689',
249
+ '701',
250
+ '702',
251
+ '703',
252
+ '704',
253
+ '705',
254
+ '706',
255
+ '707',
256
+ '708',
257
+ '709',
258
+ '712',
259
+ '713',
260
+ '714',
261
+ '715',
262
+ '716',
263
+ '717',
264
+ '718',
265
+ '719',
266
+ '720',
267
+ '721',
268
+ '724',
269
+ '725',
270
+ '726',
271
+ '727',
272
+ '731',
273
+ '732',
274
+ '734',
275
+ '737',
276
+ '740',
277
+ '742',
278
+ '743',
279
+ '747',
280
+ '754',
281
+ '757',
282
+ '758',
283
+ '760',
284
+ '762',
285
+ '763',
286
+ '765',
287
+ '767',
288
+ '769',
289
+ '770',
290
+ '771',
291
+ '772',
292
+ '773',
293
+ '774',
294
+ '775',
295
+ '778',
296
+ '779',
297
+ '780',
298
+ '781',
299
+ '782',
300
+ '784',
301
+ '785',
302
+ '786',
303
+ '787',
304
+ '800',
305
+ '801',
306
+ '802',
307
+ '803',
308
+ '804',
309
+ '805',
310
+ '806',
311
+ '807',
312
+ '808',
313
+ '809',
314
+ '810',
315
+ '812',
316
+ '813',
317
+ '814',
318
+ '815',
319
+ '816',
320
+ '817',
321
+ '818',
322
+ '819',
323
+ '820',
324
+ '825',
325
+ '826',
326
+ '828',
327
+ '829',
328
+ '830',
329
+ '831',
330
+ '832',
331
+ '833',
332
+ '835',
333
+ '838',
334
+ '839',
335
+ '840',
336
+ '843',
337
+ '845',
338
+ '847',
339
+ '848',
340
+ '849',
341
+ '850',
342
+ '854',
343
+ '855',
344
+ '856',
345
+ '857',
346
+ '858',
347
+ '859',
348
+ '860',
349
+ '862',
350
+ '863',
351
+ '864',
352
+ '865',
353
+ '866',
354
+ '867',
355
+ '868',
356
+ '869',
357
+ '870',
358
+ '872',
359
+ '873',
360
+ '876',
361
+ '877',
362
+ '878',
363
+ '888',
364
+ '901',
365
+ '902',
366
+ '903',
367
+ '904',
368
+ '905',
369
+ '906',
370
+ '907',
371
+ '908',
372
+ '909',
373
+ '910',
374
+ '912',
375
+ '913',
376
+ '914',
377
+ '915',
378
+ '916',
379
+ '917',
380
+ '918',
381
+ '919',
382
+ '920',
383
+ '925',
384
+ '928',
385
+ '929',
386
+ '930',
387
+ '931',
388
+ '934',
389
+ '936',
390
+ '937',
391
+ '938',
392
+ '939',
393
+ '940',
394
+ '941',
395
+ '943',
396
+ '945',
397
+ '947',
398
+ '948',
399
+ '949',
400
+ '951',
401
+ '952',
402
+ '954',
403
+ '956',
404
+ '959',
405
+ '970',
406
+ '971',
407
+ '972',
408
+ '973',
409
+ '978',
410
+ '979',
411
+ '980',
412
+ '983',
413
+ '984',
414
+ '985',
415
+ '986',
416
+ '989',
417
+ ];
package/src/index.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ export interface PhoneParts {
2
+ areaCode: string | null;
3
+ e164: string | null;
4
+ format: string | null;
5
+ formattedNumber: string | null;
6
+ href: string | null;
7
+ localNumber: string | null;
8
+ rawNumber: string;
9
+ regionCode: string | null;
10
+ }
11
+
12
+ export function formatPhoneNumberForE164(
13
+ phoneParts: Pick<PhoneParts, 'regionCode' | 'areaCode' | 'localNumber'>
14
+ ): string | null;
15
+
16
+ export function formatPhoneNumberLink(
17
+ phoneParts: Pick<PhoneParts, 'regionCode' | 'areaCode' | 'localNumber'>
18
+ ): string | null;
19
+
20
+ export function isValidPhoneNumber(phoneNumber: string): boolean;
21
+
22
+ export function getPhoneParts(phoneNumber: string): PhoneParts;
23
+
24
+ export function sanitizeRawNumber(phoneNumber: string): string;
25
+
26
+ export function findNumbersInString(text: string): Array<{
27
+ index: number;
28
+ lastIndex: number;
29
+ phoneParts: PhoneParts;
30
+ }>;
31
+
32
+ export function findPhoneFormat(regionCode: string): string;
33
+
34
+ export function formatPhoneNumber(params: {
35
+ format: string;
36
+ e164: string;
37
+ }): string | null;