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 1.9.3 to 1.9.4

build/helpers/applyInternationalSeparatorStyle.js

4

build/AsYouType.js

@@ -18,3 +18,3 @@ "use strict";

var _parse_ = require("./parse_");
var _getCountryByCallingCode = _interopRequireDefault(require("./helpers/getCountryByCallingCode"));

@@ -340,3 +340,3 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }

value: function determineTheCountry() {
this.state.setCountry((0, _parse_.findCountryCode)(this.isInternational() ? this.state.callingCode : this.defaultCallingCode, this.state.nationalSignificantNumber, this.metadata));
this.state.setCountry((0, _getCountryByCallingCode["default"])(this.isInternational() ? this.state.callingCode : this.defaultCallingCode, this.state.nationalSignificantNumber, this.metadata));
}

@@ -343,0 +343,0 @@ /**

@@ -9,7 +9,7 @@ "use strict";

var _checkNumberLength = _interopRequireDefault(require("./checkNumberLength"));
var _checkNumberLength = _interopRequireDefault(require("./helpers/checkNumberLength"));
var _parseDigits = _interopRequireDefault(require("./parseDigits"));
var _parseDigits = _interopRequireDefault(require("./helpers/parseDigits"));
var _format_ = require("./format_");
var _formatNationalNumberUsingFormat = _interopRequireDefault(require("./helpers/formatNationalNumberUsingFormat"));

@@ -80,3 +80,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

getSeparatorAfterNationalPrefix = _ref3.getSeparatorAfterNationalPrefix;
var formattedNationalNumber = (0, _format_.formatNationalNumberUsingFormat)(state.nationalSignificantNumber, format, {
var formattedNationalNumber = (0, _formatNationalNumberUsingFormat["default"])(state.nationalSignificantNumber, format, {
carrierCode: state.carrierCode,

@@ -83,0 +83,0 @@ useInternationalFormat: state.international,

@@ -14,4 +14,2 @@ "use strict";

var _parseDigits = _interopRequireDefault(require("./parseDigits"));
var _AsYouTypeFormatter = require("./AsYouTypeFormatter.util");

@@ -21,10 +19,14 @@

var _format_ = require("./format_");
var _parseDigits = _interopRequireDefault(require("./helpers/parseDigits"));
var _formatNationalNumberUsingFormat = require("./helpers/formatNationalNumberUsingFormat");
var _constants = require("./constants");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
var _applyInternationalSeparatorStyle = _interopRequireDefault(require("./helpers/applyInternationalSeparatorStyle"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -651,3 +653,3 @@

})) {
var numberFormatWithNationalPrefix = numberFormat.replace(_format_.FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()); // If `national_prefix_formatting_rule` of a `format` simply prepends
var numberFormatWithNationalPrefix = numberFormat.replace(_formatNationalNumberUsingFormat.FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()); // If `national_prefix_formatting_rule` of a `format` simply prepends
// national prefix at the start of a national (significant) number,

@@ -697,3 +699,3 @@ // then such formatting can be used with `AsYouType` formatter.

if (international) {
template = (0, _format_.applyInternationalSeparatorStyle)(template);
template = (0, _applyInternationalSeparatorStyle["default"])(template);
}

@@ -700,0 +702,0 @@

@@ -9,8 +9,12 @@ "use strict";

var _parseDigits = _interopRequireDefault(require("./parseDigits"));
var _extractCountryCallingCode2 = _interopRequireDefault(require("./helpers/extractCountryCallingCode"));
var _parse_ = require("./parse_");
var _extractCountryCallingCodeFromInternationalNumberWithoutPlusSign = _interopRequireDefault(require("./helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign"));
var _IDD = require("./IDD");
var _extractNationalNumberFromPossiblyIncompleteNumber = _interopRequireDefault(require("./helpers/extractNationalNumberFromPossiblyIncompleteNumber"));
var _stripIddPrefix = _interopRequireDefault(require("./helpers/stripIddPrefix"));
var _parseDigits = _interopRequireDefault(require("./helpers/parseDigits"));
var _constants = require("./constants");

@@ -119,3 +123,3 @@

if (hasReceivedThreeLeadingDigits) {
this.extractIDDPrefix(state);
this.extractIddPrefix(state);
}

@@ -154,3 +158,3 @@

value: function extractCountryCallingCode(state) {
var _extractCountryCallin = (0, _parse_.extractCountryCallingCode)('+' + state.getDigitsWithoutInternationalPrefix(), this.defaultCountry, this.defaultCallingCode, this.metadata.metadata),
var _extractCountryCallin = (0, _extractCountryCallingCode2["default"])('+' + state.getDigitsWithoutInternationalPrefix(), this.defaultCountry, this.defaultCallingCode, this.metadata.metadata),
countryCallingCode = _extractCountryCallin.countryCallingCode,

@@ -196,3 +200,3 @@ number = _extractCountryCallin.number;

var _extractNationalNumbe = (0, _parse_.extractNationalNumberFromPossiblyIncompleteNumber)(nationalDigits, this.metadata),
var _extractNationalNumbe = (0, _extractNationalNumberFromPossiblyIncompleteNumber["default"])(nationalDigits, this.metadata),
nationalPrefix = _extractNationalNumbe.nationalPrefix,

@@ -226,3 +230,3 @@ nationalNumber = _extractNationalNumbe.nationalNumber,

var _extractNationalNumbe2 = (0, _parse_.extractNationalNumberFromPossiblyIncompleteNumber)(nationalDigits, this.metadata),
var _extractNationalNumbe2 = (0, _extractNationalNumberFromPossiblyIncompleteNumber["default"])(nationalDigits, this.metadata),
nationalPrefix = _extractNationalNumbe2.nationalPrefix,

@@ -342,3 +346,3 @@ nationalNumber = _extractNationalNumbe2.nationalNumber,

if (this.extractIDDPrefix(state)) {
if (this.extractIddPrefix(state)) {
this.extractCallingCodeAndNationalSignificantNumber(state);

@@ -361,4 +365,4 @@ return true;

}, {
key: "extractIDDPrefix",
value: function extractIDDPrefix(state) {
key: "extractIddPrefix",
value: function extractIddPrefix(state) {
// An IDD prefix can't be present in a number written with a `+`.

@@ -379,3 +383,3 @@ // Also, don't re-extract an IDD prefix if has already been extracted.

var numberWithoutIDD = (0, _IDD.stripIDDPrefix)(digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata);
var numberWithoutIDD = (0, _stripIddPrefix["default"])(digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata);

@@ -396,3 +400,3 @@ if (numberWithoutIDD !== undefined && numberWithoutIDD !== digits) {

if (!state.international) {
var _extractCountryCallin2 = (0, _parse_.extractCountryCallingCodeFromInternationalNumberWithoutPlusSign)(state.digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata),
var _extractCountryCallin2 = (0, _extractCountryCallingCodeFromInternationalNumberWithoutPlusSign["default"])(state.digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata),
newCallingCode = _extractCountryCallin2.countryCallingCode,

@@ -399,0 +403,0 @@ number = _extractCountryCallin2.number;

@@ -11,3 +11,3 @@ "use strict";

var _parseDigits = _interopRequireDefault(require("../parseDigits"));
var _parseDigits = _interopRequireDefault(require("../helpers/parseDigits"));

@@ -14,0 +14,0 @@ var _util = require("./util");

@@ -8,12 +8,12 @@ "use strict";

exports.searchPhoneNumbers = searchPhoneNumbers;
exports.PhoneNumberSearch = void 0;
exports.PhoneNumberSearch = exports.EXTN_PATTERNS_FOR_PARSING = void 0;
var _constants = require("./constants");
var _extension = require("./extension");
var _parse_ = _interopRequireDefault(require("./parse_"));
var _isViablePhoneNumber = require("./isViablePhoneNumber");
var _isViablePhoneNumber = require("./helpers/isViablePhoneNumber");
var _createExtensionPattern = _interopRequireDefault(require("./helpers/extension/createExtensionPattern"));
var _parsePreCandidate = _interopRequireDefault(require("./findNumbers/parsePreCandidate"));

@@ -35,2 +35,19 @@

/**
* Regexp of all possible ways to write extensions, for use when parsing. This
* will be run as a case-insensitive regexp match. Wide character versions are
* also provided after each ASCII version. There are three regular expressions
* here. The first covers RFC 3966 format, where the extension is added using
* ';ext='. The second more generic one starts with optional white space and
* ends with an optional full stop (.), followed by zero or more spaces/tabs
* /commas and then the numbers themselves. The other one covers the special
* case of American numbers where the extension is written with a hash at the
* end, such as '- 503#'. Note that the only capturing groups should be around
* the digits that you want to capture as part of the extension, or else parsing
* will fail! We allow two options for representing the accented o - the
* character itself, and one in the unicode decomposed form with the combining
* acute accent.
*/
var EXTN_PATTERNS_FOR_PARSING = (0, _createExtensionPattern["default"])('parsing');
exports.EXTN_PATTERNS_FOR_PARSING = EXTN_PATTERNS_FOR_PARSING;
var WHITESPACE_IN_THE_BEGINNING_PATTERN = new RegExp('^[' + _constants.WHITESPACE + ']+');

@@ -37,0 +54,0 @@ var PUNCTUATION_IN_THE_END_PATTERN = new RegExp('[' + _constants.VALID_PUNCTUATION + ']+$'); // // Regular expression for getting opening brackets for a valid number

@@ -7,18 +7,17 @@ "use strict";

exports["default"] = formatNumber;
exports.formatNationalNumberUsingFormat = formatNationalNumberUsingFormat;
exports.applyInternationalSeparatorStyle = applyInternationalSeparatorStyle;
exports.FIRST_GROUP_PATTERN = void 0;
var _constants = require("./constants");
var _matchesEntirely = _interopRequireDefault(require("./helpers/matchesEntirely"));
var _util = require("./util");
var _formatNationalNumberUsingFormat = _interopRequireDefault(require("./helpers/formatNationalNumberUsingFormat"));
var _metadata = _interopRequireWildcard(require("./metadata"));
var _IDD = require("./IDD");
var _getIddPrefix = _interopRequireDefault(require("./helpers/getIddPrefix"));
var _RFC = require("./RFC3966");
var _RFC = require("./helpers/RFC3966");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

@@ -121,36 +120,2 @@

}
} // This was originally set to $1 but there are some countries for which the
// first group is not used in the national pattern (e.g. Argentina) so the $1
// group does not match correctly. Therefore, we use `\d`, so that the first
// group actually used in the pattern will be matched.
var FIRST_GROUP_PATTERN = /(\$\d)/;
exports.FIRST_GROUP_PATTERN = FIRST_GROUP_PATTERN;
function formatNationalNumberUsingFormat(number, format, _ref) {
var useInternationalFormat = _ref.useInternationalFormat,
withNationalPrefix = _ref.withNationalPrefix,
carrierCode = _ref.carrierCode,
metadata = _ref.metadata;
var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
// because that one is only used when formatting phone numbers
// for dialing from a mobile phone, and this is not a dialing library.
// carrierCode && format.domesticCarrierCodeFormattingRule()
// // First, replace the $CC in the formatting rule with the desired carrier code.
// // Then, replace the $FG in the formatting rule with the first group
// // and the carrier code combined in the appropriate way.
// ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
// : (
// withNationalPrefix && format.nationalPrefixFormattingRule()
// ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
// : format.format()
// )
withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
if (useInternationalFormat) {
return applyInternationalSeparatorStyle(formattedNumber);
}
return formattedNumber;
}

@@ -165,3 +130,3 @@

