libphonenumber-js 1.9.19 → 1.9.23
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/CHANGELOG.md +7 -0
- package/README.md +63 -3
- package/build/AsYouType.test.js +8 -7
- package/build/AsYouType.test.js.map +1 -1
- package/build/PhoneNumber.js +4 -0
- package/build/PhoneNumber.js.map +1 -1
- package/build/PhoneNumber.test.js +3 -0
- package/build/PhoneNumber.test.js.map +1 -1
- package/build/format.test.js +7 -0
- package/build/format.test.js.map +1 -1
- package/build/helpers/getIddPrefix.js +4 -2
- package/build/helpers/getIddPrefix.js.map +1 -1
- package/build/parse.test.js +3 -3
- package/build/parse.test.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/es6/AsYouType.test.js +8 -7
- package/es6/AsYouType.test.js.map +1 -1
- package/es6/PhoneNumber.js +4 -0
- package/es6/PhoneNumber.js.map +1 -1
- package/es6/PhoneNumber.test.js +3 -0
- package/es6/PhoneNumber.test.js.map +1 -1
- package/es6/format.test.js +7 -0
- package/es6/format.test.js.map +1 -1
- package/es6/helpers/getIddPrefix.js +4 -2
- package/es6/helpers/getIddPrefix.js.map +1 -1
- package/es6/parse.test.js +3 -3
- package/es6/parse.test.js.map +1 -1
- package/metadata.full.json +1 -1
- package/metadata.full.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.js +1 -1
- package/package.json +1 -1
- package/runnable/metadata-update-and-push-and-pull-request.js +1 -1
- package/runnable/modules/commit.js +1 -1
- package/source/AsYouType.test.js +8 -6
- package/source/PhoneNumber.js +3 -0
- package/source/PhoneNumber.test.js +1 -0
- package/source/format.test.js +6 -0
- package/source/helpers/getIddPrefix.js +3 -1
- package/source/parse.test.js +3 -3
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ if (update_metadata())
|
|
|
34
34
|
console.log('========================================')
|
|
35
35
|
console.log()
|
|
36
36
|
|
|
37
|
-
console.log(exec('hub pull-request -m "
|
|
37
|
+
console.log(exec('hub pull-request -m "Updated metadata" -b catamphetamine/libphonenumber-js:master -h update-metadata'))
|
|
38
38
|
|
|
39
39
|
console.log()
|
|
40
40
|
console.log('========================================')
|
package/source/AsYouType.test.js
CHANGED
|
@@ -362,10 +362,12 @@ describe('AsYouType', () => {
|
|
|
362
362
|
// formatter.input('+1 1 877 215 5230').should.equal('+1 1 8772155230')
|
|
363
363
|
formatter.getNationalNumber().should.equal('8772155230')
|
|
364
364
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
formatter
|
|
368
|
-
formatter.
|
|
365
|
+
// They've added another number format that has `8` leading digit
|
|
366
|
+
// and 14 digits. Maybe it's something related to Kazakhstan.
|
|
367
|
+
// formatter = new AsYouType()
|
|
368
|
+
// formatter.input('+78800555353').should.equal('+7 880 055 53 53')
|
|
369
|
+
// formatter.input('5').should.equal('+7 8 800 555 35 35')
|
|
370
|
+
// formatter.getNationalNumber().should.equal('8005553535')
|
|
369
371
|
})
|
|
370
372
|
|
|
371
373
|
it('should return a partial template for current value', () => {
|
|
@@ -923,10 +925,10 @@ describe('AsYouType', () => {
|
|
|
923
925
|
|
|
924
926
|
it('shouldn\'t choose a format when there\'re too many digits for any of them', () => {
|
|
925
927
|
const formatter = new AsYouType('RU')
|
|
926
|
-
formatter.input('
|
|
928
|
+
formatter.input('89991112233')
|
|
927
929
|
formatter.formatter.chosenFormat.format().should.equal('$1 $2-$3-$4')
|
|
928
930
|
formatter.reset()
|
|
929
|
-
formatter.input('
|
|
931
|
+
formatter.input('899911122334')
|
|
930
932
|
expect(formatter.formatter.chosenFormat).to.be.undefined
|
|
931
933
|
})
|
|
932
934
|
|
package/source/PhoneNumber.js
CHANGED
|
@@ -15,6 +15,9 @@ export default class PhoneNumber {
|
|
|
15
15
|
if (!nationalNumber) {
|
|
16
16
|
throw new TypeError('`nationalNumber` not passed')
|
|
17
17
|
}
|
|
18
|
+
if (!metadata) {
|
|
19
|
+
throw new TypeError('`metadata` not passed')
|
|
20
|
+
}
|
|
18
21
|
const _metadata = new Metadata(metadata)
|
|
19
22
|
// If country code is passed then derive `countryCallingCode` from it.
|
|
20
23
|
// Also store the country code as `.country`.
|
|
@@ -5,6 +5,7 @@ describe('PhoneNumber', () => {
|
|
|
5
5
|
it('should validate constructor arguments', () => {
|
|
6
6
|
expect(() => new PhoneNumber()).to.throw('`countryCallingCode` not passed')
|
|
7
7
|
expect(() => new PhoneNumber('7')).to.throw('`nationalNumber` not passed')
|
|
8
|
+
expect(() => new PhoneNumber('7', '8005553535')).to.throw('`metadata` not passed')
|
|
8
9
|
})
|
|
9
10
|
|
|
10
11
|
it('should accept country code argument', () => {
|
package/source/format.test.js
CHANGED
|
@@ -222,4 +222,10 @@ describe('format', () => {
|
|
|
222
222
|
formatNumber('+870773111632', 'INTERNATIONAL').should.equal('+870 773 111 632')
|
|
223
223
|
formatNumber('+870773111632', 'NATIONAL').should.equal('773 111 632')
|
|
224
224
|
})
|
|
225
|
+
|
|
226
|
+
it('should use the default IDD prefix when formatting a phone number', () => {
|
|
227
|
+
// Testing preferred international prefixes with ~ are supported.
|
|
228
|
+
// ("~" designates waiting on a line until proceeding with the input).
|
|
229
|
+
formatNumber('+390236618300', 'IDD', { fromCountry: 'UZ' }).should.equal('8~10 39 02 3661 8300')
|
|
230
|
+
})
|
|
225
231
|
})
|
|
@@ -16,8 +16,10 @@ const SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/
|
|
|
16
16
|
export default function getIddPrefix(country, callingCode, metadata) {
|
|
17
17
|
const countryMetadata = new Metadata(metadata)
|
|
18
18
|
countryMetadata.selectNumberingPlan(country, callingCode)
|
|
19
|
+
if (countryMetadata.defaultIDDPrefix()) {
|
|
20
|
+
return countryMetadata.defaultIDDPrefix()
|
|
21
|
+
}
|
|
19
22
|
if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
|
|
20
23
|
return countryMetadata.IDDPrefix()
|
|
21
24
|
}
|
|
22
|
-
return countryMetadata.defaultIDDPrefix()
|
|
23
25
|
}
|
package/source/parse.test.js
CHANGED
|
@@ -119,10 +119,10 @@ describe('parse', () => {
|
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
// Too long.
|
|
122
|
-
parseNumber('+
|
|
122
|
+
parseNumber('+1 213 37342530', { extended: true }).should.deep.equal({
|
|
123
123
|
country : undefined,
|
|
124
|
-
countryCallingCode : '
|
|
125
|
-
phone : '
|
|
124
|
+
countryCallingCode : '1',
|
|
125
|
+
phone : '21337342530',
|
|
126
126
|
carrierCode : undefined,
|
|
127
127
|
ext : undefined,
|
|
128
128
|
valid : false,
|