@yext/phonenumber-util 0.2.1 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yext/phonenumber-util",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "author": "bajohnson@hearsaycorp.com",
5
5
  "license": "BSD-3-Clause",
6
6
  "description": "Utility for extracting and validating phone numbers",
@@ -26,11 +26,11 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@eslint/js": "^9.7.0",
29
- "@vitest/coverage-v8": "^2.1.1",
30
- "eslint": "^9.7.0",
31
- "generate-license-file": "^3.5.1",
32
- "globals": "^15.8.0",
33
- "husky": "^9.1.5",
29
+ "@vitest/coverage-v8": "^2.1.5",
30
+ "eslint": "^9.15.0",
31
+ "generate-license-file": "^3.6.0",
32
+ "globals": "^15.12.0",
33
+ "husky": "^9.1.7",
34
34
  "istanbul-badges-readme": "^1.9.0",
35
35
  "lint-staged": "^15.2.10",
36
36
  "prettier": "^3.3.3",
@@ -1,3 +1,7 @@
1
+ // The AREA_CODE_LIST is used in validation of NANP phone numbers. If a number is passed to `isValidPhoneNumber` that is not found in this array, `false` will be returned.
2
+ // If a new area code is added to this array, it must also be added to the AREA_CODES object in phoneCodes.js.
3
+ // If a new area code is added and covers a region that has multiple timezones, it will need to be added to the STATES_WITH_MULTIPLE_TIMEZONES object in timezones.js.
4
+ // If a new area code is added and covers a region that has portions that do and portions that do not adhere to daylight savings time, it will need to be added to the AREA_CODES_WITH_MULTIPLE_DAYLIGHT_SAVINGS object in daylightSavings.js.
1
5
  export const AREA_CODE_LIST = [
2
6
  '201',
3
7
  '202',
@@ -21,6 +25,7 @@ export const AREA_CODE_LIST = [
21
25
  '223',
22
26
  '224',
23
27
  '225',
28
+ '226',
24
29
  '257',
25
30
  '228',
26
31
  '229',
@@ -49,6 +54,7 @@ export const AREA_CODE_LIST = [
49
54
  '276',
50
55
  '279',
51
56
  '281',
57
+ '283',
52
58
  '284',
53
59
  '289',
54
60
  '301',
package/src/compliance.js CHANGED
@@ -1,3 +1,4 @@
1
+ // Compliance settings are used to define quiet hours for the US (using TCPA) and Canada (using CRTC).
1
2
  export const TCPA_QUIET_HOURS = {
2
3
  start: 8,
3
4
  end: 21,
@@ -14,6 +15,7 @@ export const CRTC_QUIET_HOURS = {
14
15
  },
15
16
  };
16
17
 
18
+ // The strings of CRTC_STATES must match the `name` field found within AREA_CODES object in phoneCodes.js.
17
19
  export const CRTC_STATES = [
18
20
  'Alberta',
19
21
  'British Columbia',
package/src/phoneCodes.js CHANGED
@@ -256,6 +256,7 @@ export const AREA_CODES = {
256
256
  216: { name: 'Ohio', code: 'OH', region: UNITED_STATES },
257
257
  220: { name: 'Ohio', code: 'OH', region: UNITED_STATES },
258
258
  234: { name: 'Ohio', code: 'OH', region: UNITED_STATES },
259
+ 283: { name: 'Ohio', code: 'OH', region: UNITED_STATES },
259
260
  326: { name: 'Ohio', code: 'OH', region: UNITED_STATES },
260
261
  330: { name: 'Ohio', code: 'OH', region: UNITED_STATES },
261
262
  380: { name: 'Ohio', code: 'OH', region: UNITED_STATES },
@@ -389,6 +390,7 @@ export const AREA_CODES = {
389
390
  state: 'NS/PE',
390
391
  region: CANADA,
391
392
  },
393
+ 226: { name: 'Ontario', code: 'ON', region: CANADA },
392
394
  289: { name: 'Ontario', code: 'ON', region: CANADA },
393
395
  343: { name: 'Ontario', code: 'ON', region: CANADA },
394
396
  365: { name: 'Ontario', code: 'ON', region: CANADA },
@@ -420,7 +422,6 @@ export const AREA_CODES = {
420
422
  region: CANADA,
421
423
  },
422
424
  // Other North American Numbering Plan (NANP) Numbers
423
- // These will return "United States, Canada" as the region, which is incorrect, but they follow the same standard.
424
425
  684: { region: { name: 'American Samoa', code: 'AS', flag: '🇦🇸' } },
425
426
  264: { region: { name: 'Anguilla', code: 'AI', flag: '🇦🇮' } },
426
427
  268: { region: { name: 'Antigua and Barbuda', code: 'AG', flag: '🇦🇬' } },
@@ -491,7 +492,7 @@ export const REGION_CODES = {
491
492
  235: { name: 'Chad', code: 'TD', flag: '🇹🇩' },
492
493
  56: { name: 'Chile', code: 'CL', flag: '🇨🇱' },
493
494
  86: { name: 'China', code: 'CN', flag: '🇨🇳' },
494
- 61: { name: 'Christmas Island, Cocos Islands', code: 'CX', flag: '🇨🇽' },
495
+ 61: { name: 'Australia', code: 'AU', flag: '🇦🇺' },
495
496
  57: { name: 'Colombia', code: 'CO', flag: '🇨🇴' },
496
497
  269: { name: 'Comoros', code: 'KM', flag: '🇰🇲' },
497
498
  682: { name: 'Cook Islands', code: 'CK', flag: '🇨🇰' },
@@ -1,3 +1,5 @@
1
+ // For each region, provide a pretty format. Some regions may have multiple formats, in which case an array can be used. Each "x" will be replaced with a digit when the number of digits matches the number of "x"s in the format.
2
+ // If no format is found with a correct matching length, a sanitized e164 is returned as a fall-back.
1
3
  export const PHONE_FORMATS = {
2
4
  1: '(xxx) xxx-xxxx', // United States
3
5
  7: '+x xxx xxx-xx-xx', // Russia
package/src/timezones.js CHANGED
@@ -1,3 +1,6 @@
1
+ // Default timezone for each state, region or province.
2
+ // While some region may have multiple timezones, we set the most common one here as a default. See STATES_WITH_MULTIPLE_TIMEZONES below for references to exceptions within these regions.
3
+ // Time calculations are only provided for US and Canada.
1
4
  export const STATE_TIMEZONES = {
2
5
  Alabama: '-06:00',
3
6
  Alaska: '-09:00',