return formatNationalNumberUsingFormat(number, format, {
return (0, _formatNationalNumberUsingFormat["default"])(number, format, {
useInternationalFormat: formatAs === 'INTERNATIONAL',

@@ -176,14 +141,14 @@ withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,

for (var _iterator = availableFormats, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref2;
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref2 = _iterator[_i++];
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref2 = _i.value;
_ref = _i.value;
}
var format = _ref2;
var format = _ref;

@@ -201,40 +166,6 @@ // Validate leading digits

if ((0, _util.matchesEntirely)(nationalNnumber, format.pattern())) {
if ((0, _matchesEntirely["default"])(nationalNnumber, format.pattern())) {
return format;
}
}
} // Removes brackets and replaces dashes with spaces.
//
// E.g. "(999) 111-22-33" -> "999 111 22 33"
//
// For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
// Meanwhile, there's no single opinion about using punctuation in international phone numbers.
//
// For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
// And here's a quote from WikiPedia's "North American Numbering Plan" page:
// https://en.wikipedia.org/wiki/North_American_Numbering_Plan
//
// "The country calling code for all countries participating in the NANP is 1.
// In international format, an NANP number should be listed as +1 301 555 01 00,
// where 301 is an area code (Maryland)."
//
// I personally prefer the international format without any punctuation.
// For example, brackets are remnants of the old age, meaning that the
// phone number part in brackets (so called "area code") can be omitted
// if dialing within the same "area".
// And hyphens were clearly introduced for splitting local numbers into memorizable groups.
// For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
// Imagine a man taking a bus from home to work and seeing an ad with a phone number.
// He has a couple of seconds to memorize that number until it passes by.
// If it were spaces instead of hyphens the man wouldn't necessarily get it,
// but with hyphens instead of spaces the grouping is more explicit.
// I personally think that hyphens introduce visual clutter,
// so I prefer replacing them with spaces in international numbers.
// In the modern age all output is done on displays where spaces are clearly distinguishable
// so hyphens can be safely replaced with spaces without losing any legibility.
//
function applyInternationalSeparatorStyle(local) {
return local.replace(new RegExp("[".concat(_constants.VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
}

@@ -269,8 +200,8 @@

var IDDPrefix = (0, _IDD.getIDDPrefix)(fromCountry, undefined, metadata.metadata);
var iddPrefix = (0, _getIddPrefix["default"])(fromCountry, undefined, metadata.metadata);
if (IDDPrefix) {
return "".concat(IDDPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
if (iddPrefix) {
return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
}
}
//# sourceMappingURL=format_.js.map

@@ -5,4 +5,2 @@ "use strict";

var _format_ = require("./format_");
var _format = _interopRequireDefault(require("./format"));

@@ -155,6 +153,2 @@

});
it('should change Google\'s international format style', function () {
(0, _format_.applyInternationalSeparatorStyle)('(xxx) xxx-xx-xx').should.equal('xxx xxx xx xx');
(0, _format_.applyInternationalSeparatorStyle)('(xxx)xxx').should.equal('xxx xxx');
});
it('should format phone number extensions', function () {

@@ -161,0 +155,0 @@ // National

@@ -12,5 +12,5 @@ "use strict";

var _getNumberType_ = _interopRequireDefault(require("./getNumberType_"));
var _getNumberType = _interopRequireDefault(require("./helpers/getNumberType"));
var _checkNumberLength = _interopRequireDefault(require("./checkNumberLength"));
var _checkNumberLength = _interopRequireDefault(require("./helpers/checkNumberLength"));

@@ -59,3 +59,3 @@ var _getCountryCallingCode = _interopRequireDefault(require("./getCountryCallingCode"));

};
var number_type = (0, _getNumberType_["default"])(number, undefined, metadata.metadata);
var number_type = (0, _getNumberType["default"])(number, undefined, metadata.metadata);
var is_valid_number = number_type === number;

@@ -62,0 +62,0 @@ var formatted_number;

@@ -9,5 +9,5 @@ "use strict";

var _isViablePhoneNumber = _interopRequireDefault(require("./isViablePhoneNumber"));
var _isViablePhoneNumber = _interopRequireDefault(require("./helpers/isViablePhoneNumber"));
var _getNumberType_ = _interopRequireDefault(require("./getNumberType_"));
var _getNumberType2 = _interopRequireDefault(require("./helpers/getNumberType"));

@@ -35,3 +35,3 @@ var _parse_ = _interopRequireDefault(require("./parse_"));

return (0, _getNumberType_["default"])(input, options, metadata);
return (0, _getNumberType2["default"])(input, options, metadata);
} // Sort out arguments

@@ -38,0 +38,0 @@

@@ -11,3 +11,3 @@ "use strict";

var _checkNumberLength = _interopRequireDefault(require("./checkNumberLength"));
var _checkNumberLength = _interopRequireDefault(require("./helpers/checkNumberLength"));

@@ -14,0 +14,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -8,3 +8,3 @@ "use strict";

var _isViablePhoneNumber = _interopRequireDefault(require("./isViablePhoneNumber"));
var _isViablePhoneNumber = _interopRequireDefault(require("./helpers/isViablePhoneNumber"));

@@ -11,0 +11,0 @@ var _parse_ = _interopRequireDefault(require("./parse_"));

@@ -8,12 +8,5 @@ "use strict";

exports.extractFormattedPhoneNumber = extractFormattedPhoneNumber;
exports.extractNationalNumberFromPossiblyIncompleteNumber = extractNationalNumberFromPossiblyIncompleteNumber;
exports.findCountryCode = findCountryCode;
exports.extractNationalNumber = extractNationalNumber;
exports.extractCountryCallingCode = extractCountryCallingCode;
exports.extractCountryCallingCodeFromInternationalNumberWithoutPlusSign = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign;
var _constants = require("./constants");
var _util = require("./util");
var _ParseError = _interopRequireDefault(require("./ParseError"));

@@ -23,5 +16,5 @@

var _isViablePhoneNumber = _interopRequireDefault(require("./isViablePhoneNumber"));
var _isViablePhoneNumber = _interopRequireDefault(require("./helpers/isViablePhoneNumber"));
var _extension = require("./extension");
var _extractExtension = _interopRequireDefault(require("./helpers/extension/extractExtension"));

@@ -32,14 +25,20 @@ var _parseIncompletePhoneNumber = _interopRequireDefault(require("./parseIncompletePhoneNumber"));

var _getNumberType_ = _interopRequireDefault(require("./getNumberType_"));
var _isPossibleNumber_ = require("./isPossibleNumber_");
var _checkNumberLength = _interopRequireDefault(require("./checkNumberLength"));
var _RFC = require("./helpers/RFC3966");
var _isPossibleNumber_ = require("./isPossibleNumber_");
var _PhoneNumber = _interopRequireDefault(require("./PhoneNumber"));
var _IDD = require("./IDD");
var _matchesEntirely = _interopRequireDefault(require("./helpers/matchesEntirely"));
var _RFC = require("./RFC3966");
var _extractCountryCallingCode = _interopRequireDefault(require("./helpers/extractCountryCallingCode"));
var _PhoneNumber = _interopRequireDefault(require("./PhoneNumber"));
var _extractCountryCallingCodeFromInternationalNumberWithoutPlusSign = _interopRequireDefault(require("./helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign"));
var _extractNationalNumber = _interopRequireDefault(require("./helpers/extractNationalNumber"));
var _stripIddPrefix = _interopRequireDefault(require("./helpers/stripIddPrefix"));
var _getCountryByCallingCode = _interopRequireDefault(require("./helpers/getCountryByCallingCode"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -181,3 +180,3 @@

var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? (0, _util.matchesEntirely)(nationalNumber, metadata.nationalNumberPattern()) : false;
var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? (0, _matchesEntirely["default"])(nationalNumber, metadata.nationalNumberPattern()) : false;

@@ -237,197 +236,2 @@ if (!options.extended) {

/**
* Strips any national prefix (such as 0, 1) present in a
* (possibly incomplete) number provided.
* "Carrier codes" are only used in Colombia and Brazil,
* and only when dialing within those countries from a mobile phone to a fixed line number.
* Sometimes it won't actually strip national prefix
* and will instead prepend some digits to the `number`:
* for example, when number `2345678` is passed with `VI` country selected,
* it will return `{ number: "3402345678" }`, because `340` area code is prepended.
* @param {string} number — National number digits.
* @param {object} metadata — Metadata with country selected.
* @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`.
*/
function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
// See METADATA.md for the description of
// `national_prefix_for_parsing` and `national_prefix_transform_rule`.
// Attempt to parse the first digits as a national prefix.
var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
var prefixMatch = prefixPattern.exec(number);
if (prefixMatch) {
var nationalNumber;
var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
// If a `national_prefix_for_parsing` has any "capturing groups"
// then it means that the national (significant) number is equal to
// those "capturing groups" transformed via `national_prefix_transform_rule`,
// and nothing could be said about the actual national prefix:
// what is it and was it even there.
// If a `national_prefix_for_parsing` doesn't have any "capturing groups",
// then everything it matches is a national prefix.
// To determine whether `national_prefix_for_parsing` matched any
// "capturing groups", the value of the result of calling `.exec()`
// is looked at, and if it has non-undefined values where there're
// "capturing groups" in the regular expression, then it means
// that "capturing groups" have been matched.
// It's not possible to tell whether there'll be any "capturing gropus"
// before the matching process, because a `national_prefix_for_parsing`
// could exhibit both behaviors.
var capturedGroupsCount = prefixMatch.length - 1;
var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
// then carrier code is the second one.
if (capturedGroupsCount > 1) {
carrierCode = prefixMatch[1];
}
} // If there're no "capturing groups",
// or if there're "capturing groups" but no
// `national_prefix_transform_rule`,
// then just strip the national prefix from the number,
// and possibly a carrier code.
// Seems like there could be more.
else {
// `prefixBeforeNationalNumber` is the whole substring matched by
// the `national_prefix_for_parsing` regular expression.
// There seem to be no guarantees that it's just a national prefix.
// For example, if there's a carrier code, it's gonna be a
// part of `prefixBeforeNationalNumber` too.
var prefixBeforeNationalNumber = prefixMatch[0];
nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
// then carrier code is the first one.
if (hasCapturedGroups) {
carrierCode = prefixMatch[1];
}
} // Tries to guess whether a national prefix was present in the input.
// This is not something copy-pasted from Google's library:
// they don't seem to have an equivalent for that.
// So this isn't an "officially approved" way of doing something like that.
// But since there seems no other existing method, this library uses it.
var nationalPrefix;
if (hasCapturedGroups) {
var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
// `prefixMatch[0]` is `01115`, and `$1` is `11`,
// and the rest of the phone number is `23456789`.
// The national number is transformed via `9$1` to `91123456789`.
// National prefix `0` is detected being present at the start.
// if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
nationalPrefix = metadata.numberingPlan.nationalPrefix();
}
} else {
nationalPrefix = prefixMatch[0];
}
return {
nationalNumber: nationalNumber,
nationalPrefix: nationalPrefix,
carrierCode: carrierCode
};
}
}
return {
nationalNumber: number
};
} // In some countries, the same digit could be a national prefix
// or a leading digit of a valid phone number.
// For example, in Russia, national prefix is `8`,
// and also `800 555 35 35` is a valid number
// in which `8` is not a national prefix, but the first digit
// of a national (significant) number.
// Same's with Belarus:
// `82004910060` is a valid national (significant) number,
// but `2004910060` is not.
// To support such cases (to prevent the code from always stripping
// national prefix), a condition is imposed: a national prefix
// is not extracted when the original number is "viable" and the
// resultant number is not, a "viable" national number being the one
// that matches `national_number_pattern`.
function shouldExtractNationalPrefix(number, nationalSignificantNumber, metadata) {
// The equivalent in Google's code is:
// https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
if ((0, _util.matchesEntirely)(number, metadata.nationalNumberPattern()) && !(0, _util.matchesEntirely)(nationalSignificantNumber, metadata.nationalNumberPattern())) {
return false;
} // Just "possible" number check would be more relaxed, so it's not used.
// if (isPossibleNumber(number, metadata) &&
// !isPossibleNumber(numberWithNationalPrefixExtracted, metadata)) {
// return false
// }
return true;
}
function findCountryCode(callingCode, nationalPhoneNumber, metadata) {
/* istanbul ignore if */
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
if (metadata.isNonGeographicCallingCode(callingCode)) {
return '001';
}
} // Is always non-empty, because `callingCode` is always valid
var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
if (!possibleCountries) {
return;
} // If there's just one country corresponding to the country code,
// then just return it, without further phone number digits validation.
if (possibleCountries.length === 1) {
return possibleCountries[0];
}
return _findCountryCode(possibleCountries, nationalPhoneNumber, metadata.metadata);
} // Changes `metadata` `country`.
function _findCountryCode(possibleCountries, nationalPhoneNumber, metadata) {
metadata = new _metadata["default"](metadata);
for (var _iterator = possibleCountries, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var country = _ref;
metadata.country(country); // Leading digits check would be the simplest one
if (metadata.leadingDigits()) {
if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
return country;
}
} // Else perform full validation with all of those
// fixed-line/mobile/etc regular expressions.
else if ((0, _getNumberType_["default"])({
phone: nationalPhoneNumber,
country: country
}, undefined, metadata.metadata)) {
return country;
}
}
}
/**
* @param {string} text - Input.

@@ -452,3 +256,3 @@ * @return {object} `{ ?number, ?ext }`.

var withExtensionStripped = (0, _extension.extractExtension)(number);
var withExtensionStripped = (0, _extractExtension["default"])(number);

@@ -492,3 +296,3 @@ if (withExtensionStripped.ext) {

// Extract calling code from phone number.
var _extractCountryCallin = extractCountryCallingCode((0, _parseIncompletePhoneNumber["default"])(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
var _extractCountryCallin = (0, _extractCountryCallingCode["default"])((0, _parseIncompletePhoneNumber["default"])(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
countryCallingCode = _extractCountryCallin.countryCallingCode,

@@ -527,3 +331,3 @@ number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.

var _extractNationalNumbe = extractNationalNumber((0, _parseIncompletePhoneNumber["default"])(number), metadata),
var _extractNationalNumbe = (0, _extractNationalNumber["default"])((0, _parseIncompletePhoneNumber["default"])(number), metadata),
nationalNumber = _extractNationalNumbe.nationalNumber,

@@ -542,3 +346,3 @@ carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries

var exactCountry = findCountryCode(countryCallingCode, nationalNumber, metadata);
var exactCountry = (0, _getCountryByCallingCode["default"])(countryCallingCode, nationalNumber, metadata);

@@ -564,212 +368,2 @@ if (exactCountry) {

}
/**
* Strips national prefix and carrier code from a complete phone number.
* The difference from the non-"FromCompleteNumber" function is that
* it won't extract national prefix if the resultant number is too short
* to be a complete number for the selected phone numbering plan.
* @param {string} number — Complete phone number digits.
* @param {Metadata} metadata — Metadata with a phone numbering plan selected.
* @return {object} `{ nationalNumber: string, carrierCode: string? }`.
*/
function extractNationalNumber(number, metadata) {
// Parsing national prefixes and carrier codes
// is only required for local phone numbers
// but some people don't understand that
// and sometimes write international phone numbers
// with national prefixes (or maybe even carrier codes).
// http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
// Google's original library forgives such mistakes
// and so does this library, because it has been requested:
// https://github.com/catamphetamine/libphonenumber-js/issues/127
var _extractNationalNumbe2 = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
nationalNumber = _extractNationalNumbe2.nationalNumber,
carrierCode = _extractNationalNumbe2.carrierCode;
if (!shouldExtractNationalPrefix(number, nationalNumber, metadata)) {
// Don't strip the national prefix.
return {
nationalNumber: number
};
} // If a national prefix has been extracted, check to see
// if the resultant number isn't too short.
// Same code in Google's `libphonenumber`:
// https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3291-L3302
// For some reason, they do this check right after the `national_number_pattern` check
// this library does in `shouldExtractNationalPrefix()` function.
// Why is there a second "resultant" number validity check?
// They don't provide an explanation.
// This library just copies the behavior.
if (number.length !== nationalNumber.length + (carrierCode ? carrierCode.length : 0)) {
// If not using legacy generated metadata (before version `1.0.18`)
// then it has "possible lengths", so use those to validate the number length.
if (metadata.possibleLengths()) {
// "We require that the NSN remaining after stripping the national prefix and
// carrier code be long enough to be a possible length for the region.
// Otherwise, we don't do the stripping, since the original number could be
// a valid short number."
// https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
switch ((0, _checkNumberLength["default"])(nationalNumber, metadata)) {
case 'TOO_SHORT':
case 'INVALID_LENGTH':
// case 'IS_POSSIBLE_LOCAL_ONLY':
// Don't strip the national prefix.
return {
nationalNumber: number
};
}
}
}
return {
nationalNumber: nationalNumber,
carrierCode: carrierCode
};
}
/**
* Converts a phone number digits (possibly with a `+`)
* into a calling code and the rest phone number digits.
* The "rest phone number digits" could include
* a national prefix, carrier code, and national
* (significant) number.
* @param {string} number — Phone number digits (possibly with a `+`).
* @param {string} [country] — Default country.
* @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
* @param {object} metadata
* @return {object} `{ countryCallingCode: string?, number: string }`
* @example
* // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
* extractCountryCallingCode('2133734253', 'US', null, metadata)
* extractCountryCallingCode('2133734253', null, '1', metadata)
* extractCountryCallingCode('+12133734253', null, null, metadata)
* extractCountryCallingCode('+12133734253', 'RU', null, metadata)
*/
function extractCountryCallingCode(number, country, callingCode, metadata) {
if (!number) {
return {};
} // If this is not an international phone number,
// then either extract an "IDD" prefix, or extract a
// country calling code from a number by autocorrecting it
// by prepending a leading `+` in cases when it starts
// with the country calling code.
// https://wikitravel.org/en/International_dialling_prefix
// https://github.com/catamphetamine/libphonenumber-js/issues/376
if (number[0] !== '+') {
// Convert an "out-of-country" dialing phone number
// to a proper international phone number.
var numberWithoutIDD = (0, _IDD.stripIDDPrefix)(number, country, callingCode, metadata); // If an IDD prefix was stripped then
// convert the number to international one
// for subsequent parsing.
if (numberWithoutIDD && numberWithoutIDD !== number) {
number = '+' + numberWithoutIDD;
} else {
// Check to see if the number starts with the country calling code
// for the default country. If so, we remove the country calling code,
// and do some checks on the validity of the number before and after.
// https://github.com/catamphetamine/libphonenumber-js/issues/376
if (country || callingCode) {
var _extractCountryCallin2 = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
countryCallingCode = _extractCountryCallin2.countryCallingCode,
shorterNumber = _extractCountryCallin2.number;
if (countryCallingCode) {
return {
countryCallingCode: countryCallingCode,
number: shorterNumber
};
}
}
return {
number: number
};
}
} // Fast abortion: country codes do not begin with a '0'
if (number[1] === '0') {
return {};
}
metadata = new _metadata["default"](metadata); // The thing with country phone codes
// is that they are orthogonal to each other
// i.e. there's no such country phone code A
// for which country phone code B exists
// where B starts with A.
// Therefore, while scanning digits,
// if a valid country code is found,
// that means that it is the country code.
//
var i = 2;
while (i - 1 <= _constants.MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
var _countryCallingCode = number.slice(1, i);
if (metadata.hasCallingCode(_countryCallingCode)) {
metadata.selectNumberingPlan(_countryCallingCode);
return {
countryCallingCode: _countryCallingCode,
number: number.slice(i)
};
}
i++;
}
return {};
}
/**
* Sometimes some people incorrectly input international phone numbers
* without the leading `+`. This function corrects such input.
* @param {string} number — Phone number digits.
* @param {string?} country
* @param {string?} callingCode
* @param {object} metadata
* @return {object} `{ countryCallingCode: string?, number: string }`.
*/
function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
var countryCallingCode = country ? (0, _getCountryCallingCode["default"])(country, metadata) : callingCode;
if (number.indexOf(countryCallingCode) === 0) {
metadata = new _metadata["default"](metadata);
metadata.selectNumberingPlan(country, callingCode);
var possibleShorterNumber = number.slice(countryCallingCode.length);
var _extractNationalNumbe3 = extractNationalNumber(possibleShorterNumber, metadata),
possibleShorterNationalNumber = _extractNationalNumbe3.nationalNumber;
var _extractNationalNumbe4 = extractNationalNumber(number, metadata),
nationalNumber = _extractNationalNumbe4.nationalNumber; // If the number was not valid before but is valid now,
// or if it was too long before, we consider the number
// with the country calling code stripped to be a better result
// and keep that instead.
// For example, in Germany (+49), `49` is a valid area code,
// so if a number starts with `49`, it could be both a valid
// national German number or an international number without
// a leading `+`.
if (!(0, _util.matchesEntirely)(nationalNumber, metadata.nationalNumberPattern()) && (0, _util.matchesEntirely)(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || (0, _checkNumberLength["default"])(nationalNumber, metadata) === 'TOO_LONG') {
return {
countryCallingCode: countryCallingCode,
number: possibleShorterNumber
};
}
}
return {
number: number
};
}
//# sourceMappingURL=parse_.js.map

@@ -7,6 +7,4 @@ "use strict";

var _Metadata = _interopRequireDefault(require("./Metadata"));
var _metadata = _interopRequireDefault(require("./metadata"));
var _parse_ = require("./parse_");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -488,13 +486,2 @@

});
it('should extract country calling code from a number', function () {
(0, _parse_.extractCountryCallingCode)('+78005553535', null, null, _metadataMin["default"]).should.deep.equal({
countryCallingCode: '7',
number: '8005553535'
});
(0, _parse_.extractCountryCallingCode)('+7800', null, null, _metadataMin["default"]).should.deep.equal({
countryCallingCode: '7',
number: '800'
});
(0, _parse_.extractCountryCallingCode)('', null, null, _metadataMin["default"]).should.deep.equal({});
});
it('should correctly parse numbers starting with the same digit as the national prefix', function () {

@@ -583,13 +570,2 @@ // https://github.com/catamphetamine/libphonenumber-js/issues/373

});
describe('extractNationalNumberFromPossiblyIncompleteNumber', function () {
it('should parse a carrier code when there is no national prefix transform rule', function () {
var meta = new _Metadata["default"](_metadataMin["default"]);
meta.country('AU');
(0, _parse_.extractNationalNumberFromPossiblyIncompleteNumber)('18311800123', meta).should.deep.equal({
nationalPrefix: undefined,
carrierCode: '1831',
nationalNumber: '1800123'
});
});
});
//# sourceMappingURL=parse.test.js.map

