Socket
Socket
Sign inDemoInstall

libphonenumber-js

Package Overview
Dependencies
Maintainers
1
Versions
392
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libphonenumber-js - npm Package Compare versions

Comparing version 0.1.16 to 0.1.17

88

build/as you type.js

@@ -99,4 +99,2 @@ 'use strict';

value: function input(text) {
this.valid = false;
// Parse input

@@ -119,4 +117,7 @@

var input = (0, _parse.parse_phone_number)(extracted_number);
return this.process_input((0, _parse.parse_phone_number)(extracted_number));
}
}, {
key: 'process_input',
value: function process_input(input) {
// If an out of position '+' sign detected

@@ -133,4 +134,8 @@ // (or a second '+' sign),

// Raw phone number
this.parsed_input += input;
// Reset phone number validation state
this.valid = false;
// Add digits to the national number

@@ -150,3 +155,5 @@ this.national_number += input;

// If no country phone code could be extracted so far,
// then just return the raw phone number.
// then just return the raw phone number,
// because it has no way of knowing
// how to format the phone number so far.
if (!this.extract_country_phone_code()) {

@@ -203,2 +210,19 @@ // Return raw phone number

// Format the phone number (given the next digits)
var formatted_national_phone_number = this.format_national_phone_number(input);
// If the phone number could be formatted,
// then return it, possibly prepending with country phone code
// (for international phone numbers only)
if (formatted_national_phone_number) {
return this.full_phone_number(formatted_national_phone_number);
}
// If the phone number couldn't be formatted,
// then just fall back to the raw phone number.
return this.parsed_input;
}
}, {
key: 'format_national_phone_number',
value: function format_national_phone_number(next_digits) {
// Format the next phone number digits

@@ -213,3 +237,3 @@ // using the previously chosen phone number format.

if (this.chosen_format) {
national_number_formatted_with_previous_format = this.format_next_national_number_digits(input);
national_number_formatted_with_previous_format = this.format_next_national_number_digits(next_digits);
}

@@ -240,12 +264,7 @@

var formatted_national_number = this.reformat_national_number();
// Will return `undefined` if it couldn't format
// the supplied national number
// using the selected phone number pattern.
if (formatted_national_number) {
return this.full_phone_number(formatted_national_number);
}
// Couldn't format the supplied national number
// using the selected phone number pattern.
// Return raw phone number.
return this.parsed_input;
return this.reformat_national_number();
}

@@ -256,15 +275,9 @@

// then return the formatted number so far.
if (national_number_formatted_with_previous_format) {
return this.full_phone_number(national_number_formatted_with_previous_format);
}
// No format matches the phone number,
// therefore set `country` to `undefined`.
this.country = undefined;
// If no new phone number format could be chosen,
// and couldn't format the supplied national number
// using the selected phone number pattern,
// then it will return `undefined`.
// If no new phone number format could be chosen,
// And couldn't format the supplied national number
// using the selected phone number pattern.
// Return raw phone number
return this.parsed_input;
return national_number_formatted_with_previous_format;
}

@@ -423,5 +436,3 @@ }, {

if (matcher.test(this.national_number)) {
var formatted_national_number = (0, _format.format_national_number_using_format)(this.national_number, format, this.is_international(), this.national_prefix, this.country_metadata);
return this.full_phone_number(formatted_national_number);
return (0, _format.format_national_number_using_format)(this.national_number, format, this.is_international(), this.national_prefix, this.country_metadata);
}

@@ -451,9 +462,3 @@ }

if (this.is_international()) {
var result = '+' + this.country_phone_code;
if (formatted_national_number) {
result += ' ' + formatted_national_number;
}
return result;
return '+' + this.country_phone_code + ' ' + formatted_national_number;
}

@@ -562,3 +567,4 @@

// No format matches the national phone number entered
// No format matches the phone number,
// therefore set `country` to `undefined`.
} catch (err) {

@@ -579,2 +585,5 @@ _didIteratorError2 = true;

this.country = this.default_country;
// No format matches the national phone number entered
this.reset_format();

@@ -646,2 +655,7 @@ }

}
// For local numbers, replace national prefix
// with a digit placeholder.
else {
this.template = this.template.replace(/\d/g, DIGIT_PLACEHOLDER);
}

