-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPAN.coffee
42 lines (34 loc) · 1.11 KB
/
PAN.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
# For more info check:
# http://www.howtocallabroad.com/panama/
# https://en.wikipedia.org/wiki/Telephone_numbers_in_Panama
class Panama
constructor: ->
@countryName = "Panama"
@countryNameAbbr = "PAN"
@countryCode = '507'
@regex = /^(?:(?:(?:\+|)507)|)(?:0|)(?:[23479]\d{6}|6\d{7})$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode = ['2', '3', '4', '6', '7', '9']
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
if ndc is '6' and withoutNDC.length is 7
phone.isMobile = true
phone.nationalDestinationCode = ''
phone.number = withoutCountryCode
return phone
else if withoutNDC.length is 6
return phone
splitNumber: (number) =>
if number.length is 7
return Phone.compact number.split(/(\d{3})(\d{4})/)
else if number.length is 8
return Phone.compact number.split(/(\d{4})(\d{4})/)
return [number]
# register
panama = new Panama()
Phone.countries['507'] = panama
# exports
module.exports = panama