@@ -9,3 +9,3 @@ "use strict";

var _parseDigits = require("./parseDigits");
var _parseDigits = require("./helpers/parseDigits");

@@ -54,6 +54,9 @@ /**

/**
* `input-format` `parse()` function.
* https://gitlab.com/catamphetamine/input-format
* Parses next character while parsing phone number digits (including a `+`)
* from text: discards everything except `+` and digits, and `+` is only allowed
* at the start of a phone number.
* For example, is used in `react-phone-number-input` where it uses
* [`input-format`](https://gitlab.com/catamphetamine/input-format).
* @param {string} character - Yet another character from raw input string.
* @param {string} value - The value parsed so far.
* @param {string?} prevParsedCharacters - Previous parsed characters.
* @param {object} meta - Optional custom use-case-specific metadata.

@@ -64,3 +67,3 @@ * @return {string?} The parsed character.

function parsePhoneNumberCharacter(character, value) {
function parsePhoneNumberCharacter(character, prevParsedCharacters) {
// Only allow a leading `+`.

@@ -70,3 +73,3 @@ if (character === '+') {

// then discard it.
if (value) {
if (prevParsedCharacters) {
return;

@@ -73,0 +76,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

var _getNumberType_ = _interopRequireDefault(require("./getNumberType_"));
var _getNumberType = _interopRequireDefault(require("./helpers/getNumberType"));

@@ -107,3 +107,3 @@ var _format_ = _interopRequireDefault(require("./format_"));

value: function getType() {
return (0, _getNumberType_["default"])(this, {
return (0, _getNumberType["default"])(this, {
v2: true

@@ -110,0 +110,0 @@ }, this.metadata);

@@ -12,3 +12,3 @@ "use strict";

var _extension = require("./extension");
var _createExtensionPattern = _interopRequireDefault(require("./helpers/extension/createExtensionPattern"));

@@ -47,2 +47,3 @@ var _RegExpCache = _interopRequireDefault(require("./findNumbers/RegExpCache"));

var EXTN_PATTERNS_FOR_MATCHING = (0, _createExtensionPattern["default"])('matching');
/**

@@ -58,2 +59,3 @@ * Patterns used to extract phone numbers from a larger phone-number-like pattern. These are

*/
var INNER_MATCHES = [// Breaks on the slash - e.g. "651-234-2345/332-445-1234"

@@ -104,3 +106,3 @@ '\\/+(.*)/', // Note that the bracket here is inside the capturing group, since we consider it part of the

var PATTERN = '(?:' + _isValidCandidate.LEAD_CLASS + punctuation + ')' + leadLimit + digitSequence + '(?:' + punctuation + digitSequence + ')' + blockLimit + '(?:' + _extension.EXTN_PATTERNS_FOR_MATCHING + ')?'; // Regular expression of trailing characters that we want to remove.
var PATTERN = '(?:' + _isValidCandidate.LEAD_CLASS + punctuation + ')' + leadLimit + digitSequence + '(?:' + punctuation + digitSequence + ')' + blockLimit + '(?:' + EXTN_PATTERNS_FOR_MATCHING + ')?'; // Regular expression of trailing characters that we want to remove.
// We remove all characters that are not alpha or numerical characters.

@@ -107,0 +109,0 @@ // The hash character is retained here, as it may signify

@@ -10,5 +10,5 @@ "use strict";

var _util = require("./util");
var _matchesEntirely = _interopRequireDefault(require("./helpers/matchesEntirely"));
var _getNumberType_ = _interopRequireDefault(require("./getNumberType_"));
var _getNumberType = _interopRequireDefault(require("./helpers/getNumberType"));

@@ -61,3 +61,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

if (metadata.hasTypes()) {
return (0, _getNumberType_["default"])(input, options, metadata.metadata) !== undefined;
return (0, _getNumberType["default"])(input, options, metadata.metadata) !== undefined;
} // If there are no type regexps for this country in metadata then use

@@ -68,4 +68,4 @@ // `nationalNumberPattern` as a "better than nothing" replacement.

var national_number = options.v2 ? input.nationalNumber : input.phone;
return (0, _util.matchesEntirely)(national_number, metadata.nationalNumberPattern());
return (0, _matchesEntirely["default"])(national_number, metadata.nationalNumberPattern());
}
//# sourceMappingURL=validate_.js.map

@@ -66,2 +66,7 @@ <!-- Maybe rename `metadata.full.json` -> `metadata.max.json`. -->

1.9.4 / 13.11.2020
==================
* Refactored the main ES6 export in order to support "tree shaking".
1.9.3 / 11.11.2020

@@ -68,0 +73,0 @@ ==================

@@ -41,5 +41,5 @@ 'use strict'

exports.parsePhoneNumberCharacter = require('../build/parseIncompletePhoneNumber').parsePhoneNumberCharacter
exports.parseDigits = require('../build/parseDigits').default
exports.parseDigits = require('../build/helpers/parseDigits').default
exports.parseRFC3966 = require('../build/RFC3966').parseRFC3966
exports.formatRFC3966 = require('../build/RFC3966').formatRFC3966
exports.parseRFC3966 = require('../build/helpers/RFC3966').parseRFC3966
exports.formatRFC3966 = require('../build/helpers/RFC3966').formatRFC3966

@@ -9,4 +9,7 @@ export { default as ParseError } from '../es6/ParseError'

// Deprecated.
export { default as findNumbers } from '../es6/findNumbers'
// Deprecated.
export { default as searchNumbers } from '../es6/searchNumbers'
export { default as findPhoneNumbersInText } from '../es6/findPhoneNumbersInText'

@@ -17,2 +20,3 @@ export { default as searchPhoneNumbersInText } from '../es6/searchPhoneNumbersInText'

export { default as AsYouType } from '../es6/AsYouType'
export { DIGIT_PLACEHOLDER } from '../es6/AsYouTypeFormatter'

@@ -26,4 +30,4 @@ export { default as getCountries } from '../es6/getCountries'

export { default as parseIncompletePhoneNumber, parsePhoneNumberCharacter } from '../es6/parseIncompletePhoneNumber'
export { default as parseDigits } from '../es6/parseDigits'
export { default as parseDigits } from '../es6/helpers/parseDigits'
export { parseRFC3966, formatRFC3966 } from '../es6/RFC3966'
export { parseRFC3966, formatRFC3966 } from '../es6/helpers/RFC3966'

@@ -55,3 +55,3 @@ // Deprecated.

exports.parsePhoneNumberCharacter = require('./build/parseIncompletePhoneNumber').parsePhoneNumberCharacter
exports.parseDigits = require('./build/parseDigits').default
exports.parseDigits = require('./build/helpers/parseDigits').default

@@ -64,3 +64,3 @@ // Deprecated: `DIGITS` were used by `react-phone-number-input`.

//
exports.DIGITS = require('./build/parseDigits').DIGITS
exports.DIGITS = require('./build/helpers/parseDigits').DIGITS
exports.DIGIT_PLACEHOLDER = require('./build/AsYouTypeFormatter').DIGIT_PLACEHOLDER

@@ -77,5 +77,5 @@

exports.parseRFC3966 = require('./build/RFC3966').parseRFC3966
exports.formatRFC3966 = require('./build/RFC3966').formatRFC3966
exports.parseRFC3966 = require('./build/helpers/RFC3966').parseRFC3966
exports.formatRFC3966 = require('./build/helpers/RFC3966').formatRFC3966
// exports['default'] = ...

@@ -22,3 +22,3 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

import AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser';
import { findCountryCode } from './parse_';
import getCountryByCallingCode from './helpers/getCountryByCallingCode';
var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;

@@ -323,3 +323,3 @@

value: function determineTheCountry() {
this.state.setCountry(findCountryCode(this.isInternational() ? this.state.callingCode : this.defaultCallingCode, this.state.nationalSignificantNumber, this.metadata));
this.state.setCountry(getCountryByCallingCode(this.isInternational() ? this.state.callingCode : this.defaultCallingCode, this.state.nationalSignificantNumber, this.metadata));
}

@@ -326,0 +326,0 @@ /**

@@ -1,4 +0,4 @@

import checkNumberLength from './checkNumberLength';
import parseDigits from './parseDigits';
import { formatNationalNumberUsingFormat } from './format_';
import checkNumberLength from './helpers/checkNumberLength';
import parseDigits from './helpers/parseDigits';
import formatNationalNumberUsingFormat from './helpers/formatNationalNumberUsingFormat';
export default function formatCompleteNumber(state, format, _ref) {

@@ -5,0 +5,0 @@ var metadata = _ref.metadata,

@@ -9,8 +9,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

import parseDigits from './parseDigits';
import { DIGIT_PLACEHOLDER, countOccurences, repeat, cutAndStripNonPairedParens, closeNonPairedParens, stripNonPairedParens, populateTemplateWithDigits } from './AsYouTypeFormatter.util';
import formatCompleteNumber, { canFormatCompleteNumber } from './AsYouTypeFormatter.complete';
import parseDigits from './helpers/parseDigits';
export { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.util';
import formatCompleteNumber, { canFormatCompleteNumber } from './AsYouTypeFormatter.complete';
import { FIRST_GROUP_PATTERN, applyInternationalSeparatorStyle } from './format_';
import { VALID_PUNCTUATION } from './constants'; // Used in phone number format template creation.
import { FIRST_GROUP_PATTERN } from './helpers/formatNationalNumberUsingFormat';
import { VALID_PUNCTUATION } from './constants';
import applyInternationalSeparatorStyle from './helpers/applyInternationalSeparatorStyle'; // Used in phone number format template creation.
// Could be any digit, I guess.

@@ -17,0 +18,0 @@

@@ -15,5 +15,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

import parseDigits from './parseDigits';
import { extractNationalNumber, extractNationalNumberFromPossiblyIncompleteNumber, extractCountryCallingCode as _extractCountryCallingCode, extractCountryCallingCodeFromInternationalNumberWithoutPlusSign } from './parse_';
import { stripIDDPrefix } from './IDD';
import _extractCountryCallingCode from './helpers/extractCountryCallingCode';
import extractCountryCallingCodeFromInternationalNumberWithoutPlusSign from './helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign';
import extractNationalNumberFromPossiblyIncompleteNumber from './helpers/extractNationalNumberFromPossiblyIncompleteNumber';
import stripIddPrefix from './helpers/stripIddPrefix';
import parseDigits from './helpers/parseDigits';
import { VALID_DIGITS, VALID_PUNCTUATION, PLUS_CHARS } from './constants';

@@ -105,3 +107,3 @@ var VALID_FORMATTED_PHONE_NUMBER_PART = '[' + VALID_PUNCTUATION + VALID_DIGITS + ']+';

if (hasReceivedThreeLeadingDigits) {
this.extractIDDPrefix(state);
this.extractIddPrefix(state);
}

@@ -325,3 +327,3 @@

if (this.extractIDDPrefix(state)) {
if (this.extractIddPrefix(state)) {
this.extractCallingCodeAndNationalSignificantNumber(state);

@@ -344,4 +346,4 @@ return true;

}, {
key: "extractIDDPrefix",
value: function extractIDDPrefix(state) {
key: "extractIddPrefix",
value: function extractIddPrefix(state) {
// An IDD prefix can't be present in a number written with a `+`.

@@ -362,3 +364,3 @@ // Also, don't re-extract an IDD prefix if has already been extracted.

var numberWithoutIDD = stripIDDPrefix(digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata);
var numberWithoutIDD = stripIddPrefix(digits, this.defaultCountry, this.defaultCallingCode, this.metadata.metadata);

@@ -365,0 +367,0 @@ if (numberWithoutIDD !== undefined && numberWithoutIDD !== digits) {

import isValidNumber from '../validate_';
import parseDigits from '../parseDigits';
import parseDigits from '../helpers/parseDigits';
import { startsWith, endsWith } from './util';

@@ -4,0 +4,0 @@ /**

@@ -12,8 +12,25 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

import { PLUS_CHARS, VALID_PUNCTUATION, VALID_DIGITS, WHITESPACE } from './constants';
import { EXTN_PATTERNS_FOR_PARSING } from './extension';
import parse from './parse_';
import { VALID_PHONE_NUMBER_WITH_EXTENSION } from './isViablePhoneNumber';
import { VALID_PHONE_NUMBER_WITH_EXTENSION } from './helpers/isViablePhoneNumber';
import createExtensionPattern from './helpers/extension/createExtensionPattern';
import parsePreCandidate from './findNumbers/parsePreCandidate';
import isValidPreCandidate from './findNumbers/isValidPreCandidate';
import isValidCandidate from './findNumbers/isValidCandidate';
/**
* Regexp of all possible ways to write extensions, for use when parsing. This
* will be run as a case-insensitive regexp match. Wide character versions are
* also provided after each ASCII version. There are three regular expressions
* here. The first covers RFC 3966 format, where the extension is added using
* ';ext='. The second more generic one starts with optional white space and
* ends with an optional full stop (.), followed by zero or more spaces/tabs
* /commas and then the numbers themselves. The other one covers the special
* case of American numbers where the extension is written with a hash at the
* end, such as '- 503#'. Note that the only capturing groups should be around
* the digits that you want to capture as part of the extension, or else parsing
* will fail! We allow two options for representing the accented o - the
* character itself, and one in the unicode decomposed form with the combining
* acute accent.
*/
export var EXTN_PATTERNS_FOR_PARSING = createExtensionPattern('parsing');
var WHITESPACE_IN_THE_BEGINNING_PATTERN = new RegExp('^[' + WHITESPACE + ']+');