@@ -648,0 +662,0 @@ // This one is for national number only

@@ -0,1 +1,6 @@

0.1.17 / 01.12.2016
===================
* "As you type" formatter `template` fix for national prefixes (which weren't replaced with `x`-es)
0.1.16 / 01.12.2016

@@ -2,0 +7,0 @@ ===================

{
"name": "libphonenumber-js",
"version": "0.1.16",
"version": "0.1.17",
"description": "A simpler (and smaller) rewrite of Google Android's famous libphonenumber library",

@@ -5,0 +5,0 @@ "main": "index.common.js",

@@ -119,4 +119,2 @@ // This is an enhanced port of Google Android `libphonenumber`'s

{
this.valid = false
// Parse input

@@ -142,4 +140,7 @@

let input = parse_phone_number(extracted_number)
return this.process_input(parse_phone_number(extracted_number))
}
process_input(input)
{
// If an out of position '+' sign detected

@@ -158,4 +159,8 @@ // (or a second '+' sign),

// Raw phone number
this.parsed_input += input
// Reset phone number validation state
this.valid = false
// Add digits to the national number

@@ -177,3 +182,5 @@ this.national_number += input

// If no country phone code could be extracted so far,
// then just return the raw phone number.
// then just return the raw phone number,
// because it has no way of knowing
// how to format the phone number so far.
if (!this.extract_country_phone_code())

@@ -236,2 +243,20 @@ {

// Format the phone number (given the next digits)
const formatted_national_phone_number = this.format_national_phone_number(input)
// If the phone number could be formatted,
// then return it, possibly prepending with country phone code
// (for international phone numbers only)
if (formatted_national_phone_number)
{
return this.full_phone_number(formatted_national_phone_number)
}
// If the phone number couldn't be formatted,
// then just fall back to the raw phone number.
return this.parsed_input
}
format_national_phone_number(next_digits)
{
// Format the next phone number digits

@@ -247,3 +272,3 @@ // using the previously chosen phone number format.

{
national_number_formatted_with_previous_format = this.format_next_national_number_digits(input)
national_number_formatted_with_previous_format = this.format_next_national_number_digits(next_digits)
}

@@ -276,13 +301,7 @@

const formatted_national_number = this.reformat_national_number()
// Will return `undefined` if it couldn't format
// the supplied national number
// using the selected phone number pattern.
if (formatted_national_number)
{
return this.full_phone_number(formatted_national_number)
}
// Couldn't format the supplied national number
// using the selected phone number pattern.
// Return raw phone number.
return this.parsed_input
return this.reformat_national_number()
}

@@ -293,16 +312,9 @@

// then return the formatted number so far.
if (national_number_formatted_with_previous_format)
{
return this.full_phone_number(national_number_formatted_with_previous_format)
}
// No format matches the phone number,
// therefore set `country` to `undefined`.
this.country = undefined
// If no new phone number format could be chosen,
// and couldn't format the supplied national number
// using the selected phone number pattern,
// then it will return `undefined`.
// If no new phone number format could be chosen,
// And couldn't format the supplied national number
// using the selected phone number pattern.
// Return raw phone number
return this.parsed_input
return national_number_formatted_with_previous_format
}

@@ -465,3 +477,3 @@

{
const formatted_national_number = format_national_number_using_format
return format_national_number_using_format
(

@@ -474,4 +486,2 @@ this.national_number,

)
return this.full_phone_number(formatted_national_number)
}

@@ -486,10 +496,3 @@ }

{
let result = '+' + this.country_phone_code
if (formatted_national_number)
{
result += ' ' + formatted_national_number
}
return result
return `+${this.country_phone_code} ${formatted_national_number}`
}

@@ -595,2 +598,6 @@

// No format matches the phone number,
// therefore set `country` to `undefined`.
this.country = this.default_country
// No format matches the national phone number entered

@@ -668,2 +675,8 @@ this.reset_format()

}
// For local numbers, replace national prefix
// with a digit placeholder.
else
{
this.template = this.template.replace(/\d/g, DIGIT_PLACEHOLDER)
}

@@ -670,0 +683,0 @@ // This one is for national number only

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc