libphonenumber-js
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -287,7 +287,6 @@ 'use strict'; | ||
this.country_phone_code = ''; | ||
if (this.default_country) { | ||
this.country = this.default_country; | ||
this.country_metadata = _metadata2.default.countries[this.default_country]; | ||
this.country_phone_code = this.country_metadata.phone_code; | ||
@@ -298,2 +297,3 @@ this.initialize_phone_number_formats_for_this_country_phone_code(); | ||
this.country_metadata = undefined; | ||
this.country_phone_code = undefined; | ||
@@ -300,0 +300,0 @@ this.available_formats = []; |
@@ -0,1 +1,6 @@ | ||
0.2.1 / 10.12.2016 | ||
=================== | ||
* Added `.country_phone_code` readable property to "as you type" formatter | ||
0.2.0 / 02.12.2016 | ||
@@ -2,0 +7,0 @@ =================== |
{ | ||
"name": "libphonenumber-js", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A simpler (and smaller) rewrite of Google Android's famous libphonenumber library", | ||
@@ -5,0 +5,0 @@ "main": "index.common.js", |
@@ -59,3 +59,3 @@ # libphonenumber-js | ||
`options` can be | ||
`options` can be either an object | ||
@@ -76,3 +76,3 @@ ```js | ||
Returns `{ country, phone }` where `country` is a two-letter country code, and `phone` is a national (significant) number. If the phone number supplied isn't valid for the corresponding country then an empty object is returned. | ||
Returns `{ country, phone }` where `country` is a two-letter country code, and `phone` is a national (significant) number. If the phone number supplied isn't valid then an empty object `{}` is returned. | ||
@@ -86,12 +86,12 @@ ```js | ||
Formats an already parsed phone number in one of the following `format`s: | ||
Formats a phone number using one of the following `format`s: | ||
* `International` — e.g. `+1 213 373 4253` | ||
* `International_plaintext` — (aka `E.164`) e.g. `+12133734253` | ||
* `International_plaintext` — (aka [`E.164`](https://en.wikipedia.org/wiki/E.164)) e.g. `+12133734253` | ||
* `National` — e.g. `(213) 373-4253` | ||
Can also be called with the first object argument expanded: | ||
`parsed_number` argument is the result of the `parse()` function call: `{ country, phone }` (`phone` is a national (significant) number). `parsed_number` argument can also be expanded into two arguments: | ||
```js | ||
format('2133734253', 'US', 'International') === '+1-213-373-4253' | ||
format({ country: 'US', phone: '2133734253' }, 'International') === '+1-213-373-4253' | ||
format({ country: 'US', phone: '2133734253' }, 'International') === '+1 213 373 4253' | ||
format('2133734253', 'US', 'International') === '+1 213 373 4253' | ||
``` | ||
@@ -125,2 +125,3 @@ | ||
* `country` — a two-letter country code of the country this phone belongs to | ||
* `country_phone_code` — a phone code of the `country` | ||
* `template` — currently used phone number formatting template, where digits (and the plus sign, if present) are denoted by `x`-es | ||
@@ -131,2 +132,9 @@ | ||
new asYouType('US').input('2133734') === '(213) 373-4' | ||
const formatter = new asYouType() | ||
formatter.input('+1-213-373-4253') === '+1 213 373 4253' | ||
formatter.valid === true | ||
formatter.country === 'US' | ||
formatter.country_phone_code = '1' | ||
formatter.template === 'xx xxx xxx xxxx' | ||
``` | ||
@@ -133,0 +141,0 @@ |
@@ -323,4 +323,2 @@ // This is an enhanced port of Google Android `libphonenumber`'s | ||
this.country_phone_code = '' | ||
if (this.default_country) | ||
@@ -330,2 +328,3 @@ { | ||
this.country_metadata = metadata.countries[this.default_country] | ||
this.country_phone_code = this.country_metadata.phone_code | ||
@@ -338,2 +337,3 @@ this.initialize_phone_number_formats_for_this_country_phone_code() | ||
this.country_metadata = undefined | ||
this.country_phone_code = undefined | ||
@@ -340,0 +340,0 @@ this.available_formats = [] |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1235966
3916
218