@@ -20,0 +37,0 @@ var PUNCTUATION_IN_THE_END_PATTERN = new RegExp('[' + VALID_PUNCTUATION + ']+$'); // // Regular expression for getting opening brackets for a valid number

@@ -9,7 +9,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
import { VALID_PUNCTUATION } from './constants';
import { matchesEntirely } from './util';
import matchesEntirely from './helpers/matchesEntirely';
import formatNationalNumberUsingFormat from './helpers/formatNationalNumberUsingFormat';
import Metadata, { getCountryCallingCode } from './metadata';
import { getIDDPrefix } from './IDD';
import { formatRFC3966 } from './RFC3966';
import getIddPrefix from './helpers/getIddPrefix';
import { formatRFC3966 } from './helpers/RFC3966';
var DEFAULT_OPTIONS = {

@@ -107,33 +107,2 @@ formatExtension: function formatExtension(formattedNumber, extension, metadata) {

}
} // This was originally set to $1 but there are some countries for which the
// first group is not used in the national pattern (e.g. Argentina) so the $1
// group does not match correctly. Therefore, we use `\d`, so that the first
// group actually used in the pattern will be matched.
export var FIRST_GROUP_PATTERN = /(\$\d)/;
export function formatNationalNumberUsingFormat(number, format, _ref) {
var useInternationalFormat = _ref.useInternationalFormat,
withNationalPrefix = _ref.withNationalPrefix,
carrierCode = _ref.carrierCode,
metadata = _ref.metadata;
var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
// because that one is only used when formatting phone numbers
// for dialing from a mobile phone, and this is not a dialing library.
// carrierCode && format.domesticCarrierCodeFormattingRule()
// // First, replace the $CC in the formatting rule with the desired carrier code.
// // Then, replace the $FG in the formatting rule with the first group
// // and the carrier code combined in the appropriate way.
// ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
// : (
// withNationalPrefix && format.nationalPrefixFormattingRule()
// ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
// : format.format()
// )
withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
if (useInternationalFormat) {
return applyInternationalSeparatorStyle(formattedNumber);
}
return formattedNumber;
}

@@ -158,14 +127,14 @@

for (var _iterator = availableFormats, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref2;
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref2 = _iterator[_i++];
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref2 = _i.value;
_ref = _i.value;
}
var format = _ref2;
var format = _ref;

@@ -187,36 +156,2 @@ // Validate leading digits

}
} // Removes brackets and replaces dashes with spaces.
//
// E.g. "(999) 111-22-33" -> "999 111 22 33"
//
// For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
// Meanwhile, there's no single opinion about using punctuation in international phone numbers.
//
// For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
// And here's a quote from WikiPedia's "North American Numbering Plan" page:
// https://en.wikipedia.org/wiki/North_American_Numbering_Plan
//
// "The country calling code for all countries participating in the NANP is 1.
// In international format, an NANP number should be listed as +1 301 555 01 00,
// where 301 is an area code (Maryland)."
//
// I personally prefer the international format without any punctuation.
// For example, brackets are remnants of the old age, meaning that the
// phone number part in brackets (so called "area code") can be omitted
// if dialing within the same "area".
// And hyphens were clearly introduced for splitting local numbers into memorizable groups.
// For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
// Imagine a man taking a bus from home to work and seeing an ad with a phone number.
// He has a couple of seconds to memorize that number until it passes by.
// If it were spaces instead of hyphens the man wouldn't necessarily get it,
// but with hyphens instead of spaces the grouping is more explicit.
// I personally think that hyphens introduce visual clutter,
// so I prefer replacing them with spaces in international numbers.
// In the modern age all output is done on displays where spaces are clearly distinguishable
// so hyphens can be safely replaced with spaces without losing any legibility.
//
export function applyInternationalSeparatorStyle(local) {
return local.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
}

@@ -251,8 +186,8 @@

var IDDPrefix = getIDDPrefix(fromCountry, undefined, metadata.metadata);
var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);
if (IDDPrefix) {
return "".concat(IDDPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
if (iddPrefix) {
return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
}
}
//# sourceMappingURL=format_.js.map
import metadata from '../metadata.min.json';
import { applyInternationalSeparatorStyle } from './format_';
import _formatNumber from './format';

@@ -148,6 +147,2 @@

});
it('should change Google\'s international format style', function () {
applyInternationalSeparatorStyle('(xxx) xxx-xx-xx').should.equal('xxx xxx xx xx');
applyInternationalSeparatorStyle('(xxx)xxx').should.equal('xxx xxx');
});
it('should format phone number extensions', function () {

@@ -154,0 +149,0 @@ // National

@@ -8,4 +8,4 @@ // This function is copy-pasted from

import format from './format_';
import getNumberType from './getNumberType_';
import checkNumberLength from './checkNumberLength';
import getNumberType from './helpers/getNumberType';
import checkNumberLength from './helpers/checkNumberLength';
import getCountryCallingCode from './getCountryCallingCode';

@@ -12,0 +12,0 @@ var REGION_CODE_FOR_NON_GEO_ENTITY = '001';

@@ -11,4 +11,4 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

import isViablePhoneNumber from './isViablePhoneNumber';
import _getNumberType from './getNumberType_';
import isViablePhoneNumber from './helpers/isViablePhoneNumber';
import _getNumberType from './helpers/getNumberType';
import parse from './parse_'; // Finds out national phone number type (fixed line, mobile, etc)

@@ -15,0 +15,0 @@

import Metadata from './metadata';
import checkNumberLength from './checkNumberLength';
import checkNumberLength from './helpers/checkNumberLength';
export default function isPossiblePhoneNumber(input, options, metadata) {

@@ -4,0 +4,0 @@ /* istanbul ignore if */

@@ -1,2 +0,2 @@

import isViablePhoneNumber from './isViablePhoneNumber';
import isViablePhoneNumber from './helpers/isViablePhoneNumber';
import parseNumber from './parse_';

@@ -3,0 +3,0 @@ import _isValidNumberForRegion from './isValidNumberForRegion_';

@@ -5,16 +5,18 @@ // This is a port of Google Android `libphonenumber`'s

// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
import { VALID_DIGITS, PLUS_CHARS, MIN_LENGTH_FOR_NSN, MAX_LENGTH_FOR_NSN, MAX_LENGTH_COUNTRY_CODE } from './constants';
import { matchesEntirely } from './util';
import { VALID_DIGITS, PLUS_CHARS, MIN_LENGTH_FOR_NSN, MAX_LENGTH_FOR_NSN } from './constants';
import ParseError from './ParseError';
import Metadata from './metadata';
import isViablePhoneNumber from './isViablePhoneNumber';
import { extractExtension } from './extension';
import isViablePhoneNumber from './helpers/isViablePhoneNumber';
import extractExtension from './helpers/extension/extractExtension';
import parseIncompletePhoneNumber from './parseIncompletePhoneNumber';
import getCountryCallingCode from './getCountryCallingCode';
import getNumberType from './getNumberType_';
import checkNumberLength from './checkNumberLength';
import { isPossibleNumber } from './isPossibleNumber_';
import { stripIDDPrefix } from './IDD';
import { parseRFC3966 } from './RFC3966';
import PhoneNumber from './PhoneNumber'; // We don't allow input strings for parsing to be longer than 250 chars.
import { parseRFC3966 } from './helpers/RFC3966';
import PhoneNumber from './PhoneNumber';
import matchesEntirely from './helpers/matchesEntirely';
import extractCountryCallingCode from './helpers/extractCountryCallingCode';
import extractCountryCallingCodeFromInternationalNumberWithoutPlusSign from './helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign';
import extractNationalNumber from './helpers/extractNationalNumber';
import stripIddPrefix from './helpers/stripIddPrefix';
import getCountryByCallingCode from './helpers/getCountryByCallingCode'; // We don't allow input strings for parsing to be longer than 250 chars.
// This prevents malicious input from consuming CPU.

@@ -204,194 +206,2 @@

/**
* Strips any national prefix (such as 0, 1) present in a
* (possibly incomplete) number provided.
* "Carrier codes" are only used in Colombia and Brazil,
* and only when dialing within those countries from a mobile phone to a fixed line number.
* Sometimes it won't actually strip national prefix
* and will instead prepend some digits to the `number`:
* for example, when number `2345678` is passed with `VI` country selected,
* it will return `{ number: "3402345678" }`, because `340` area code is prepended.
* @param {string} number — National number digits.
* @param {object} metadata — Metadata with country selected.
* @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`.
*/
export function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
// See METADATA.md for the description of
// `national_prefix_for_parsing` and `national_prefix_transform_rule`.
// Attempt to parse the first digits as a national prefix.
var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
var prefixMatch = prefixPattern.exec(number);
if (prefixMatch) {
var nationalNumber;
var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
// If a `national_prefix_for_parsing` has any "capturing groups"
// then it means that the national (significant) number is equal to
// those "capturing groups" transformed via `national_prefix_transform_rule`,
// and nothing could be said about the actual national prefix:
// what is it and was it even there.
// If a `national_prefix_for_parsing` doesn't have any "capturing groups",
// then everything it matches is a national prefix.
// To determine whether `national_prefix_for_parsing` matched any
// "capturing groups", the value of the result of calling `.exec()`
// is looked at, and if it has non-undefined values where there're
// "capturing groups" in the regular expression, then it means
// that "capturing groups" have been matched.
// It's not possible to tell whether there'll be any "capturing gropus"
// before the matching process, because a `national_prefix_for_parsing`
// could exhibit both behaviors.
var capturedGroupsCount = prefixMatch.length - 1;
var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
// then carrier code is the second one.
if (capturedGroupsCount > 1) {
carrierCode = prefixMatch[1];
}
} // If there're no "capturing groups",
// or if there're "capturing groups" but no
// `national_prefix_transform_rule`,
// then just strip the national prefix from the number,
// and possibly a carrier code.
// Seems like there could be more.
else {
// `prefixBeforeNationalNumber` is the whole substring matched by
// the `national_prefix_for_parsing` regular expression.
// There seem to be no guarantees that it's just a national prefix.
// For example, if there's a carrier code, it's gonna be a
// part of `prefixBeforeNationalNumber` too.
var prefixBeforeNationalNumber = prefixMatch[0];
nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
// then carrier code is the first one.
if (hasCapturedGroups) {
carrierCode = prefixMatch[1];
}
} // Tries to guess whether a national prefix was present in the input.
// This is not something copy-pasted from Google's library:
// they don't seem to have an equivalent for that.
// So this isn't an "officially approved" way of doing something like that.
// But since there seems no other existing method, this library uses it.
var nationalPrefix;
if (hasCapturedGroups) {
var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
// `prefixMatch[0]` is `01115`, and `$1` is `11`,
// and the rest of the phone number is `23456789`.
// The national number is transformed via `9$1` to `91123456789`.
// National prefix `0` is detected being present at the start.
// if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
nationalPrefix = metadata.numberingPlan.nationalPrefix();
}
} else {
nationalPrefix = prefixMatch[0];
}
return {
nationalNumber: nationalNumber,
nationalPrefix: nationalPrefix,
carrierCode: carrierCode
};
}
}
return {
nationalNumber: number
};
} // In some countries, the same digit could be a national prefix
// or a leading digit of a valid phone number.
// For example, in Russia, national prefix is `8`,
// and also `800 555 35 35` is a valid number
// in which `8` is not a national prefix, but the first digit
// of a national (significant) number.
// Same's with Belarus:
// `82004910060` is a valid national (significant) number,
// but `2004910060` is not.
// To support such cases (to prevent the code from always stripping
// national prefix), a condition is imposed: a national prefix
// is not extracted when the original number is "viable" and the
// resultant number is not, a "viable" national number being the one
// that matches `national_number_pattern`.
function shouldExtractNationalPrefix(number, nationalSignificantNumber, metadata) {
// The equivalent in Google's code is:
// https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
if (matchesEntirely(number, metadata.nationalNumberPattern()) && !matchesEntirely(nationalSignificantNumber, metadata.nationalNumberPattern())) {
return false;
} // Just "possible" number check would be more relaxed, so it's not used.
// if (isPossibleNumber(number, metadata) &&
// !isPossibleNumber(numberWithNationalPrefixExtracted, metadata)) {
// return false
// }
return true;
}
export function findCountryCode(callingCode, nationalPhoneNumber, metadata) {
/* istanbul ignore if */
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
if (metadata.isNonGeographicCallingCode(callingCode)) {
return '001';
}
} // Is always non-empty, because `callingCode` is always valid
var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
if (!possibleCountries) {
return;
} // If there's just one country corresponding to the country code,
// then just return it, without further phone number digits validation.
if (possibleCountries.length === 1) {
return possibleCountries[0];
}
return _findCountryCode(possibleCountries, nationalPhoneNumber, metadata.metadata);
} // Changes `metadata` `country`.
function _findCountryCode(possibleCountries, nationalPhoneNumber, metadata) {
metadata = new Metadata(metadata);
for (var _iterator = possibleCountries, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var country = _ref;
metadata.country(country); // Leading digits check would be the simplest one
if (metadata.leadingDigits()) {
if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
return country;
}
} // Else perform full validation with all of those
// fixed-line/mobile/etc regular expressions.
else if (getNumberType({
phone: nationalPhoneNumber,
country: country
}, undefined, metadata.metadata)) {
return country;
}
}
}
/**
* @param {string} text - Input.

@@ -401,3 +211,2 @@ * @return {object} `{ ?number, ?ext }`.

function parseInput(text, v2) {

@@ -504,3 +313,3 @@ // Parse RFC 3966 phone number URI.

var exactCountry = findCountryCode(countryCallingCode, nationalNumber, metadata);
var exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata);

@@ -526,210 +335,2 @@ if (exactCountry) {

}
/**
* Strips national prefix and carrier code from a complete phone number.
* The difference from the non-"FromCompleteNumber" function is that
* it won't extract national prefix if the resultant number is too short
* to be a complete number for the selected phone numbering plan.
* @param {string} number — Complete phone number digits.
* @param {Metadata} metadata — Metadata with a phone numbering plan selected.
* @return {object} `{ nationalNumber: string, carrierCode: string? }`.
*/
export function extractNationalNumber(number, metadata) {
// Parsing national prefixes and carrier codes
// is only required for local phone numbers
// but some people don't understand that
// and sometimes write international phone numbers
// with national prefixes (or maybe even carrier codes).
// http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
// Google's original library forgives such mistakes
// and so does this library, because it has been requested:
// https://github.com/catamphetamine/libphonenumber-js/issues/127
var _extractNationalNumbe2 = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
nationalNumber = _extractNationalNumbe2.nationalNumber,
carrierCode = _extractNationalNumbe2.carrierCode;
if (!shouldExtractNationalPrefix(number, nationalNumber, metadata)) {
// Don't strip the national prefix.
return {
nationalNumber: number
};
} // If a national prefix has been extracted, check to see
// if the resultant number isn't too short.
// Same code in Google's `libphonenumber`:
// https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3291-L3302
// For some reason, they do this check right after the `national_number_pattern` check
// this library does in `shouldExtractNationalPrefix()` function.
// Why is there a second "resultant" number validity check?
// They don't provide an explanation.
// This library just copies the behavior.
if (number.length !== nationalNumber.length + (carrierCode ? carrierCode.length : 0)) {
// If not using legacy generated metadata (before version `1.0.18`)
// then it has "possible lengths", so use those to validate the number length.
if (metadata.possibleLengths()) {
// "We require that the NSN remaining after stripping the national prefix and
// carrier code be long enough to be a possible length for the region.
// Otherwise, we don't do the stripping, since the original number could be
// a valid short number."
// https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
switch (checkNumberLength(nationalNumber, metadata)) {
case 'TOO_SHORT':
case 'INVALID_LENGTH':
// case 'IS_POSSIBLE_LOCAL_ONLY':
// Don't strip the national prefix.
return {
nationalNumber: number
};
}
}
}
return {
nationalNumber: nationalNumber,
carrierCode: carrierCode
};
}
/**
* Converts a phone number digits (possibly with a `+`)
* into a calling code and the rest phone number digits.
* The "rest phone number digits" could include
* a national prefix, carrier code, and national
* (significant) number.
* @param {string} number — Phone number digits (possibly with a `+`).
* @param {string} [country] — Default country.
* @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
* @param {object} metadata
* @return {object} `{ countryCallingCode: string?, number: string }`
* @example
* // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
* extractCountryCallingCode('2133734253', 'US', null, metadata)
* extractCountryCallingCode('2133734253', null, '1', metadata)
* extractCountryCallingCode('+12133734253', null, null, metadata)
* extractCountryCallingCode('+12133734253', 'RU', null, metadata)
*/
export function extractCountryCallingCode(number, country, callingCode, metadata) {
if (!number) {
return {};
} // If this is not an international phone number,
// then either extract an "IDD" prefix, or extract a
// country calling code from a number by autocorrecting it
// by prepending a leading `+` in cases when it starts
// with the country calling code.
// https://wikitravel.org/en/International_dialling_prefix
// https://github.com/catamphetamine/libphonenumber-js/issues/376
if (number[0] !== '+') {
// Convert an "out-of-country" dialing phone number
// to a proper international phone number.
var numberWithoutIDD = stripIDDPrefix(number, country, callingCode, metadata); // If an IDD prefix was stripped then
// convert the number to international one
// for subsequent parsing.
if (numberWithoutIDD && numberWithoutIDD !== number) {
number = '+' + numberWithoutIDD;
} else {
// Check to see if the number starts with the country calling code
// for the default country. If so, we remove the country calling code,
// and do some checks on the validity of the number before and after.
// https://github.com/catamphetamine/libphonenumber-js/issues/376
if (country || callingCode) {
var _extractCountryCallin2 = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
countryCallingCode = _extractCountryCallin2.countryCallingCode,
shorterNumber = _extractCountryCallin2.number;
if (countryCallingCode) {
return {
countryCallingCode: countryCallingCode,
number: shorterNumber
};
}
}
return {
number: number
};
}
} // Fast abortion: country codes do not begin with a '0'
if (number[1] === '0') {
return {};
}
metadata = new Metadata(metadata); // The thing with country phone codes
// is that they are orthogonal to each other
// i.e. there's no such country phone code A
// for which country phone code B exists
// where B starts with A.
// Therefore, while scanning digits,
// if a valid country code is found,
// that means that it is the country code.
//
var i = 2;
while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
var _countryCallingCode = number.slice(1, i);
if (metadata.hasCallingCode(_countryCallingCode)) {
metadata.selectNumberingPlan(_countryCallingCode);
return {
countryCallingCode: _countryCallingCode,
number: number.slice(i)
};
}
i++;
}
return {};
}
/**
* Sometimes some people incorrectly input international phone numbers
* without the leading `+`. This function corrects such input.
* @param {string} number — Phone number digits.
* @param {string?} country
* @param {string?} callingCode
* @param {object} metadata
* @return {object} `{ countryCallingCode: string?, number: string }`.
*/
export function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
var countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode;
if (number.indexOf(countryCallingCode) === 0) {
metadata = new Metadata(metadata);
metadata.selectNumberingPlan(country, callingCode);
var possibleShorterNumber = number.slice(countryCallingCode.length);
var _extractNationalNumbe3 = extractNationalNumber(possibleShorterNumber, metadata),
possibleShorterNationalNumber = _extractNationalNumbe3.nationalNumber;
var _extractNationalNumbe4 = extractNationalNumber(number, metadata),
nationalNumber = _extractNationalNumbe4.nationalNumber; // If the number was not valid before but is valid now,
// or if it was too long before, we consider the number
// with the country calling code stripped to be a better result
// and keep that instead.
// For example, in Germany (+49), `49` is a valid area code,
// so if a number starts with `49`, it could be both a valid
// national German number or an international number without
// a leading `+`.
if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || checkNumberLength(nationalNumber, metadata) === 'TOO_LONG') {
return {
countryCallingCode: countryCallingCode,
number: possibleShorterNumber
};
}
}
return {
number: number
};
}
//# sourceMappingURL=parse_.js.map
import metadata from '../metadata.min.json';
import _parseNumber from './parse';
import Metadata from './Metadata';
import { extractCountryCallingCode, extractNationalNumberFromPossiblyIncompleteNumber } from './parse_';
import Metadata from './metadata';

