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/CHANGELOG.md
CHANGED
|
@@ -71,6 +71,13 @@ And edit the README:
|
|
|
71
71
|
|
|
72
72
|
<!-- (breaking change) Changed `countries` and `country_calling_codes` properties in metadata: now they're not properties but rather elements of an array (`countries` is an array now rather than an object; `countries` is `metadata[0]` and `country_calling_codes` is `metadata[1]`). If you were using a custom-generated metadata then it has to be re-generated for the new version. -->
|
|
73
73
|
|
|
74
|
+
This changelog [only](https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/16#note_594165443) mentions the changes in the code. See [Google's changelog](https://github.com/google/libphonenumber/blob/master/release_notes.txt) for metadata changes.
|
|
75
|
+
|
|
76
|
+
1.9.20 / 07.06.2021
|
|
77
|
+
==================
|
|
78
|
+
|
|
79
|
+
* [Changed](https://github.com/google/libphonenumber/commit/c6277266fba8223cfc610cfb1e999deb9f876d65) formatting numbers in `IDD` format to always use the preferred IDD prefix (if defined), not just in cases when a country has multiple IDD prefixes. This means that it will output `8~10` as the prefix instead of `810` for some regions (like Uzbekistan) that have this tilde in their IDD prefix (the tilde designates that the user should wait before continuing to dial).
|
|
80
|
+
|
|
74
81
|
1.9.11 / 10.02.2021
|
|
75
82
|
==================
|
|
76
83
|
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ One part of me was curious about how all this phone number parsing and formattin
|
|
|
40
40
|
|
|
41
41
|
* "Two-in-one" phone numbers with "combined" extensions like `(530) 583-6985 x302/x2303` that in fact represent two separate phone numbers, because the library can only return a single phone number when parsing a string.
|
|
42
42
|
|
|
43
|
-
* Overall, doesn't support formatting non-"conventional" numbers like numbers with the "area code" omitted.
|
|
43
|
+
* Overall, doesn't support formatting non-"conventional" numbers like numbers with the "area code" omitted or "alternative" "short" numbers like [Australian `13`-smart numbers](https://github.com/catamphetamine/libphonenumber-js/issues/400). For example, when dialing phone numbers within the same "area", people sometimes skip the "area code", and dial, say, `456-789` instead of `(123) 456-789`. Google's `libphonenumber` supports formatting such numbers (with "area code" omitted) because it is used for dialing on the Android phone operating system. Because `libphonenumber-js` isn't a phone operating system and is not used for actual dialing — only for inputting internationally-dialable personal phone numbers — it doesn't format such "short" phone numbers because it doesn't need to support those.
|
|
44
44
|
|
|
45
45
|
* Any other "miscellaneous" cases that're considered irrelevant for the task.
|
|
46
46
|
|
|
@@ -90,6 +90,55 @@ If you're not using a bundler then use a [standalone version from a CDN](https:/
|
|
|
90
90
|
|
|
91
91
|
## Use
|
|
92
92
|
|
|
93
|
+
<!--
|
|
94
|
+
### Importing
|
|
95
|
+
|
|
96
|
+
When using [Babel](https://babeljs.io/) or [`esm`](npmjs.com/package/esm) or [rollup.js](https://rollupjs.org/) or any other `import` transpiler:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import parsePhoneNumber, {
|
|
100
|
+
isPossiblePhoneNumber,
|
|
101
|
+
isValidPhoneNumber,
|
|
102
|
+
AsYouType,
|
|
103
|
+
findPhoneNumbersInText
|
|
104
|
+
} from 'libphonenumber-js'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
When using Node.js 14 and not using any of the above:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import parsePhoneNumber from 'libphonenumber-js'
|
|
111
|
+
|
|
112
|
+
// or
|
|
113
|
+
|
|
114
|
+
import libphonenumber from 'libphonenumber-js'
|
|
115
|
+
|
|
116
|
+
const {
|
|
117
|
+
default: parsePhoneNumber,
|
|
118
|
+
isPossiblePhoneNumber,
|
|
119
|
+
isValidPhoneNumber,
|
|
120
|
+
AsYouType,
|
|
121
|
+
findPhoneNumbersInText
|
|
122
|
+
} = libphonenumber
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
When using Node.js < 14 and not using any of the above:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
const libphonenumber = require('libphonenumber-js')
|
|
129
|
+
|
|
130
|
+
const {
|
|
131
|
+
default: parsePhoneNumber,
|
|
132
|
+
isPossiblePhoneNumber,
|
|
133
|
+
isValidPhoneNumber,
|
|
134
|
+
AsYouType,
|
|
135
|
+
findPhoneNumbersInText
|
|
136
|
+
} = libphonenumber
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/42
|
|
140
|
+
-->
|
|
141
|
+
|
|
93
142
|
### Parse phone number
|
|
94
143
|
|
|
95
144
|
<!--
|
|
@@ -1502,7 +1551,13 @@ Google periodically releases new metadata with the changes described in the [rel
|
|
|
1502
1551
|
|
|
1503
1552
|
Metadata update process is automated through an "autoupdate" script: see `autoupdate.cmd` (Windows) or `autoupdate.sh` (Linux/macOS). The script detects changes to `PhoneNumberMetadata.xml` in Google `libphonenumber`'s repo and if there are changes then it pulls the latest metadata, processes it, commits the changes to GitHub, builds a new version of the library and releases it to NPM. So this library's metadata is supposed to be up-to-date. I could set up this script to run automatically but on my Windows machine `ssh-agent` doesn't work properly so I run the "autoupdate" script manually from time to time.
|
|
1504
1553
|
|
|
1505
|
-
Also Google sometimes (very rarely) updates their code:
|
|
1554
|
+
Also Google sometimes (very rarely) updates their code:
|
|
1555
|
+
|
|
1556
|
+
* [`phonenumberutil.js`](https://github.com/googlei18n/libphonenumber/blob/master/javascript/i18n/phonenumbers/phonenumberutil.js) — `parseNumber()`, `formatNumber()`, `isValidNumber()`, `getNumberType()`
|
|
1557
|
+
* [`AsYouTypeFormatter.java`](https://github.com/google/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java) — `AsYouType`
|
|
1558
|
+
* [`PhoneNumberMatcher.java`](https://github.com/googlei18n/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java) — `findPhoneNumbersInText()`
|
|
1559
|
+
|
|
1560
|
+
The latest sync-up was on June 7th, 2021.
|
|
1506
1561
|
|
|
1507
1562
|
## Contributing
|
|
1508
1563
|
|
|
@@ -1552,4 +1607,9 @@ If you're looking for an international "2 days ago" javascript solution then che
|
|
|
1552
1607
|
|
|
1553
1608
|
## License
|
|
1554
1609
|
|
|
1555
|
-
[
|
|
1610
|
+
Google's `libphonenumber` is [licensed](https://github.com/google/libphonenumber/blob/master/LICENSE) under Apache 2.
|
|
1611
|
+
|
|
1612
|
+
[Apache 2](https://en.wikipedia.org/wiki/Apache_License#Licensing_conditions) does not require a derivative work of the software, or modifications to the original, to be distributed using the same license. Hence, this library is licensed under [MIT](LICENSE), which is [compatible](https://www.quora.com/Is-the-MIT-license-compatible-with-the-Apache-License-Version-2-APLv2) with Apache 2.
|
|
1613
|
+
|
|
1614
|
+
The Apache license is terminated if the user sues anyone over patent infringement related to the software covered by the license. This condition is added in order to prevent patent litigations.
|
|
1615
|
+
|
package/build/AsYouType.test.js
CHANGED
|
@@ -319,11 +319,12 @@ describe('AsYouType', function () {
|
|
|
319
319
|
formatter = new AsYouType();
|
|
320
320
|
formatter.input('+1 1 877 215 5230').should.equal('+1 1 877 215 5230'); // formatter.input('+1 1 877 215 5230').should.equal('+1 1 8772155230')
|
|
321
321
|
|
|
322
|
-
formatter.getNationalNumber().should.equal('8772155230');
|
|
323
|
-
|
|
324
|
-
formatter
|
|
325
|
-
formatter.input('
|
|
326
|
-
formatter.
|
|
322
|
+
formatter.getNationalNumber().should.equal('8772155230'); // They've added another number format that has `8` leading digit
|
|
323
|
+
// and 14 digits. Maybe it's something related to Kazakhstan.
|
|
324
|
+
// formatter = new AsYouType()
|
|
325
|
+
// formatter.input('+78800555353').should.equal('+7 880 055 53 53')
|
|
326
|
+
// formatter.input('5').should.equal('+7 8 800 555 35 35')
|
|
327
|
+
// formatter.getNationalNumber().should.equal('8005553535')
|
|
327
328
|
});
|
|
328
329
|
it('should return a partial template for current value', function () {
|
|
329
330
|
var asYouType = new AsYouType('US');
|
|
@@ -815,10 +816,10 @@ describe('AsYouType', function () {
|
|
|
815
816
|
});
|
|
816
817
|
it('shouldn\'t choose a format when there\'re too many digits for any of them', function () {
|
|
817
818
|
var formatter = new AsYouType('RU');
|
|
818
|
-
formatter.input('
|
|
819
|
+
formatter.input('89991112233');
|
|
819
820
|
formatter.formatter.chosenFormat.format().should.equal('$1 $2-$3-$4');
|
|
820
821
|
formatter.reset();
|
|
821
|
-
formatter.input('
|
|
822
|
+
formatter.input('899911122334');
|
|
822
823
|
expect(formatter.formatter.chosenFormat).to.be.undefined;
|
|
823
824
|
});
|
|
824
825
|
it('should get separator after national prefix', function () {
|