libphonenumber-js
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -189,10 +189,13 @@ 'use strict'; | ||
} else { | ||
if (!this.national_prefix) { | ||
// Possibly extract a national prefix | ||
this.extract_national_prefix(); | ||
} else if (!this.able_to_format) { | ||
if (!this.extract_longer_national_prefix()) { | ||
// Return raw phone number | ||
return this.parsed_input; | ||
} | ||
// Some national prefixes are substrings of other national prefixes | ||
// (for the same country), therefore extract national prefix each time. | ||
var previous_national_prefix = this.national_prefix; | ||
this.national_number = this.national_prefix + this.national_number; | ||
// Possibly extract a national prefix | ||
this.extract_national_prefix(); | ||
if (this.national_prefix !== previous_national_prefix) { | ||
this.reset_formatting(); | ||
} | ||
@@ -284,13 +287,12 @@ } | ||
this.country_metadata = undefined; | ||
this.available_formats = undefined; | ||
} | ||
this.clear_formatting(); | ||
this.reset_formatting(); | ||
} | ||
}, { | ||
key: 'clear_formatting', | ||
value: function clear_formatting() { | ||
this.able_to_format = true; | ||
key: 'reset_formatting', | ||
value: function reset_formatting() { | ||
this.possible_formats = this.available_formats; | ||
this.possible_formats = undefined; | ||
this.current_format = undefined; | ||
@@ -342,9 +344,2 @@ | ||
}, { | ||
key: 'attempt_to_choose_formatting_pattern_with_national_prefix_extracted', | ||
value: function attempt_to_choose_formatting_pattern_with_national_prefix_extracted() { | ||
this.clear_formatting(); | ||
return this.format_national_number(); | ||
} | ||
}, { | ||
key: 'initialize_possible_formats', | ||
@@ -351,0 +346,0 @@ value: function initialize_possible_formats() { |
{ | ||
"name": "libphonenumber-js", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A simpler (and smaller) rewrite of Google Android's famous libphonenumber library", | ||
@@ -5,0 +5,0 @@ "main": "index.common.js", |
@@ -123,7 +123,2 @@ # libphonenumber-js | ||
## To do | ||
* Maybe fix the "miniumum of 3 characters" limit for "As you type" formatter | ||
* Maybe fix braces for "As you type" formatter (don't cut off closing braces) | ||
## Contributing | ||
@@ -130,0 +125,0 @@ |
@@ -195,15 +195,15 @@ // This is an enhanced port of Google Android `libphonenumber`'s | ||
{ | ||
if (!this.national_prefix) | ||
// Some national prefixes are substrings of other national prefixes | ||
// (for the same country), therefore extract national prefix each time. | ||
const previous_national_prefix = this.national_prefix | ||
this.national_number = this.national_prefix + this.national_number | ||
// Possibly extract a national prefix | ||
this.extract_national_prefix() | ||
if (this.national_prefix !== previous_national_prefix) | ||
{ | ||
// Possibly extract a national prefix | ||
this.extract_national_prefix() | ||
this.reset_formatting() | ||
} | ||
else if (!this.able_to_format) | ||
{ | ||
if (!this.extract_longer_national_prefix()) | ||
{ | ||
// Return raw phone number | ||
return this.parsed_input | ||
} | ||
} | ||
} | ||
@@ -300,13 +300,12 @@ | ||
this.country_metadata = undefined | ||
this.available_formats = undefined | ||
} | ||
this.clear_formatting() | ||
this.reset_formatting() | ||
} | ||
clear_formatting() | ||
reset_formatting() | ||
{ | ||
this.able_to_format = true | ||
this.possible_formats = this.available_formats | ||
this.possible_formats = undefined | ||
this.current_format = undefined | ||
@@ -336,9 +335,2 @@ | ||
attempt_to_choose_formatting_pattern_with_national_prefix_extracted() | ||
{ | ||
this.clear_formatting() | ||
return this.format_national_number() | ||
} | ||
initialize_possible_formats() | ||
@@ -345,0 +337,0 @@ { |
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
1178211
3235
168