@@ -480,13 +479,2 @@ function parseNumber() {

});
it('should extract country calling code from a number', function () {
extractCountryCallingCode('+78005553535', null, null, metadata).should.deep.equal({
countryCallingCode: '7',
number: '8005553535'
});
extractCountryCallingCode('+7800', null, null, metadata).should.deep.equal({
countryCallingCode: '7',
number: '800'
});
extractCountryCallingCode('', null, null, metadata).should.deep.equal({});
});
it('should correctly parse numbers starting with the same digit as the national prefix', function () {

@@ -575,13 +563,2 @@ // https://github.com/catamphetamine/libphonenumber-js/issues/373

});
describe('extractNationalNumberFromPossiblyIncompleteNumber', function () {
it('should parse a carrier code when there is no national prefix transform rule', function () {
var meta = new Metadata(metadata);
meta.country('AU');
extractNationalNumberFromPossiblyIncompleteNumber('18311800123', meta).should.deep.equal({
nationalPrefix: undefined,
carrierCode: '1831',
nationalNumber: '1800123'
});
});
});
//# sourceMappingURL=parse.test.js.map

@@ -1,2 +0,2 @@

import { parseDigit } from './parseDigits';
import { parseDigit } from './helpers/parseDigits';
/**

@@ -45,6 +45,9 @@ * Parses phone number characters from a string.

/**
* `input-format` `parse()` function.
* https://gitlab.com/catamphetamine/input-format
* Parses next character while parsing phone number digits (including a `+`)
* from text: discards everything except `+` and digits, and `+` is only allowed
* at the start of a phone number.
* For example, is used in `react-phone-number-input` where it uses
* [`input-format`](https://gitlab.com/catamphetamine/input-format).
* @param {string} character - Yet another character from raw input string.
* @param {string} value - The value parsed so far.
* @param {string?} prevParsedCharacters - Previous parsed characters.
* @param {object} meta - Optional custom use-case-specific metadata.

@@ -54,3 +57,3 @@ * @return {string?} The parsed character.

export function parsePhoneNumberCharacter(character, value) {
export function parsePhoneNumberCharacter(character, prevParsedCharacters) {
// Only allow a leading `+`.

@@ -60,3 +63,3 @@ if (character === '+') {

// then discard it.
if (value) {
if (prevParsedCharacters) {
return;

@@ -63,0 +66,0 @@ }

@@ -15,3 +15,3 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

import isValidNumberForRegion from './isValidNumberForRegion_';
import getNumberType from './getNumberType_';
import getNumberType from './helpers/getNumberType';
import formatNumber from './format_';

@@ -18,0 +18,0 @@ var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;

@@ -18,3 +18,3 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

import { MAX_LENGTH_FOR_NSN, MAX_LENGTH_COUNTRY_CODE, VALID_PUNCTUATION } from './constants';
import { EXTN_PATTERNS_FOR_MATCHING } from './extension';
import createExtensionPattern from './helpers/extension/createExtensionPattern';
import RegExpCache from './findNumbers/RegExpCache';

@@ -29,2 +29,3 @@ import { limit, trimAfterFirstMatch } from './findNumbers/util';

import parseNumber from './parse_';
var EXTN_PATTERNS_FOR_MATCHING = createExtensionPattern('matching');
/**

@@ -31,0 +32,0 @@ * Patterns used to extract phone numbers from a larger phone-number-like pattern. These are

import Metadata from './metadata';
import { matchesEntirely } from './util';
import getNumberType from './getNumberType_';
import matchesEntirely from './helpers/matchesEntirely';
import getNumberType from './helpers/getNumberType';
/**

@@ -5,0 +5,0 @@ * Checks if a given phone number is valid.

@@ -1,239 +0,58 @@

// Deprecated.
// Use `libphonenumber-js/min` or `libphonenumber-js/max` or `libphonenumber-js/core` instead.
// Importing from `.json.js` a workaround for a bug in web browsers' "native"
// ES6 importing system which is uncapable of importing "*.json" files.
// https://github.com/catamphetamine/libphonenumber-js/issues/239
import metadata from './metadata.min.json.js'
import parsePhoneNumberWithErrorCustom from './es6/parsePhoneNumber'
import parsePhoneNumberFromStringCustom from './es6/parsePhoneNumberFromString'
import parseNumberCustom from './es6/parse'
import formatNumberCustom from './es6/format'
import getNumberTypeCustom from './es6/getNumberType'
import getExampleNumberCustom from './es6/getExampleNumber'
import isPossibleNumberCustom from './es6/isPossibleNumber'
import isValidNumberCustom from './es6/validate'
import isValidNumberForRegionCustom from './es6/isValidNumberForRegion'
// Deprecated
import findPhoneNumbersCustom, { searchPhoneNumbers as searchPhoneNumbersCustom } from './es6/findPhoneNumbers'
import { PhoneNumberSearch as PhoneNumberSearchCustom } from './es6/findPhoneNumbers_'
import findNumbersCustom from './es6/findNumbers'
import searchNumbersCustom from './es6/searchNumbers'
import findPhoneNumbersInTextCustom from './es6/findPhoneNumbersInText'
import searchPhoneNumbersInTextCustom from './es6/searchPhoneNumbersInText'
import PhoneNumberMatcherCustom from './es6/PhoneNumberMatcher'
import AsYouTypeCustom from './es6/AsYouType'
import getCountryCallingCodeCustom from './es6/getCountryCallingCode'
import getCountriesCustom from './es6/getCountries'
export { default as Metadata } from './es6/metadata'
import { getExtPrefix as getExtPrefixCustom, isSupportedCountry as isSupportedCountryCustom } from './es6/metadata'
import { parseRFC3966 as parseRFC3966Custom, formatRFC3966 as formatRFC3966Custom } from './es6/RFC3966'
import formatIncompletePhoneNumberCustom from './es6/formatIncompletePhoneNumber'
export { default as parseIncompletePhoneNumber, parsePhoneNumberCharacter } from './es6/parseIncompletePhoneNumber'
// Deprecated: remove DIGITS export in 2.0.0.
// (it was used in `react-phone-number-input`)
export { DIGITS, default as parseDigits } from './es6/parseDigits'
export { default as ParseError } from './es6/ParseError'
export function parsePhoneNumberWithError()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return parsePhoneNumberWithErrorCustom.apply(this, parameters)
}
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
export var parsePhoneNumber = parsePhoneNumberWithError
export { parsePhoneNumberWithError, parsePhoneNumberWithError as parsePhoneNumber } from './min/exports/parsePhoneNumberWithError'
// `parsePhoneNumberFromString()` named export is now considered legacy:
// it has been promoted to a default export due to being too verbose.
export function parsePhoneNumberFromString()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return parsePhoneNumberFromStringCustom.apply(this, parameters)
}
export { parsePhoneNumberFromString, parsePhoneNumberFromString as default } from './min/exports/parsePhoneNumberFromString'
export default parsePhoneNumberFromString
export function parseNumber()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return parseNumberCustom.apply(this, parameters)
}
// Deprecated: remove `parse()` export in 2.0.0.
// (renamed to `parseNumber()`)
export function parse()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return parseNumberCustom.apply(this, parameters)
}
export function formatNumber()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return formatNumberCustom.apply(this, parameters)
}
// Deprecated: remove `format()` export in 2.0.0.
// (renamed to `formatNumber()`)
export function format()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return formatNumberCustom.apply(this, parameters)
}
export function getNumberType()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return getNumberTypeCustom.apply(this, parameters)
}
export function getExampleNumber()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return getExampleNumberCustom.apply(this, parameters)
}
export function isPossibleNumber()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return isPossibleNumberCustom.apply(this, parameters)
}
export function isValidNumber()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return isValidNumberCustom.apply(this, parameters)
}
export function isValidNumberForRegion()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return isValidNumberForRegionCustom.apply(this, parameters)
}
// Deprecated.
export function findPhoneNumbers()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return findPhoneNumbersCustom.apply(this, parameters)
}
export { findNumbers } from './min/exports/findNumbers'
// Deprecated.
export function searchPhoneNumbers()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return searchPhoneNumbersCustom.apply(this, parameters)
}
export { searchNumbers } from './min/exports/searchNumbers'
// Deprecated.
export function PhoneNumberSearch(text, options)
{
PhoneNumberSearchCustom.call(this, text, options, metadata)
}
export { findPhoneNumbersInText } from './min/exports/findPhoneNumbersInText'
export { searchPhoneNumbersInText } from './min/exports/searchPhoneNumbersInText'
export { PhoneNumberMatcher } from './min/exports/PhoneNumberMatcher'
// Deprecated.
PhoneNumberSearch.prototype = Object.create(PhoneNumberSearchCustom.prototype, {})
PhoneNumberSearch.prototype.constructor = PhoneNumberSearch
export { AsYouType } from './min/exports/AsYouType'
export { DIGIT_PLACEHOLDER } from './es6/AsYouTypeFormatter'
export function findNumbers()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return findNumbersCustom.apply(this, parameters)
}
export { isSupportedCountry } from './min/exports/isSupportedCountry'
export { getCountries } from './min/exports/getCountries'
// `getPhoneCode` name is deprecated, use `getCountryCallingCode` instead.
export { getCountryCallingCode, getCountryCallingCode as getPhoneCode } from './min/exports/getCountryCallingCode'
export { getExtPrefix } from './min/exports/getExtPrefix'
export function searchNumbers()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return searchNumbersCustom.apply(this, parameters)
}
// export { Metadata } from './min/exports/Metadata'
export { getExampleNumber } from './min/exports/getExampleNumber'
export function findPhoneNumbersInText()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return findPhoneNumbersInTextCustom.apply(this, parameters)
}
export { formatIncompletePhoneNumber } from './min/exports/formatIncompletePhoneNumber'
export function searchPhoneNumbersInText()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return searchPhoneNumbersInTextCustom.apply(this, parameters)
}
export {
ParseError,
parseIncompletePhoneNumber,
parsePhoneNumberCharacter,
parseDigits,
parseRFC3966,
formatRFC3966
} from './core/index'
export function PhoneNumberMatcher(text, options)
{
PhoneNumberMatcherCustom.call(this, text, options, metadata)
}
// Deprecated (old) exports.
export { parse as parseNumber, parse } from './index.es6.exports/parse'
export { format as formatNumber, format } from './index.es6.exports/format'
export { getNumberType } from './index.es6.exports/getNumberType'
export { isPossibleNumber } from './index.es6.exports/isPossibleNumber'
export { isValidNumber } from './index.es6.exports/isValidNumber'
export { isValidNumberForRegion } from './index.es6.exports/isValidNumberForRegion'
export { findPhoneNumbers } from './index.es6.exports/findPhoneNumbers'
export { searchPhoneNumbers } from './index.es6.exports/searchPhoneNumbers'
export { PhoneNumberSearch } from './index.es6.exports/PhoneNumberSearch'
PhoneNumberMatcher.prototype = Object.create(PhoneNumberMatcherCustom.prototype, {})
PhoneNumberMatcher.prototype.constructor = PhoneNumberMatcher
// Deprecated: exporting `/core` metadata from non-`/core`.
export { default as Metadata } from './es6/metadata'
export function AsYouType(country)
{
AsYouTypeCustom.call(this, country, metadata)
}
// Deprecated DIGITS export.
// (it was used in `react-phone-number-input`)
export { DIGITS } from './es6/helpers/parseDigits'
AsYouType.prototype = Object.create(AsYouTypeCustom.prototype, {})
AsYouType.prototype.constructor = AsYouType
export function isSupportedCountry()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return isSupportedCountryCustom.apply(this, parameters)
}
export function getExtPrefix()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return getExtPrefixCustom.apply(this, parameters)
}
export function parseRFC3966()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return parseRFC3966Custom.apply(this, parameters)
}
export function formatRFC3966()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return formatRFC3966Custom.apply(this, parameters)
}
export function formatIncompletePhoneNumber()
{
var parameters = Array.prototype.slice.call(arguments)
parameters.push(metadata)
return formatIncompletePhoneNumberCustom.apply(this, parameters)
}
// Deprecated: remove this in 2.0.0 and make `custom.js` in ES6
// (the old `custom.js` becomes `custom.commonjs.js`).
// Deprecated "custom" exports.
export { default as parseCustom } from './es6/parse'

@@ -246,27 +65,3 @@ export { default as formatCustom } from './es6/format'

export { default as getNumberTypeCustom } from './es6/getNumberType'
export { default as getCountryCallingCodeCustom } from './es6/getCountryCallingCode'
export { default as AsYouTypeCustom } from './es6/AsYouType'
export { DIGIT_PLACEHOLDER } from './es6/AsYouTypeFormatter'
export function getCountries()
{
return getCountriesCustom(metadata)
}
export function getCountryCallingCode(country)
{
return getCountryCallingCodeCustom(country, metadata)
}
// `getPhoneCode` name is deprecated, use `getCountryCallingCode` instead.
export function getPhoneCode(country)
{
return getCountryCallingCode(country)
}
// `getPhoneCodeCustom` name is deprecated, use `getCountryCallingCodeCustom` instead.
export function getPhoneCodeCustom(country, metadata)
{
return getCountryCallingCodeCustom(country, metadata)
}
export { default as getCountryCallingCodeCustom, default as getPhoneCodeCustom } from './es6/getCountryCallingCode'
export { default as AsYouTypeCustom } from './es6/AsYouType'

@@ -1,116 +0,36 @@

// Importing from `.json.js` a workaround for a bug in web browsers' "native"
// ES6 importing system which is uncapable of importing "*.json" files.
// https://github.com/catamphetamine/libphonenumber-js/issues/239
import metadata from '../metadata.full.json.js'
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
export { parsePhoneNumberWithError, parsePhoneNumberWithError as parsePhoneNumber } from './exports/parsePhoneNumberWithError'
// `parsePhoneNumberFromString()` named export is now considered legacy:
// it has been promoted to a default export due to being too verbose.
export { parsePhoneNumberFromString, parsePhoneNumberFromString as default } from './exports/parsePhoneNumberFromString'
import {
parsePhoneNumberWithError as _parsePhoneNumberWithError,
parsePhoneNumberFromString as _parsePhoneNumberFromString,
// Deprecated.
export { findNumbers } from './exports/findNumbers'
// Deprecated.
export { searchNumbers } from './exports/searchNumbers'
findNumbers as _findNumbers,
searchNumbers as _searchNumbers,
findPhoneNumbersInText as _findPhoneNumbersInText,
searchPhoneNumbersInText as _searchPhoneNumbersInText,
PhoneNumberMatcher as _PhoneNumberMatcher,
export { findPhoneNumbersInText } from './exports/findPhoneNumbersInText'
export { searchPhoneNumbersInText } from './exports/searchPhoneNumbersInText'
export { PhoneNumberMatcher } from './exports/PhoneNumberMatcher'
AsYouType as _AsYouType,
export { AsYouType } from './exports/AsYouType'
isSupportedCountry as _isSupportedCountry,
getCountries as _getCountries,
getCountryCallingCode as _getCountryCallingCode,
getExtPrefix as _getExtPrefix,
export { isSupportedCountry } from './exports/isSupportedCountry'
export { getCountries } from './exports/getCountries'
export { getCountryCallingCode } from './exports/getCountryCallingCode'
export { getExtPrefix } from './exports/getExtPrefix'
getExampleNumber as _getExampleNumber,
export { Metadata } from './exports/Metadata'
export { getExampleNumber } from './exports/getExampleNumber'
formatIncompletePhoneNumber as _formatIncompletePhoneNumber,
parseIncompletePhoneNumber,
parsePhoneNumberCharacter,
parseDigits,
export { formatIncompletePhoneNumber } from './exports/formatIncompletePhoneNumber'
parseRFC3966,
formatRFC3966
} from '../core/index'
export {
ParseError,
parseIncompletePhoneNumber,
parsePhoneNumberCharacter,
parseDigits,
parseRFC3966,
formatRFC3966
} from '../core/index'
function call(func, _arguments) {
var args = Array.prototype.slice.call(_arguments)
args.push(metadata)
return func.apply(this, args)
}
export function parsePhoneNumberWithError() {
return call(_parsePhoneNumberWithError, arguments)
}
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
export var parsePhoneNumber = parsePhoneNumberWithError
// `parsePhoneNumberFromString()` named export is now considered legacy:
// it has been promoted to a default export due to being too verbose.
export function parsePhoneNumberFromString() {
return call(_parsePhoneNumberFromString, arguments)
}
export default parsePhoneNumberFromString;
export function findNumbers() {
return call(_findNumbers, arguments)
}
export function searchNumbers() {
return call(_searchNumbers, arguments)
}
export function findPhoneNumbersInText() {
return call(_findPhoneNumbersInText, arguments)
}
export function searchPhoneNumbersInText() {
return call(_searchPhoneNumbersInText, arguments)
}
export function PhoneNumberMatcher(text, options) {
return _PhoneNumberMatcher.call(this, text, options, metadata)
}
PhoneNumberMatcher.prototype = Object.create(_PhoneNumberMatcher.prototype, {})
PhoneNumberMatcher.prototype.constructor = PhoneNumberMatcher
export function AsYouType(country) {
return _AsYouType.call(this, country, metadata)
}
AsYouType.prototype = Object.create(_AsYouType.prototype, {})
AsYouType.prototype.constructor = AsYouType
export function isSupportedCountry() {
return call(_isSupportedCountry, arguments)
}
export function getCountries() {
return call(_getCountries, arguments)
}
export function getCountryCallingCode() {
return call(_getCountryCallingCode, arguments)
}
export function getExtPrefix(country) {
return call(_getExtPrefix, arguments)
}
export function getExampleNumber() {
return call(_getExampleNumber, arguments)
}
export function formatIncompletePhoneNumber() {
return call(_formatIncompletePhoneNumber, arguments)
}
formatRFC3966,
DIGIT_PLACEHOLDER
} from '../core/index'
import {
Metadata,
PhoneNumber,

@@ -19,2 +20,3 @@ E164Number,

export {
Metadata,
PhoneNumber,

@@ -21,0 +23,0 @@ E164Number,

@@ -1,116 +0,36 @@

// Importing from `.json.js` a workaround for a bug in web browsers' "native"
// ES6 importing system which is uncapable of importing "*.json" files.
// https://github.com/catamphetamine/libphonenumber-js/issues/239
import metadata from '../metadata.min.json.js'
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
export { parsePhoneNumberWithError, parsePhoneNumberWithError as parsePhoneNumber } from './exports/parsePhoneNumberWithError'
// `parsePhoneNumberFromString()` named export is now considered legacy:
// it has been promoted to a default export due to being too verbose.
export { parsePhoneNumberFromString, parsePhoneNumberFromString as default } from './exports/parsePhoneNumberFromString'
import {
parsePhoneNumberWithError as _parsePhoneNumberWithError,
parsePhoneNumberFromString as _parsePhoneNumberFromString,
// Deprecated.
export { findNumbers } from './exports/findNumbers'
// Deprecated.
export { searchNumbers } from './exports/searchNumbers'
findNumbers as _findNumbers,
searchNumbers as _searchNumbers,
findPhoneNumbersInText as _findPhoneNumbersInText,
searchPhoneNumbersInText as _searchPhoneNumbersInText,
PhoneNumberMatcher as _PhoneNumberMatcher,
export { findPhoneNumbersInText } from './exports/findPhoneNumbersInText'
export { searchPhoneNumbersInText } from './exports/searchPhoneNumbersInText'
export { PhoneNumberMatcher } from './exports/PhoneNumberMatcher'
AsYouType as _AsYouType,
export { AsYouType } from './exports/AsYouType'
isSupportedCountry as _isSupportedCountry,
getCountries as _getCountries,
getCountryCallingCode as _getCountryCallingCode,
getExtPrefix as _getExtPrefix,
export { isSupportedCountry } from './exports/isSupportedCountry'
export { getCountries } from './exports/getCountries'
export { getCountryCallingCode } from './exports/getCountryCallingCode'
export { getExtPrefix } from './exports/getExtPrefix'
getExampleNumber as _getExampleNumber,
export { Metadata } from './exports/Metadata'
export { getExampleNumber } from './exports/getExampleNumber'
formatIncompletePhoneNumber as _formatIncompletePhoneNumber,
parseIncompletePhoneNumber,
parsePhoneNumberCharacter,
parseDigits,
export { formatIncompletePhoneNumber } from './exports/formatIncompletePhoneNumber'
parseRFC3966,
formatRFC3966
} from '../core/index'
export {
ParseError,
parseIncompletePhoneNumber,
parsePhoneNumberCharacter,
parseDigits,
parseRFC3966,
formatRFC3966
} from '../core/index'
function call(func, _arguments) {
var args = Array.prototype.slice.call(_arguments)
args.push(metadata)
return func.apply(this, args)
}
export function parsePhoneNumberWithError() {
return call(_parsePhoneNumberWithError, arguments)
}
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
export var parsePhoneNumber = parsePhoneNumberWithError
// `parsePhoneNumberFromString()` named export is now considered legacy:
// it has been promoted to a default export due to being too verbose.
export function parsePhoneNumberFromString() {
return call(_parsePhoneNumberFromString, arguments)
}
export default parsePhoneNumberFromString
export function findNumbers() {
return call(_findNumbers, arguments)
}
export function searchNumbers() {
return call(_searchNumbers, arguments)
}
export function findPhoneNumbersInText() {
return call(_findPhoneNumbersInText, arguments)
}
export function searchPhoneNumbersInText() {
return call(_searchPhoneNumbersInText, arguments)
}
export function PhoneNumberMatcher(text, options) {
return _PhoneNumberMatcher.call(this, text, options, metadata)
}
PhoneNumberMatcher.prototype = Object.create(_PhoneNumberMatcher.prototype, {})
PhoneNumberMatcher.prototype.constructor = PhoneNumberMatcher
export function AsYouType(country) {
return _AsYouType.call(this, country, metadata)
}
AsYouType.prototype = Object.create(_AsYouType.prototype, {})
AsYouType.prototype.constructor = AsYouType
export function isSupportedCountry() {
return call(_isSupportedCountry, arguments)
}
export function getCountries() {
return call(_getCountries, arguments)
}
export function getCountryCallingCode() {
return call(_getCountryCallingCode, arguments)
}
export function getExtPrefix(country) {
return call(_getExtPrefix, arguments)
}
export function getExampleNumber() {
return call(_getExampleNumber, arguments)
}
export function formatIncompletePhoneNumber() {
return call(_formatIncompletePhoneNumber, arguments)
}
formatRFC3966,
DIGIT_PLACEHOLDER
} from '../core/index'

@@ -1,116 +0,36 @@

// Importing from `.json.js` a workaround for a bug in web browsers' "native"
// ES6 importing system which is uncapable of importing "*.json" files.
// https://github.com/catamphetamine/libphonenumber-js/issues/239
import metadata from '../metadata.mobile.json.js'
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
export { parsePhoneNumberWithError, parsePhoneNumberWithError as parsePhoneNumber } from './exports/parsePhoneNumberWithError'
// `parsePhoneNumberFromString()` named export is now considered legacy:
// it has been promoted to a default export due to being too verbose.
export { parsePhoneNumberFromString, parsePhoneNumberFromString as default } from './exports/parsePhoneNumberFromString'
import {
parsePhoneNumberWithError as _parsePhoneNumberWithError,
parsePhoneNumberFromString as _parsePhoneNumberFromString,
// Deprecated.
export { findNumbers } from './exports/findNumbers'
// Deprecated.
export { searchNumbers } from './exports/searchNumbers'
findNumbers as _findNumbers,
searchNumbers as _searchNumbers,
findPhoneNumbersInText as _findPhoneNumbersInText,
searchPhoneNumbersInText as _searchPhoneNumbersInText,
PhoneNumberMatcher as _PhoneNumberMatcher,
export { findPhoneNumbersInText } from './exports/findPhoneNumbersInText'
export { searchPhoneNumbersInText } from './exports/searchPhoneNumbersInText'
export { PhoneNumberMatcher } from './exports/PhoneNumberMatcher'
AsYouType as _AsYouType,
export { AsYouType } from './exports/AsYouType'
isSupportedCountry as _isSupportedCountry,
getCountries as _getCountries,
getCountryCallingCode as _getCountryCallingCode,
getExtPrefix as _getExtPrefix,
export { isSupportedCountry } from './exports/isSupportedCountry'
export { getCountries } from './exports/getCountries'
export { getCountryCallingCode } from './exports/getCountryCallingCode'
export { getExtPrefix } from './exports/getExtPrefix'
getExampleNumber as _getExampleNumber,
export { Metadata } from './exports/Metadata'
export { getExampleNumber } from './exports/getExampleNumber'
formatIncompletePhoneNumber as _formatIncompletePhoneNumber,
parseIncompletePhoneNumber,
parsePhoneNumberCharacter,
parseDigits,
export { formatIncompletePhoneNumber } from './exports/formatIncompletePhoneNumber'
parseRFC3966,
formatRFC3966
} from '../core/index'
export {
ParseError,
parseIncompletePhoneNumber,
parsePhoneNumberCharacter,
parseDigits,
parseRFC3966,
formatRFC3966
} from '../core/index'
function call(func, _arguments) {
var args = Array.prototype.slice.call(_arguments)
args.push(metadata)
return func.apply(this, args)
}
export function parsePhoneNumberWithError() {
return call(_parsePhoneNumberWithError, arguments)
}
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
export var parsePhoneNumber = parsePhoneNumberWithError
// `parsePhoneNumberFromString()` named export is now considered legacy:
// it has been promoted to a default export due to being too verbose.
export function parsePhoneNumberFromString() {
return call(_parsePhoneNumberFromString, arguments)
}
export default parsePhoneNumberFromString
export function findNumbers() {
return call(_findNumbers, arguments)
}
export function searchNumbers() {
return call(_searchNumbers, arguments)
}
export function findPhoneNumbersInText() {
return call(_findPhoneNumbersInText, arguments)
}
export function searchPhoneNumbersInText() {
return call(_searchPhoneNumbersInText, arguments)
}
export function PhoneNumberMatcher(text, options) {
return _PhoneNumberMatcher.call(this, text, options, metadata)
}
PhoneNumberMatcher.prototype = Object.create(_PhoneNumberMatcher.prototype, {})
PhoneNumberMatcher.prototype.constructor = PhoneNumberMatcher
export function AsYouType(country) {
return _AsYouType.call(this, country, metadata)
}
AsYouType.prototype = Object.create(_AsYouType.prototype, {})
AsYouType.prototype.constructor = AsYouType
export function isSupportedCountry() {
return call(_isSupportedCountry, arguments)
}
export function getCountries() {
return call(_getCountries, arguments)
}
export function getCountryCallingCode() {
return call(_getCountryCallingCode, arguments)
}
export function getExtPrefix(country) {
return call(_getExtPrefix, arguments)
}
export function getExampleNumber() {
return call(_getExampleNumber, arguments)
}
export function formatIncompletePhoneNumber() {
return call(_formatIncompletePhoneNumber, arguments)
}
formatRFC3966,
DIGIT_PLACEHOLDER
} from '../core/index'
{
"name": "libphonenumber-js",
"version": "1.9.3",
"version": "1.9.4",
"description": "A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript",

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

@@ -6,3 +6,3 @@ import Metadata from './metadata'

import AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser'
import { findCountryCode } from './parse_'
import getCountryByCallingCode from './helpers/getCountryByCallingCode'

@@ -256,3 +256,3 @@ const USE_NON_GEOGRAPHIC_COUNTRY_CODE = false

determineTheCountry() {
this.state.setCountry(findCountryCode(
this.state.setCountry(getCountryByCallingCode(
this.isInternational() ? this.state.callingCode : this.defaultCallingCode,

@@ -259,0 +259,0 @@ this.state.nationalSignificantNumber,

@@ -1,4 +0,4 @@

import checkNumberLength from './checkNumberLength'
import parseDigits from './parseDigits'
import { formatNationalNumberUsingFormat } from './format_'
import checkNumberLength from './helpers/checkNumberLength'
import parseDigits from './helpers/parseDigits'
import formatNationalNumberUsingFormat from './helpers/formatNationalNumberUsingFormat'

@@ -5,0 +5,0 @@ export default function formatCompleteNumber(state, format, {

@@ -1,3 +0,1 @@

import parseDigits from './parseDigits'
import {

@@ -13,17 +11,12 @@ DIGIT_PLACEHOLDER,

export {
DIGIT_PLACEHOLDER
} from './AsYouTypeFormatter.util'
import formatCompleteNumber, {
canFormatCompleteNumber
} from './AsYouTypeFormatter.complete'
import formatCompleteNumber, { canFormatCompleteNumber } from './AsYouTypeFormatter.complete'
import parseDigits from './helpers/parseDigits'
export { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.util'
import { FIRST_GROUP_PATTERN } from './helpers/formatNationalNumberUsingFormat'
import { VALID_PUNCTUATION } from './constants'
import applyInternationalSeparatorStyle from './helpers/applyInternationalSeparatorStyle'
import {
FIRST_GROUP_PATTERN,
applyInternationalSeparatorStyle
} from './format_'
import {
VALID_PUNCTUATION
} from './constants'
// Used in phone number format template creation.

@@ -30,0 +23,0 @@ // Could be any digit, I guess.

@@ -1,13 +0,8 @@

import parseDigits from './parseDigits'
import extractCountryCallingCode from './helpers/extractCountryCallingCode'
import extractCountryCallingCodeFromInternationalNumberWithoutPlusSign from './helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign'
import extractNationalNumberFromPossiblyIncompleteNumber from './helpers/extractNationalNumberFromPossiblyIncompleteNumber'
import stripIddPrefix from './helpers/stripIddPrefix'
import parseDigits from './helpers/parseDigits'
import {
extractNationalNumber,
extractNationalNumberFromPossiblyIncompleteNumber,
extractCountryCallingCode,
extractCountryCallingCodeFromInternationalNumberWithoutPlusSign
} from './parse_'
import { stripIDDPrefix } from './IDD'
import {
VALID_DIGITS,

@@ -116,3 +111,3 @@ VALID_PUNCTUATION,

if (hasReceivedThreeLeadingDigits) {
this.extractIDDPrefix(state)
this.extractIddPrefix(state)
}

@@ -346,3 +341,3 @@

//
if (this.extractIDDPrefix(state)) {
if (this.extractIddPrefix(state)) {
this.extractCallingCodeAndNationalSignificantNumber(state)

@@ -364,3 +359,3 @@ return true

extractIDDPrefix(state) {
extractIddPrefix(state) {
// An IDD prefix can't be present in a number written with a `+`.

@@ -381,3 +376,3 @@ // Also, don't re-extract an IDD prefix if has already been extracted.

// Detect such numbers.
const numberWithoutIDD = stripIDDPrefix(
const numberWithoutIDD = stripIddPrefix(
digits,

@@ -384,0 +379,0 @@ this.defaultCountry,

import isValidNumber from '../validate_'
import parseDigits from '../parseDigits'
import parseDigits from '../helpers/parseDigits'

@@ -4,0 +4,0 @@ import {

@@ -11,5 +11,5 @@ // This is a legacy function.

import { EXTN_PATTERNS_FOR_PARSING } from './extension'
import parse from './parse_'
import { VALID_PHONE_NUMBER_WITH_EXTENSION } from './isViablePhoneNumber'
import { VALID_PHONE_NUMBER_WITH_EXTENSION } from './helpers/isViablePhoneNumber'
import createExtensionPattern from './helpers/extension/createExtensionPattern'

@@ -20,2 +20,19 @@ import parsePreCandidate from './findNumbers/parsePreCandidate'

/**
* Regexp of all possible ways to write extensions, for use when parsing. This
* will be run as a case-insensitive regexp match. Wide character versions are
* also provided after each ASCII version. There are three regular expressions
* here. The first covers RFC 3966 format, where the extension is added using
* ';ext='. The second more generic one starts with optional white space and
* ends with an optional full stop (.), followed by zero or more spaces/tabs
* /commas and then the numbers themselves. The other one covers the special
* case of American numbers where the extension is written with a hash at the
* end, such as '- 503#'. Note that the only capturing groups should be around
* the digits that you want to capture as part of the extension, or else parsing
* will fail! We allow two options for representing the accented o - the
* character itself, and one in the unicode decomposed form with the combining
* acute accent.
*/
export const EXTN_PATTERNS_FOR_PARSING = createExtensionPattern('parsing')
const WHITESPACE_IN_THE_BEGINNING_PATTERN = new RegExp('^[' + WHITESPACE + ']+')

@@ -22,0 +39,0 @@ const PUNCTUATION_IN_THE_END_PATTERN = new RegExp('[' + VALID_PUNCTUATION + ']+$')

@@ -6,7 +6,7 @@ // This is a port of Google Android `libphonenumber`'s

import { VALID_PUNCTUATION } from './constants'
import { matchesEntirely } from './util'
import matchesEntirely from './helpers/matchesEntirely'
import formatNationalNumberUsingFormat from './helpers/formatNationalNumberUsingFormat'
import Metadata, { getCountryCallingCode } from './metadata'
import { getIDDPrefix } from './IDD'
import { formatRFC3966 } from './RFC3966'
import getIddPrefix from './helpers/getIddPrefix'
import { formatRFC3966 } from './helpers/RFC3966'

@@ -113,47 +113,2 @@ const DEFAULT_OPTIONS = {

// This was originally set to $1 but there are some countries for which the
// first group is not used in the national pattern (e.g. Argentina) so the $1
// group does not match correctly. Therefore, we use `\d`, so that the first
// group actually used in the pattern will be matched.
export const FIRST_GROUP_PATTERN = /(\$\d)/
export function formatNationalNumberUsingFormat(
number,
format,
{
useInternationalFormat,
withNationalPrefix,
carrierCode,
metadata
}
) {
const formattedNumber = number.replace(
new RegExp(format.pattern()),
useInternationalFormat
? format.internationalFormat()
: (
// This library doesn't use `domestic_carrier_code_formatting_rule`,
// because that one is only used when formatting phone numbers
// for dialing from a mobile phone, and this is not a dialing library.
// carrierCode && format.domesticCarrierCodeFormattingRule()
// // First, replace the $CC in the formatting rule with the desired carrier code.
// // Then, replace the $FG in the formatting rule with the first group
// // and the carrier code combined in the appropriate way.
// ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
// : (
// withNationalPrefix && format.nationalPrefixFormattingRule()
// ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
// : format.format()
// )
withNationalPrefix && format.nationalPrefixFormattingRule()
? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
: format.format()
)
)
if (useInternationalFormat) {
return applyInternationalSeparatorStyle(formattedNumber)
}
return formattedNumber
}
function formatNationalNumber(number, carrierCode, formatAs, metadata, options) {

@@ -194,36 +149,2 @@ const format = chooseFormatForNumber(metadata.formats(), number)

// Removes brackets and replaces dashes with spaces.
//
// E.g. "(999) 111-22-33" -> "999 111 22 33"
//
// For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
// Meanwhile, there's no single opinion about using punctuation in international phone numbers.
//
// For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
// And here's a quote from WikiPedia's "North American Numbering Plan" page:
// https://en.wikipedia.org/wiki/North_American_Numbering_Plan
//
// "The country calling code for all countries participating in the NANP is 1.
// In international format, an NANP number should be listed as +1 301 555 01 00,
// where 301 is an area code (Maryland)."
//
// I personally prefer the international format without any punctuation.
// For example, brackets are remnants of the old age, meaning that the
// phone number part in brackets (so called "area code") can be omitted
// if dialing within the same "area".
// And hyphens were clearly introduced for splitting local numbers into memorizable groups.
// For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
// Imagine a man taking a bus from home to work and seeing an ad with a phone number.
// He has a couple of seconds to memorize that number until it passes by.
// If it were spaces instead of hyphens the man wouldn't necessarily get it,
// but with hyphens instead of spaces the grouping is more explicit.
// I personally think that hyphens introduce visual clutter,
// so I prefer replacing them with spaces in international numbers.
// In the modern age all output is done on displays where spaces are clearly distinguishable
// so hyphens can be safely replaced with spaces without losing any legibility.
//
export function applyInternationalSeparatorStyle(local) {
return local.replace(new RegExp(`[${VALID_PUNCTUATION}]+`, 'g'), ' ').trim()
}
function addExtension(formattedNumber, ext, metadata, formatExtension) {

@@ -260,6 +181,6 @@ return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber

}
const IDDPrefix = getIDDPrefix(fromCountry, undefined, metadata.metadata)
if (IDDPrefix) {
return `${IDDPrefix} ${countryCallingCode} ${formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata)}`
const iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata)
if (iddPrefix) {
return `${iddPrefix} ${countryCallingCode} ${formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata)}`
}
}
import metadata from '../metadata.min.json'
import { applyInternationalSeparatorStyle } from './format_'
import _formatNumber from './format'

@@ -119,7 +118,2 @@

it('should change Google\'s international format style', () => {
applyInternationalSeparatorStyle('(xxx) xxx-xx-xx').should.equal('xxx xxx xx xx')
applyInternationalSeparatorStyle('(xxx)xxx').should.equal('xxx xxx')
})
it('should format phone number extensions', () => {

@@ -126,0 +120,0 @@ // National

@@ -9,4 +9,4 @@ // This function is copy-pasted from

import format from './format_'
import getNumberType from './getNumberType_'
import checkNumberLength from './checkNumberLength'
import getNumberType from './helpers/getNumberType'
import checkNumberLength from './helpers/checkNumberLength'
import getCountryCallingCode from './getCountryCallingCode'

@@ -13,0 +13,0 @@

@@ -1,3 +0,3 @@

import isViablePhoneNumber from './isViablePhoneNumber'
import _getNumberType from './getNumberType_'
import isViablePhoneNumber from './helpers/isViablePhoneNumber'
import _getNumberType from './helpers/getNumberType'
import parse from './parse_'

@@ -4,0 +4,0 @@

import Metadata from './metadata'
import checkNumberLength from './checkNumberLength'
import checkNumberLength from './helpers/checkNumberLength'

@@ -4,0 +4,0 @@ export default function isPossiblePhoneNumber(input, options, metadata) {

@@ -1,2 +0,2 @@

import isViablePhoneNumber from './isViablePhoneNumber'
import isViablePhoneNumber from './helpers/isViablePhoneNumber'
import parseNumber from './parse_'

@@ -3,0 +3,0 @@ import _isValidNumberForRegion from './isValidNumberForRegion_'

@@ -10,19 +10,20 @@ // This is a port of Google Android `libphonenumber`'s

MIN_LENGTH_FOR_NSN,
MAX_LENGTH_FOR_NSN,
MAX_LENGTH_COUNTRY_CODE
MAX_LENGTH_FOR_NSN
} from './constants'
import { matchesEntirely } from './util'
import ParseError from './ParseError'
import Metadata from './metadata'
import isViablePhoneNumber from './isViablePhoneNumber'
import { extractExtension } from './extension'
import isViablePhoneNumber from './helpers/isViablePhoneNumber'
import extractExtension from './helpers/extension/extractExtension'
import parseIncompletePhoneNumber from './parseIncompletePhoneNumber'
import getCountryCallingCode from './getCountryCallingCode'
import getNumberType from './getNumberType_'
import checkNumberLength from './checkNumberLength'
import { isPossibleNumber } from './isPossibleNumber_'
import { stripIDDPrefix } from './IDD'
import { parseRFC3966 } from './RFC3966'
import { parseRFC3966 } from './helpers/RFC3966'
import PhoneNumber from './PhoneNumber'
import matchesEntirely from './helpers/matchesEntirely'
import extractCountryCallingCode from './helpers/extractCountryCallingCode'
import extractCountryCallingCodeFromInternationalNumberWithoutPlusSign from './helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign'
import extractNationalNumber from './helpers/extractNationalNumber'
import stripIddPrefix from './helpers/stripIddPrefix'
import getCountryByCallingCode from './helpers/getCountryByCallingCode'

@@ -222,176 +223,2 @@ // We don't allow input strings for parsing to be longer than 250 chars.

/**
* Strips any national prefix (such as 0, 1) present in a
* (possibly incomplete) number provided.
* "Carrier codes" are only used in Colombia and Brazil,
* and only when dialing within those countries from a mobile phone to a fixed line number.
* Sometimes it won't actually strip national prefix
* and will instead prepend some digits to the `number`:
* for example, when number `2345678` is passed with `VI` country selected,
* it will return `{ number: "3402345678" }`, because `340` area code is prepended.
* @param {string} number — National number digits.
* @param {object} metadata — Metadata with country selected.
* @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`.
*/
export function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
// See METADATA.md for the description of
// `national_prefix_for_parsing` and `national_prefix_transform_rule`.
// Attempt to parse the first digits as a national prefix.
const prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')')
const prefixMatch = prefixPattern.exec(number)
if (prefixMatch) {
let nationalNumber
let carrierCode
// https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
// If a `national_prefix_for_parsing` has any "capturing groups"
// then it means that the national (significant) number is equal to
// those "capturing groups" transformed via `national_prefix_transform_rule`,
// and nothing could be said about the actual national prefix:
// what is it and was it even there.
// If a `national_prefix_for_parsing` doesn't have any "capturing groups",
// then everything it matches is a national prefix.
// To determine whether `national_prefix_for_parsing` matched any
// "capturing groups", the value of the result of calling `.exec()`
// is looked at, and if it has non-undefined values where there're
// "capturing groups" in the regular expression, then it means
// that "capturing groups" have been matched.
// It's not possible to tell whether there'll be any "capturing gropus"
// before the matching process, because a `national_prefix_for_parsing`
// could exhibit both behaviors.
const capturedGroupsCount = prefixMatch.length - 1
const hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount]
if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
nationalNumber = number.replace(
prefixPattern,
metadata.nationalPrefixTransformRule()
)
// If there's more than one captured group,
// then carrier code is the second one.
if (capturedGroupsCount > 1) {
carrierCode = prefixMatch[1]
}
}
// If there're no "capturing groups",
// or if there're "capturing groups" but no
// `national_prefix_transform_rule`,
// then just strip the national prefix from the number,
// and possibly a carrier code.
// Seems like there could be more.
else {
// `prefixBeforeNationalNumber` is the whole substring matched by
// the `national_prefix_for_parsing` regular expression.
// There seem to be no guarantees that it's just a national prefix.
// For example, if there's a carrier code, it's gonna be a
// part of `prefixBeforeNationalNumber` too.
const prefixBeforeNationalNumber = prefixMatch[0]
nationalNumber = number.slice(prefixBeforeNationalNumber.length)
// If there's at least one captured group,
// then carrier code is the first one.
if (hasCapturedGroups) {
carrierCode = prefixMatch[1]
}
}
// Tries to guess whether a national prefix was present in the input.
// This is not something copy-pasted from Google's library:
// they don't seem to have an equivalent for that.
// So this isn't an "officially approved" way of doing something like that.
// But since there seems no other existing method, this library uses it.
let nationalPrefix
if (hasCapturedGroups) {
const possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1])
const possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup)
// Example: an Argentinian (AR) phone number `0111523456789`.
// `prefixMatch[0]` is `01115`, and `$1` is `11`,
// and the rest of the phone number is `23456789`.
// The national number is transformed via `9$1` to `91123456789`.
// National prefix `0` is detected being present at the start.
// if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
nationalPrefix = metadata.numberingPlan.nationalPrefix()
}
} else {
nationalPrefix = prefixMatch[0]
}
return {
nationalNumber,
nationalPrefix,
carrierCode
}
}
}
return {
nationalNumber: number
}
}
// In some countries, the same digit could be a national prefix
// or a leading digit of a valid phone number.
// For example, in Russia, national prefix is `8`,
// and also `800 555 35 35` is a valid number
// in which `8` is not a national prefix, but the first digit
// of a national (significant) number.
// Same's with Belarus:
// `82004910060` is a valid national (significant) number,
// but `2004910060` is not.
// To support such cases (to prevent the code from always stripping
// national prefix), a condition is imposed: a national prefix
// is not extracted when the original number is "viable" and the
// resultant number is not, a "viable" national number being the one
// that matches `national_number_pattern`.
function shouldExtractNationalPrefix(number, nationalSignificantNumber, metadata) {
// The equivalent in Google's code is:
// https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
if (matchesEntirely(number, metadata.nationalNumberPattern()) &&
!matchesEntirely(nationalSignificantNumber, metadata.nationalNumberPattern())) {
return false
}
// Just "possible" number check would be more relaxed, so it's not used.
// if (isPossibleNumber(number, metadata) &&
// !isPossibleNumber(numberWithNationalPrefixExtracted, metadata)) {
// return false
// }
return true
}
export function findCountryCode(callingCode, nationalPhoneNumber, metadata) {
/* istanbul ignore if */
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
if (metadata.isNonGeographicCallingCode(callingCode)) {
return '001'
}
}
// Is always non-empty, because `callingCode` is always valid
const possibleCountries = metadata.getCountryCodesForCallingCode(callingCode)
if (!possibleCountries) {
return
}
// If there's just one country corresponding to the country code,
// then just return it, without further phone number digits validation.
if (possibleCountries.length === 1) {
return possibleCountries[0]
}
return _findCountryCode(possibleCountries, nationalPhoneNumber, metadata.metadata)
}
// Changes `metadata` `country`.
function _findCountryCode(possibleCountries, nationalPhoneNumber, metadata) {
metadata = new Metadata(metadata)
for (const country of possibleCountries) {
metadata.country(country)
// Leading digits check would be the simplest one
if (metadata.leadingDigits()) {
if (nationalPhoneNumber &&
nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
return country
}
}
// Else perform full validation with all of those
// fixed-line/mobile/etc regular expressions.
else if (getNumberType({ phone: nationalPhoneNumber, country }, undefined, metadata.metadata)) {
return country
}
}
}
/**
* @param {string} text - Input.

@@ -500,3 +327,3 @@ * @return {object} `{ ?number, ?ext }`.

//
const exactCountry = findCountryCode(countryCallingCode, nationalNumber, metadata)
const exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata)
if (exactCountry) {

@@ -520,222 +347,2 @@ country = exactCountry

}
}
/**
* Strips national prefix and carrier code from a complete phone number.
* The difference from the non-"FromCompleteNumber" function is that
* it won't extract national prefix if the resultant number is too short
* to be a complete number for the selected phone numbering plan.
* @param {string} number — Complete phone number digits.
* @param {Metadata} metadata — Metadata with a phone numbering plan selected.
* @return {object} `{ nationalNumber: string, carrierCode: string? }`.
*/
export function extractNationalNumber(number, metadata) {
// Parsing national prefixes and carrier codes
// is only required for local phone numbers
// but some people don't understand that
// and sometimes write international phone numbers
// with national prefixes (or maybe even carrier codes).
// http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
// Google's original library forgives such mistakes
// and so does this library, because it has been requested:
// https://github.com/catamphetamine/libphonenumber-js/issues/127
const {
nationalNumber,
carrierCode
} = extractNationalNumberFromPossiblyIncompleteNumber(
number,
metadata
)
if (!shouldExtractNationalPrefix(number, nationalNumber, metadata)) {
// Don't strip the national prefix.
return { nationalNumber: number }
}
// If a national prefix has been extracted, check to see
// if the resultant number isn't too short.
// Same code in Google's `libphonenumber`:
// https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3291-L3302
// For some reason, they do this check right after the `national_number_pattern` check
// this library does in `shouldExtractNationalPrefix()` function.
// Why is there a second "resultant" number validity check?
// They don't provide an explanation.
// This library just copies the behavior.
if (number.length !== nationalNumber.length + (carrierCode ? carrierCode.length : 0)) {
// If not using legacy generated metadata (before version `1.0.18`)
// then it has "possible lengths", so use those to validate the number length.
if (metadata.possibleLengths()) {
// "We require that the NSN remaining after stripping the national prefix and
// carrier code be long enough to be a possible length for the region.
// Otherwise, we don't do the stripping, since the original number could be
// a valid short number."
// https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
switch (checkNumberLength(nationalNumber, metadata)) {
case 'TOO_SHORT':
case 'INVALID_LENGTH':
// case 'IS_POSSIBLE_LOCAL_ONLY':
// Don't strip the national prefix.
return { nationalNumber: number }
}
}
}
return { nationalNumber, carrierCode }
}
/**
* Converts a phone number digits (possibly with a `+`)
* into a calling code and the rest phone number digits.
* The "rest phone number digits" could include
* a national prefix, carrier code, and national
* (significant) number.
* @param {string} number — Phone number digits (possibly with a `+`).
* @param {string} [country] — Default country.
* @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
* @param {object} metadata
* @return {object} `{ countryCallingCode: string?, number: string }`
* @example
* // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
* extractCountryCallingCode('2133734253', 'US', null, metadata)
* extractCountryCallingCode('2133734253', null, '1', metadata)
* extractCountryCallingCode('+12133734253', null, null, metadata)
* extractCountryCallingCode('+12133734253', 'RU', null, metadata)
*/
export function extractCountryCallingCode(
number,
country,
callingCode,
metadata
) {
if (!number) {
return {}
}
// If this is not an international phone number,
// then either extract an "IDD" prefix, or extract a
// country calling code from a number by autocorrecting it
// by prepending a leading `+` in cases when it starts
// with the country calling code.
// https://wikitravel.org/en/International_dialling_prefix
// https://github.com/catamphetamine/libphonenumber-js/issues/376
if (number[0] !== '+') {
// Convert an "out-of-country" dialing phone number
// to a proper international phone number.
const numberWithoutIDD = stripIDDPrefix(number, country, callingCode, metadata)
// If an IDD prefix was stripped then
// convert the number to international one
// for subsequent parsing.
if (numberWithoutIDD && numberWithoutIDD !== number) {
number = '+' + numberWithoutIDD
} else {
// Check to see if the number starts with the country calling code
// for the default country. If so, we remove the country calling code,
// and do some checks on the validity of the number before and after.
// https://github.com/catamphetamine/libphonenumber-js/issues/376
if (country || callingCode) {
const {
countryCallingCode,
number: shorterNumber
} = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(
number,
country,
callingCode,
metadata
)
if (countryCallingCode) {
return {
countryCallingCode,
number: shorterNumber
}
}
}
return { number }
}
}
// Fast abortion: country codes do not begin with a '0'
if (number[1] === '0') {
return {}
}
metadata = new Metadata(metadata)
// The thing with country phone codes
// is that they are orthogonal to each other
// i.e. there's no such country phone code A
// for which country phone code B exists
// where B starts with A.
// Therefore, while scanning digits,
// if a valid country code is found,
// that means that it is the country code.
//
let i = 2
while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
const countryCallingCode = number.slice(1, i)
if (metadata.hasCallingCode(countryCallingCode)) {
metadata.selectNumberingPlan(countryCallingCode)
return {
countryCallingCode,
number: number.slice(i)
}
}
i++
}
return {}
}
/**
* Sometimes some people incorrectly input international phone numbers
* without the leading `+`. This function corrects such input.
* @param {string} number — Phone number digits.
* @param {string?} country
* @param {string?} callingCode
* @param {object} metadata
* @return {object} `{ countryCallingCode: string?, number: string }`.
*/
export function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(
number,
country,
callingCode,
metadata
) {
const countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode
if (number.indexOf(countryCallingCode) === 0) {
metadata = new Metadata(metadata)
metadata.selectNumberingPlan(country, callingCode)
const possibleShorterNumber = number.slice(countryCallingCode.length)
const {
nationalNumber: possibleShorterNationalNumber,
} = extractNationalNumber(
possibleShorterNumber,
metadata
)
const {
nationalNumber
} = extractNationalNumber(
number,
metadata
)
// If the number was not valid before but is valid now,
// or if it was too long before, we consider the number
// with the country calling code stripped to be a better result
// and keep that instead.
// For example, in Germany (+49), `49` is a valid area code,
// so if a number starts with `49`, it could be both a valid
// national German number or an international number without
// a leading `+`.
if (
(
!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())
&&
matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern())
)
||
checkNumberLength(nationalNumber, metadata) === 'TOO_LONG'
) {
return {
countryCallingCode,
number: possibleShorterNumber
}
}
}
return { number }
}
}
import metadata from '../metadata.min.json'
import _parseNumber from './parse'
import Metadata from './Metadata'
import { extractCountryCallingCode, extractNationalNumberFromPossiblyIncompleteNumber } from './parse_'
import Metadata from './metadata'

@@ -443,16 +442,2 @@ function parseNumber(...parameters) {

it('should extract country calling code from a number', () => {
extractCountryCallingCode('+78005553535', null, null, metadata).should.deep.equal({
countryCallingCode: '7',
number: '8005553535'
})
extractCountryCallingCode('+7800', null, null, metadata).should.deep.equal({
countryCallingCode: '7',
number: '800'
})
extractCountryCallingCode('', null, null, metadata).should.deep.equal({})
})
it('should correctly parse numbers starting with the same digit as the national prefix', () => {

@@ -540,14 +525,2 @@ // https://github.com/catamphetamine/libphonenumber-js/issues/373

})
})
describe('extractNationalNumberFromPossiblyIncompleteNumber', () => {
it('should parse a carrier code when there is no national prefix transform rule', () => {
const meta = new Metadata(metadata)
meta.country('AU')
extractNationalNumberFromPossiblyIncompleteNumber('18311800123', meta).should.deep.equal({
nationalPrefix: undefined,
carrierCode: '1831',
nationalNumber: '1800123'
})
})
})

@@ -1,2 +0,2 @@

import { parseDigit } from './parseDigits'
import { parseDigit } from './helpers/parseDigits'

@@ -33,10 +33,13 @@ /**

/**
* `input-format` `parse()` function.
* https://gitlab.com/catamphetamine/input-format
* Parses next character while parsing phone number digits (including a `+`)
* from text: discards everything except `+` and digits, and `+` is only allowed
* at the start of a phone number.
* For example, is used in `react-phone-number-input` where it uses
* [`input-format`](https://gitlab.com/catamphetamine/input-format).
* @param {string} character - Yet another character from raw input string.
* @param {string} value - The value parsed so far.
* @param {string?} prevParsedCharacters - Previous parsed characters.
* @param {object} meta - Optional custom use-case-specific metadata.
* @return {string?} The parsed character.
*/
export function parsePhoneNumberCharacter(character, value) {
export function parsePhoneNumberCharacter(character, prevParsedCharacters) {
// Only allow a leading `+`.

@@ -46,3 +49,3 @@ if (character === '+') {

// then discard it.
if (value) {
if (prevParsedCharacters) {
return

@@ -49,0 +52,0 @@ }

@@ -5,3 +5,3 @@ import Metadata from './metadata'

import isValidNumberForRegion from './isValidNumberForRegion_'
import getNumberType from './getNumberType_'
import getNumberType from './helpers/getNumberType'
import formatNumber from './format_'

@@ -8,0 +8,0 @@

@@ -15,3 +15,3 @@ /**

import { EXTN_PATTERNS_FOR_MATCHING } from './extension'
import createExtensionPattern from './helpers/extension/createExtensionPattern'

@@ -42,2 +42,4 @@ import RegExpCache from './findNumbers/RegExpCache'

const EXTN_PATTERNS_FOR_MATCHING = createExtensionPattern('matching')
/**

@@ -44,0 +46,0 @@ * Patterns used to extract phone numbers from a larger phone-number-like pattern. These are

import Metadata from './metadata'
import { matchesEntirely } from './util'
import getNumberType from './getNumberType_'
import matchesEntirely from './helpers/matchesEntirely'
import getNumberType from './helpers/getNumberType'

@@ -5,0 +5,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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