libphonenumber-js 1.10.46 → 1.10.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +15 -2
  2. package/build/AsYouType.js +5 -3
  3. package/build/AsYouType.js.map +1 -1
  4. package/build/formatIncompletePhoneNumber.js +5 -5
  5. package/build/formatIncompletePhoneNumber.js.map +1 -1
  6. package/build/formatIncompletePhoneNumber.test.js +8 -0
  7. package/build/formatIncompletePhoneNumber.test.js.map +1 -1
  8. package/build/helpers/isObject.js +12 -0
  9. package/build/helpers/isObject.js.map +1 -0
  10. package/build/legacy/format.js +4 -12
  11. package/build/legacy/format.js.map +1 -1
  12. package/build/legacy/getNumberType.js +5 -13
  13. package/build/legacy/getNumberType.js.map +1 -1
  14. package/build/metadata.js +5 -11
  15. package/build/metadata.js.map +1 -1
  16. package/build/normalizeArguments.js +5 -10
  17. package/build/normalizeArguments.js.map +1 -1
  18. package/bundle/libphonenumber-js.min.js +1 -1
  19. package/bundle/libphonenumber-js.min.js.map +1 -1
  20. package/bundle/libphonenumber-max.js +1 -1
  21. package/bundle/libphonenumber-max.js.map +1 -1
  22. package/bundle/libphonenumber-min.js +1 -1
  23. package/bundle/libphonenumber-min.js.map +1 -1
  24. package/bundle/libphonenumber-mobile.js +1 -1
  25. package/bundle/libphonenumber-mobile.js.map +1 -1
  26. package/core/index.d.cts +1 -1
  27. package/core/index.d.ts +1 -1
  28. package/custom.d.ts +1 -1
  29. package/es6/AsYouType.js +2 -3
  30. package/es6/AsYouType.js.map +1 -1
  31. package/es6/formatIncompletePhoneNumber.js +5 -5
  32. package/es6/formatIncompletePhoneNumber.js.map +1 -1
  33. package/es6/formatIncompletePhoneNumber.test.js +8 -0
  34. package/es6/formatIncompletePhoneNumber.test.js.map +1 -1
  35. package/es6/helpers/isObject.js +5 -0
  36. package/es6/helpers/isObject.js.map +1 -0
  37. package/es6/legacy/format.js +3 -12
  38. package/es6/legacy/format.js.map +1 -1
  39. package/es6/legacy/getNumberType.js +4 -12
  40. package/es6/legacy/getNumberType.js.map +1 -1
  41. package/es6/metadata.js +5 -12
  42. package/es6/metadata.js.map +1 -1
  43. package/es6/normalizeArguments.js +3 -10
  44. package/es6/normalizeArguments.js.map +1 -1
  45. package/index.d.cts +1 -0
  46. package/index.d.ts +1 -0
  47. package/max/index.d.cts +1 -1
  48. package/max/index.d.ts +1 -1
  49. package/min/index.d.cts +1 -1
  50. package/min/index.d.ts +1 -1
  51. package/mobile/index.d.cts +1 -1
  52. package/mobile/index.d.ts +1 -1
  53. package/package.json +1 -1
  54. package/source/AsYouType.js +2 -1
  55. package/source/formatIncompletePhoneNumber.js +5 -5
  56. package/source/formatIncompletePhoneNumber.test.js +5 -0
  57. package/source/helpers/isObject.js +5 -0
  58. package/source/legacy/format.js +3 -7
  59. package/source/legacy/getNumberType.js +4 -8
  60. package/source/metadata.js +4 -8
  61. package/source/normalizeArguments.js +3 -5
package/README.md CHANGED
@@ -1120,12 +1120,25 @@ parseIncompletePhoneNumber('+7 800 555') === '+7800555'
1120
1120
  parseIncompletePhoneNumber('+٤٤٢٣٢٣٢٣٤') === '+442323234'
1121
1121
  ```
1122
1122
 
1123
- ### formatIncompletePhoneNumber(value: string, country: string?): string
1123
+ ### formatIncompletePhoneNumber(value: string, defaultCountry?: string | options?: object): string
1124
1124
 
1125
- Formats incomplete phone number as a national one for a given `country`. If `country` is not specified then outputs the phone number in international format. This is just an alias for `new AsYouType(country, metadata).input(value)`. Can be used for building a phone number input component (e.g. [react-phone-number-input](https://gitlab.com/catamphetamine/react-phone-number-input/)).
1125
+ Formats a possibly incomplete phone number.
1126
+
1127
+ While the usual `parsePhoneNumber(string).format()` function could only be used to format a complete phone number, this function could be used to format a possibly incomplete phone number.
1128
+
1129
+ The `value` argument should be a (possibly incomplete) phone number in [`E.164`](https://en.wikipedia.org/wiki/E.164) format.
1130
+
1131
+ For the description of the `defaultCountry?: string | options?: object` argument, see [`parsePhoneNumber()`](#parsephonenumberstring-defaultcountry-string--options-object-phonenumber) function description.
1132
+
1133
+ This function is just an alias for `new AsYouType(defaultCountry, metadata).input(value)`. It can be used for building a phone number input component (e.g. [react-phone-number-input](https://gitlab.com/catamphetamine/react-phone-number-input/)).
1126
1134
 
1127
1135
  ```js
1136
+ // National numbers, with second argument.
1128
1137
  formatIncompletePhoneNumber('8800555', 'RU') === '8 (800) 555'
1138
+ formatIncompletePhoneNumber('8800555', { defaultCountry: 'RU' }) === '8 (800) 555'
1139
+ formatIncompletePhoneNumber('8800555', { defaultCallingCode: '7' }) === '8 (800) 555'
1140
+
1141
+ // International numbers, without second argument.
1129
1142
  formatIncompletePhoneNumber('+7800555') === '+7 800 555'
1130
1143
  ```
1131
1144
 
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -19,14 +21,14 @@ var _getCountryByCallingCode = _interopRequireDefault(require("./helpers/getCoun
19
21
 
20
22
  var _getCountryByNationalNumber = _interopRequireDefault(require("./helpers/getCountryByNationalNumber.js"));
21
23
 
24
+ var _isObject = _interopRequireDefault(require("./helpers/isObject.js"));
25
+
22
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
27
 
24
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
29
 
26
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
31
 
28
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
29
-
30
32
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
31
33
 
32
34
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -78,7 +80,7 @@ var AsYouType = /*#__PURE__*/function () {
78
80
  var defaultCallingCode; // Turns out `null` also has type "object". Weird.
79
81
 
80
82
  if (optionsOrDefaultCountry) {
81
- if (_typeof(optionsOrDefaultCountry) === 'object') {
83
+ if ((0, _isObject["default"])(optionsOrDefaultCountry)) {
82
84
  defaultCountry = optionsOrDefaultCountry.defaultCountry;
83
85
  defaultCallingCode = optionsOrDefaultCountry.defaultCallingCode;
84
86
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"AsYouType.js","names":["USE_NON_GEOGRAPHIC_COUNTRY_CODE","AsYouType","optionsOrDefaultCountry","metadata","Metadata","getCountryAndCallingCode","defaultCountry","defaultCallingCode","reset","hasCountry","undefined","isNonGeographicCallingCode","text","parser","input","state","digits","justLeadingPlus","formattedOutput","determineTheCountryIfNeeded","nationalSignificantNumber","formatter","narrowDownMatchingFormats","formattedNationalNumber","hasSelectedNumberingPlan","format","reExtractNationalSignificantNumber","nationalDigits","getNationalDigits","getFullNumber","getNonFormattedNumber","AsYouTypeState","onCountryChange","country","onCallingCodeChange","callingCode","selectNumberingPlan","numberingPlan","AsYouTypeFormatter","AsYouTypeParser","onNationalSignificantNumberChange","international","isInternational","getCallingCode","_getCountry","isCountryCallingCodeAmbiguous","determineTheCountry","prefix","getInternationalPrefixBeforeCountryCallingCode","spacing","getDigitsWithoutInternationalPrefix","complexPrefixBeforeNationalSignificantNumber","nationalPrefix","number","nationalSignificantNumberMatchesInput","getNonFormattedNationalNumberWithPrefix","replace","DIGIT_PLACEHOLDER","countryCodes","getCountryCodesForCallingCode","length","setCountry","getCountryByCallingCode","nationalNumber","callingCode_","countryCallingCode","carrierCode","ambiguousCountries","exactCountry","getCountryByNationalNumber","countries","phoneNumber","PhoneNumber","getNumber","isPossible","isValid","getTemplate","getNonFormattedTemplate"],"sources":["../source/AsYouType.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport PhoneNumber from './PhoneNumber.js'\r\nimport AsYouTypeState from './AsYouTypeState.js'\r\nimport AsYouTypeFormatter, { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.js'\r\nimport AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser.js'\r\nimport getCountryByCallingCode from './helpers/getCountryByCallingCode.js'\r\nimport getCountryByNationalNumber from './helpers/getCountryByNationalNumber.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class AsYouType {\r\n\t/**\r\n\t * @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.\r\n\t * @param {Object} metadata\r\n\t */\r\n\tconstructor(optionsOrDefaultCountry, metadata) {\r\n\t\tthis.metadata = new Metadata(metadata)\r\n\t\tconst [defaultCountry, defaultCallingCode] = this.getCountryAndCallingCode(optionsOrDefaultCountry)\r\n\t\t// `this.defaultCountry` and `this.defaultCallingCode` aren't required to be in sync.\r\n\t\t// For example, `this.defaultCountry` could be `\"AR\"` and `this.defaultCallingCode` could be `undefined`.\r\n\t\t// So `this.defaultCountry` and `this.defaultCallingCode` are totally independent.\r\n\t\tthis.defaultCountry = defaultCountry\r\n\t\tthis.defaultCallingCode = defaultCallingCode\r\n\t\tthis.reset()\r\n\t}\r\n\r\n\tgetCountryAndCallingCode(optionsOrDefaultCountry) {\r\n\t\t// Set `defaultCountry` and `defaultCallingCode` options.\r\n\t\tlet defaultCountry\r\n\t\tlet defaultCallingCode\r\n\t\t// Turns out `null` also has type \"object\". Weird.\r\n\t\tif (optionsOrDefaultCountry) {\r\n\t\t\tif (typeof optionsOrDefaultCountry === 'object') {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry.defaultCountry\r\n\t\t\t\tdefaultCallingCode = optionsOrDefaultCountry.defaultCallingCode\r\n\t\t\t} else {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (defaultCountry && !this.metadata.hasCountry(defaultCountry)) {\r\n\t\t\tdefaultCountry = undefined\r\n\t\t}\r\n\t\tif (defaultCallingCode) {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (this.metadata.isNonGeographicCallingCode(defaultCallingCode)) {\r\n\t\t\t\t\tdefaultCountry = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn [defaultCountry, defaultCallingCode]\r\n\t}\r\n\r\n\t/**\r\n\t * Inputs \"next\" phone number characters.\r\n\t * @param {string} text\r\n\t * @return {string} Formatted phone number characters that have been input so far.\r\n\t */\r\n\tinput(text) {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tjustLeadingPlus\r\n\t\t} = this.parser.input(text, this.state)\r\n\t\tif (justLeadingPlus) {\r\n\t\t\tthis.formattedOutput = '+'\r\n\t\t} else if (digits) {\r\n\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t// Match the available formats by the currently available leading digits.\r\n\t\t\tif (this.state.nationalSignificantNumber) {\r\n\t\t\t\tthis.formatter.narrowDownMatchingFormats(this.state)\r\n\t\t\t}\r\n\t\t\tlet formattedNationalNumber\r\n\t\t\tif (this.metadata.hasSelectedNumberingPlan()) {\r\n\t\t\t\tformattedNationalNumber = this.formatter.format(digits, this.state)\r\n\t\t\t}\r\n\t\t\tif (formattedNationalNumber === undefined) {\r\n\t\t\t\t// See if another national (significant) number could be re-extracted.\r\n\t\t\t\tif (this.parser.reExtractNationalSignificantNumber(this.state)) {\r\n\t\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\t\t// If it could, then re-try formatting the new national (significant) number.\r\n\t\t\t\t\tconst nationalDigits = this.state.getNationalDigits()\r\n\t\t\t\t\tif (nationalDigits) {\r\n\t\t\t\t\t\tformattedNationalNumber = this.formatter.format(nationalDigits, this.state)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.formattedOutput = formattedNationalNumber\r\n\t\t\t\t? this.getFullNumber(formattedNationalNumber)\r\n\t\t\t\t: this.getNonFormattedNumber()\r\n\t\t}\r\n\t\treturn this.formattedOutput\r\n\t}\r\n\r\n\treset() {\r\n\t\tthis.state = new AsYouTypeState({\r\n\t\t\tonCountryChange: (country) => {\r\n\t\t\t\t// Before version `1.6.0`, the official `AsYouType` formatter API\r\n\t\t\t\t// included the `.country` property of an `AsYouType` instance.\r\n\t\t\t\t// Since that property (along with the others) have been moved to\r\n\t\t\t\t// `this.state`, `this.country` property is emulated for compatibility\r\n\t\t\t\t// with the old versions.\r\n\t\t\t\tthis.country = country\r\n\t\t\t},\r\n\t\t\tonCallingCodeChange: (callingCode, country) => {\r\n\t\t\t\tthis.metadata.selectNumberingPlan(country, callingCode)\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t\tthis.parser.reset(this.metadata.numberingPlan)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.formatter = new AsYouTypeFormatter({\r\n\t\t\tstate: this.state,\r\n\t\t\tmetadata: this.metadata\r\n\t\t})\r\n\t\tthis.parser = new AsYouTypeParser({\r\n\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\tdefaultCallingCode: this.defaultCallingCode,\r\n\t\t\tmetadata: this.metadata,\r\n\t\t\tstate: this.state,\r\n\t\t\tonNationalSignificantNumberChange: () => {\r\n\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.state.reset({\r\n\t\t\tcountry: this.defaultCountry,\r\n\t\t\tcallingCode: this.defaultCallingCode\r\n\t\t})\r\n\t\tthis.formattedOutput = ''\r\n\t\treturn this\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is being input in international format.\r\n\t * In other words, returns `true` if and only if the parsed phone number starts with a `\"+\"`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisInternational() {\r\n\t\treturn this.state.international\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the \"calling code\" part of the phone number when it's being input\r\n\t * in an international format.\r\n\t * If no valid calling code has been entered so far, returns `undefined`.\r\n\t * @return {string} [callingCode]\r\n\t */\r\n\tgetCallingCode() {\r\n\t\t // If the number is being input in national format and some \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then `this.state.callingCode`\r\n\t\t // is equal to that \"default calling code\".\r\n\t\t //\r\n\t\t // If the number is being input in national format and no \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then returns `undefined`,\r\n\t\t // even if a \"default country\" has been passed to `AsYouType` constructor.\r\n\t\t //\r\n\t\tif (this.isInternational()) {\r\n\t\t\treturn this.state.callingCode\r\n\t\t}\r\n\t}\r\n\r\n\t// A legacy alias.\r\n\tgetCountryCallingCode() {\r\n\t\treturn this.getCallingCode()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * Returns `undefined` if no phone number has been input yet.\r\n\t * @return {string} [country]\r\n\t */\r\n\tgetCountry() {\r\n\t\tconst { digits } = this.state\r\n\t\t// Return `undefined` if no digits have been input yet.\r\n\t\tif (digits) {\r\n\t\t\treturn this._getCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * @return {string} [country]\r\n\t */\r\n\t_getCountry() {\r\n\t\tconst { country } = this.state\r\n\t\t/* istanbul ignore if */\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t// `AsYouType.getCountry()` returns `undefined`\r\n\t\t\t// for \"non-geographic\" phone numbering plans.\r\n\t\t\tif (country === '001') {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn country\r\n\t}\r\n\r\n\tdetermineTheCountryIfNeeded() {\r\n\t\t// Suppose a user enters a phone number in international format,\r\n\t\t// and there're several countries corresponding to that country calling code,\r\n\t\t// and a country has been derived from the number, and then\r\n\t\t// a user enters one more digit and the number is no longer\r\n\t\t// valid for the derived country, so the country should be re-derived\r\n\t\t// on every new digit in those cases.\r\n\t\t//\r\n\t\t// If the phone number is being input in national format,\r\n\t\t// then it could be a case when `defaultCountry` wasn't specified\r\n\t\t// when creating `AsYouType` instance, and just `defaultCallingCode` was specified,\r\n\t\t// and that \"calling code\" could correspond to a \"non-geographic entity\",\r\n\t\t// or there could be several countries corresponding to that country calling code.\r\n\t\t// In those cases, `this.country` is `undefined` and should be derived\r\n\t\t// from the number. Again, if country calling code is ambiguous, then\r\n\t\t// `this.country` should be re-derived with each new digit.\r\n\t\t//\r\n\t\tif (!this.state.country || this.isCountryCallingCodeAmbiguous()) {\r\n\t\t\tthis.determineTheCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t// Prepends `+CountryCode ` in case of an international phone number\r\n\tgetFullNumber(formattedNationalNumber) {\r\n\t\tif (this.isInternational()) {\r\n\t\t\tconst prefix = (text) => this.formatter.getInternationalPrefixBeforeCountryCallingCode(this.state, {\r\n\t\t\t\tspacing: text ? true : false\r\n\t\t\t}) + text\r\n\t\t\tconst { callingCode } = this.state\r\n\t\t\tif (!callingCode) {\r\n\t\t\t\treturn prefix(`${this.state.getDigitsWithoutInternationalPrefix()}`)\r\n\t\t\t}\r\n\t\t\tif (!formattedNationalNumber) {\r\n\t\t\t\treturn prefix(callingCode)\r\n\t\t\t}\r\n\t\t\treturn prefix(`${callingCode} ${formattedNationalNumber}`)\r\n\t\t}\r\n\t\treturn formattedNationalNumber\r\n\t}\r\n\r\n\tgetNonFormattedNationalNumberWithPrefix() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tcomplexPrefixBeforeNationalSignificantNumber,\r\n\t\t\tnationalPrefix\r\n\t\t} = this.state\r\n\t\tlet number = nationalSignificantNumber\r\n\t\tconst prefix = complexPrefixBeforeNationalSignificantNumber || nationalPrefix\r\n\t\tif (prefix) {\r\n\t\t\tnumber = prefix + number\r\n\t\t}\r\n\t\treturn number\r\n\t}\r\n\r\n\tgetNonFormattedNumber() {\r\n\t\tconst { nationalSignificantNumberMatchesInput } = this.state\r\n\t\treturn this.getFullNumber(\r\n\t\t\tnationalSignificantNumberMatchesInput\r\n\t\t\t\t? this.getNonFormattedNationalNumberWithPrefix()\r\n\t\t\t\t: this.state.getNationalDigits()\r\n\t\t)\r\n\t}\r\n\r\n\tgetNonFormattedTemplate() {\r\n\t\tconst number = this.getNonFormattedNumber()\r\n\t\tif (number) {\r\n\t\t\treturn number.replace(/[\\+\\d]/g, DIGIT_PLACEHOLDER)\r\n\t\t}\r\n\t}\r\n\r\n\tisCountryCallingCodeAmbiguous() {\r\n\t\tconst { callingCode } = this.state\r\n\t\tconst countryCodes = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\treturn countryCodes && countryCodes.length > 1\r\n\t}\r\n\r\n\t// Determines the country of the phone number\r\n\t// entered so far based on the country phone code\r\n\t// and the national phone number.\r\n\tdetermineTheCountry() {\r\n\t\tthis.state.setCountry(getCountryByCallingCode(\r\n\t\t\tthis.isInternational() ? this.state.callingCode : this.defaultCallingCode,\r\n\t\t\t{\r\n\t\t\t\tnationalNumber: this.state.nationalSignificantNumber,\r\n\t\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\t\tmetadata: this.metadata\r\n\t\t\t}\r\n\t\t))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a E.164 phone number value for the user's input.\r\n\t *\r\n\t * For example, for country `\"US\"` and input `\"(222) 333-4444\"`\r\n\t * it will return `\"+12223334444\"`.\r\n\t *\r\n\t * For international phone number input, it will also auto-correct\r\n\t * some minor errors such as using a national prefix when writing\r\n\t * an international phone number. For example, if the user inputs\r\n\t * `\"+44 0 7400 000000\"` then it will return an auto-corrected\r\n\t * `\"+447400000000\"` phone number value.\r\n\t *\r\n\t * Will return `undefined` if no digits have been input,\r\n\t * or when inputting a phone number in national format and no\r\n\t * default country or default \"country calling code\" have been set.\r\n\t *\r\n\t * @return {string} [value]\r\n\t */\r\n\tgetNumberValue() {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tcallingCode,\r\n\t\t\tcountry,\r\n\t\t\tnationalSignificantNumber\r\n\t\t} = this.state\r\n\r\n\t \t// Will return `undefined` if no digits have been input.\r\n\t\tif (!digits) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (this.isInternational()) {\r\n\t\t\tif (callingCode) {\r\n\t\t\t\treturn '+' + callingCode + nationalSignificantNumber\r\n\t\t\t} else {\r\n\t\t\t\treturn '+' + digits\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (country || callingCode) {\r\n\t\t\t\tconst callingCode_ = country ? this.metadata.countryCallingCode() : callingCode\r\n\t\t\t\treturn '+' + callingCode_ + nationalSignificantNumber\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an instance of `PhoneNumber` class.\r\n\t * Will return `undefined` if no national (significant) number\r\n\t * digits have been entered so far, or if no `defaultCountry` has been\r\n\t * set and the user enters a phone number not in international format.\r\n\t */\r\n\tgetNumber() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tcarrierCode,\r\n\t\t\tcallingCode\r\n\t\t} = this.state\r\n\r\n\t\t// `this._getCountry()` is basically same as `this.state.country`\r\n\t\t// with the only change that it return `undefined` in case of a\r\n\t\t// \"non-geographic\" numbering plan instead of `\"001\"` \"internal use\" value.\r\n\t\tlet country = this._getCountry()\r\n\r\n\t\tif (!nationalSignificantNumber) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t// For example, `country` could be `\"AR\"` and `callingCode` could be `undefined`.\r\n\t\t// So `country` and `callingCode` are totally independent.\r\n\r\n\t\tif (!country && !callingCode) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// By default, if `defaultCountry` parameter was passed when\r\n\t\t// creating `AsYouType` instance, `state.country` is gonna be\r\n\t\t// that `defaultCountry`, which doesn't entirely conform with\r\n\t\t// `parsePhoneNumber()`'s behavior where it attempts to determine\r\n\t\t// the country more precisely in cases when multiple countries\r\n\t\t// could correspond to the same `countryCallingCode`.\r\n\t\t// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/103#note_1417192969\r\n\t\t//\r\n\t\t// Because `AsYouType.getNumber()` method is supposed to be a 1:1\r\n\t\t// equivalent for `parsePhoneNumber(AsYouType.getNumberValue())`,\r\n\t\t// then it should also behave accordingly in cases of `country` ambiguity.\r\n\t\t// That's how users of this library would expect it to behave anyway.\r\n\t\t//\r\n\t\tif (country) {\r\n\t\t\tif (country === this.defaultCountry) {\r\n\t\t\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t\t\t// For example, `state.country` could be `\"AR\"` and `state.callingCode` could be `undefined`.\r\n\t\t\t\t// So `state.country` and `state.callingCode` are totally independent.\r\n\t\t\t\tconst metadata = new Metadata(this.metadata.metadata)\r\n\t\t\t\tmetadata.selectNumberingPlan(country)\r\n\t\t\t\tconst callingCode = metadata.numberingPlan.callingCode()\r\n\t\t\t\tconst ambiguousCountries = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\t\t\tif (ambiguousCountries.length > 1) {\r\n\t\t\t\t\tconst exactCountry = getCountryByNationalNumber(nationalSignificantNumber, {\r\n\t\t\t\t\t\tcountries: ambiguousCountries,\r\n\t\t\t\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\t\t\t\tmetadata: this.metadata.metadata\r\n\t\t\t\t\t})\r\n\t\t\t\t\tif (exactCountry) {\r\n\t\t\t\t\t\tcountry = exactCountry\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst phoneNumber = new PhoneNumber(\r\n\t\t\tcountry || callingCode,\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tthis.metadata.metadata\r\n\t\t)\r\n\t\tif (carrierCode) {\r\n\t\t\tphoneNumber.carrierCode = carrierCode\r\n\t\t}\r\n\t\t// Phone number extensions are not supported by \"As You Type\" formatter.\r\n\t\treturn phoneNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"possible\".\r\n\t * Is just a shortcut for `PhoneNumber.isPossible()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisPossible() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isPossible()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"valid\".\r\n\t * Is just a shortcut for `PhoneNumber.isValid()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisValid() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isValid()\r\n\t}\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * This method is used in `react-phone-number-input/source/input-control.js`\r\n\t * in versions before `3.0.16`.\r\n\t */\r\n\tgetNationalNumber() {\r\n\t\treturn this.state.nationalSignificantNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the phone number characters entered by the user.\r\n\t * @return {string}\r\n\t */\r\n\tgetChars() {\r\n\t\treturn (this.state.international ? '+' : '') + this.state.digits\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the template for the formatted phone number.\r\n\t * @return {string}\r\n\t */\r\n\tgetTemplate() {\r\n\t\treturn this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || ''\r\n\t}\r\n}"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,+BAA+B,GAAG,KAAxC;;IAEqBC,S;EACpB;AACD;AACA;AACA;EACC,mBAAYC,uBAAZ,EAAqCC,QAArC,EAA+C;IAAA;;IAC9C,KAAKA,QAAL,GAAgB,IAAIC,oBAAJ,CAAaD,QAAb,CAAhB;;IACA,4BAA6C,KAAKE,wBAAL,CAA8BH,uBAA9B,CAA7C;IAAA;IAAA,IAAOI,cAAP;IAAA,IAAuBC,kBAAvB,6BAF8C,CAG9C;IACA;IACA;;;IACA,KAAKD,cAAL,GAAsBA,cAAtB;IACA,KAAKC,kBAAL,GAA0BA,kBAA1B;IACA,KAAKC,KAAL;EACA;;;;WAED,kCAAyBN,uBAAzB,EAAkD;MACjD;MACA,IAAII,cAAJ;MACA,IAAIC,kBAAJ,CAHiD,CAIjD;;MACA,IAAIL,uBAAJ,E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ArB;;YAKA,IAAIiE,YAAJ,EAAkB;cACjBnC,OAAO,GAAGmC,YAAV;YACA;UACD;QACD;MACD;;MAED,IAAMG,WAAW,GAAG,IAAIC,uBAAJ,CACnBvC,OAAO,IAAIE,WADQ,EAEnBf,yBAFmB,EAGnB,KAAKjB,QAAL,CAAcA,QAHK,CAApB;;MAKA,IAAI+D,WAAJ,EAAiB;QAChBK,WAAW,CAACL,WAAZ,GAA0BA,WAA1B;MACA,CAlEU,CAmEX;;;MACA,OAAOK,WAAP;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,sBAAa;MACZ,IAAMA,WAAW,GAAG,KAAKE,SAAL,EAApB;;MACA,IAAI,CAACF,WAAL,EAAkB;QACjB,OAAO,KAAP;MACA;;MACD,OAAOA,WAAW,CAACG,UAAZ,EAAP;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,mBAAU;MACT,IAAMH,WAAW,GAAG,KAAKE,SAAL,EAApB;;MACA,IAAI,CAACF,WAAL,EAAkB;QACjB,OAAO,KAAP;MACA;;MACD,OAAOA,WAAW,CAACI,OAAZ,EAAP;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,6BAAoB;MACnB,OAAO,KAAK5D,KAAL,CAAWK,yBAAlB;IACA;IAED;AACD;AACA;AACA;;;;WACC,oBAAW;MACV,OAAO,CAAC,KAAKL,KAAL,CAAW0B,aAAX,GAA2B,GAA3B,GAAiC,EAAlC,IAAwC,KAAK1B,KAAL,CAAWC,MAA1D;IACA;IAED;AACD;AACA;AACA;;;;WACC,uBAAc;MACb,OAAO,KAAKK,SAAL,CAAeuD,WAAf,CAA2B,KAAK7D,KAAhC,KAA0C,KAAK8D,uBAAL,EAA1C,IAA4E,EAAnF;IACA"}
1
+ {"version":3,"file":"AsYouType.js","names":["USE_NON_GEOGRAPHIC_COUNTRY_CODE","AsYouType","optionsOrDefaultCountry","metadata","Metadata","getCountryAndCallingCode","defaultCountry","defaultCallingCode","reset","isObject","hasCountry","undefined","isNonGeographicCallingCode","text","parser","input","state","digits","justLeadingPlus","formattedOutput","determineTheCountryIfNeeded","nationalSignificantNumber","formatter","narrowDownMatchingFormats","formattedNationalNumber","hasSelectedNumberingPlan","format","reExtractNationalSignificantNumber","nationalDigits","getNationalDigits","getFullNumber","getNonFormattedNumber","AsYouTypeState","onCountryChange","country","onCallingCodeChange","callingCode","selectNumberingPlan","numberingPlan","AsYouTypeFormatter","AsYouTypeParser","onNationalSignificantNumberChange","international","isInternational","getCallingCode","_getCountry","isCountryCallingCodeAmbiguous","determineTheCountry","prefix","getInternationalPrefixBeforeCountryCallingCode","spacing","getDigitsWithoutInternationalPrefix","complexPrefixBeforeNationalSignificantNumber","nationalPrefix","number","nationalSignificantNumberMatchesInput","getNonFormattedNationalNumberWithPrefix","replace","DIGIT_PLACEHOLDER","countryCodes","getCountryCodesForCallingCode","length","setCountry","getCountryByCallingCode","nationalNumber","callingCode_","countryCallingCode","carrierCode","ambiguousCountries","exactCountry","getCountryByNationalNumber","countries","phoneNumber","PhoneNumber","getNumber","isPossible","isValid","getTemplate","getNonFormattedTemplate"],"sources":["../source/AsYouType.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport PhoneNumber from './PhoneNumber.js'\r\nimport AsYouTypeState from './AsYouTypeState.js'\r\nimport AsYouTypeFormatter, { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.js'\r\nimport AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser.js'\r\nimport getCountryByCallingCode from './helpers/getCountryByCallingCode.js'\r\nimport getCountryByNationalNumber from './helpers/getCountryByNationalNumber.js'\r\nimport isObject from './helpers/isObject.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class AsYouType {\r\n\t/**\r\n\t * @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.\r\n\t * @param {Object} metadata\r\n\t */\r\n\tconstructor(optionsOrDefaultCountry, metadata) {\r\n\t\tthis.metadata = new Metadata(metadata)\r\n\t\tconst [defaultCountry, defaultCallingCode] = this.getCountryAndCallingCode(optionsOrDefaultCountry)\r\n\t\t// `this.defaultCountry` and `this.defaultCallingCode` aren't required to be in sync.\r\n\t\t// For example, `this.defaultCountry` could be `\"AR\"` and `this.defaultCallingCode` could be `undefined`.\r\n\t\t// So `this.defaultCountry` and `this.defaultCallingCode` are totally independent.\r\n\t\tthis.defaultCountry = defaultCountry\r\n\t\tthis.defaultCallingCode = defaultCallingCode\r\n\t\tthis.reset()\r\n\t}\r\n\r\n\tgetCountryAndCallingCode(optionsOrDefaultCountry) {\r\n\t\t// Set `defaultCountry` and `defaultCallingCode` options.\r\n\t\tlet defaultCountry\r\n\t\tlet defaultCallingCode\r\n\t\t// Turns out `null` also has type \"object\". Weird.\r\n\t\tif (optionsOrDefaultCountry) {\r\n\t\t\tif (isObject(optionsOrDefaultCountry)) {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry.defaultCountry\r\n\t\t\t\tdefaultCallingCode = optionsOrDefaultCountry.defaultCallingCode\r\n\t\t\t} else {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (defaultCountry && !this.metadata.hasCountry(defaultCountry)) {\r\n\t\t\tdefaultCountry = undefined\r\n\t\t}\r\n\t\tif (defaultCallingCode) {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (this.metadata.isNonGeographicCallingCode(defaultCallingCode)) {\r\n\t\t\t\t\tdefaultCountry = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn [defaultCountry, defaultCallingCode]\r\n\t}\r\n\r\n\t/**\r\n\t * Inputs \"next\" phone number characters.\r\n\t * @param {string} text\r\n\t * @return {string} Formatted phone number characters that have been input so far.\r\n\t */\r\n\tinput(text) {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tjustLeadingPlus\r\n\t\t} = this.parser.input(text, this.state)\r\n\t\tif (justLeadingPlus) {\r\n\t\t\tthis.formattedOutput = '+'\r\n\t\t} else if (digits) {\r\n\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t// Match the available formats by the currently available leading digits.\r\n\t\t\tif (this.state.nationalSignificantNumber) {\r\n\t\t\t\tthis.formatter.narrowDownMatchingFormats(this.state)\r\n\t\t\t}\r\n\t\t\tlet formattedNationalNumber\r\n\t\t\tif (this.metadata.hasSelectedNumberingPlan()) {\r\n\t\t\t\tformattedNationalNumber = this.formatter.format(digits, this.state)\r\n\t\t\t}\r\n\t\t\tif (formattedNationalNumber === undefined) {\r\n\t\t\t\t// See if another national (significant) number could be re-extracted.\r\n\t\t\t\tif (this.parser.reExtractNationalSignificantNumber(this.state)) {\r\n\t\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\t\t// If it could, then re-try formatting the new national (significant) number.\r\n\t\t\t\t\tconst nationalDigits = this.state.getNationalDigits()\r\n\t\t\t\t\tif (nationalDigits) {\r\n\t\t\t\t\t\tformattedNationalNumber = this.formatter.format(nationalDigits, this.state)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.formattedOutput = formattedNationalNumber\r\n\t\t\t\t? this.getFullNumber(formattedNationalNumber)\r\n\t\t\t\t: this.getNonFormattedNumber()\r\n\t\t}\r\n\t\treturn this.formattedOutput\r\n\t}\r\n\r\n\treset() {\r\n\t\tthis.state = new AsYouTypeState({\r\n\t\t\tonCountryChange: (country) => {\r\n\t\t\t\t// Before version `1.6.0`, the official `AsYouType` formatter API\r\n\t\t\t\t// included the `.country` property of an `AsYouType` instance.\r\n\t\t\t\t// Since that property (along with the others) have been moved to\r\n\t\t\t\t// `this.state`, `this.country` property is emulated for compatibility\r\n\t\t\t\t// with the old versions.\r\n\t\t\t\tthis.country = country\r\n\t\t\t},\r\n\t\t\tonCallingCodeChange: (callingCode, country) => {\r\n\t\t\t\tthis.metadata.selectNumberingPlan(country, callingCode)\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t\tthis.parser.reset(this.metadata.numberingPlan)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.formatter = new AsYouTypeFormatter({\r\n\t\t\tstate: this.state,\r\n\t\t\tmetadata: this.metadata\r\n\t\t})\r\n\t\tthis.parser = new AsYouTypeParser({\r\n\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\tdefaultCallingCode: this.defaultCallingCode,\r\n\t\t\tmetadata: this.metadata,\r\n\t\t\tstate: this.state,\r\n\t\t\tonNationalSignificantNumberChange: () => {\r\n\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.state.reset({\r\n\t\t\tcountry: this.defaultCountry,\r\n\t\t\tcallingCode: this.defaultCallingCode\r\n\t\t})\r\n\t\tthis.formattedOutput = ''\r\n\t\treturn this\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is being input in international format.\r\n\t * In other words, returns `true` if and only if the parsed phone number starts with a `\"+\"`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisInternational() {\r\n\t\treturn this.state.international\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the \"calling code\" part of the phone number when it's being input\r\n\t * in an international format.\r\n\t * If no valid calling code has been entered so far, returns `undefined`.\r\n\t * @return {string} [callingCode]\r\n\t */\r\n\tgetCallingCode() {\r\n\t\t // If the number is being input in national format and some \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then `this.state.callingCode`\r\n\t\t // is equal to that \"default calling code\".\r\n\t\t //\r\n\t\t // If the number is being input in national format and no \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then returns `undefined`,\r\n\t\t // even if a \"default country\" has been passed to `AsYouType` constructor.\r\n\t\t //\r\n\t\tif (this.isInternational()) {\r\n\t\t\treturn this.state.callingCode\r\n\t\t}\r\n\t}\r\n\r\n\t// A legacy alias.\r\n\tgetCountryCallingCode() {\r\n\t\treturn this.getCallingCode()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * Returns `undefined` if no phone number has been input yet.\r\n\t * @return {string} [country]\r\n\t */\r\n\tgetCountry() {\r\n\t\tconst { digits } = this.state\r\n\t\t// Return `undefined` if no digits have been input yet.\r\n\t\tif (digits) {\r\n\t\t\treturn this._getCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * @return {string} [country]\r\n\t */\r\n\t_getCountry() {\r\n\t\tconst { country } = this.state\r\n\t\t/* istanbul ignore if */\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t// `AsYouType.getCountry()` returns `undefined`\r\n\t\t\t// for \"non-geographic\" phone numbering plans.\r\n\t\t\tif (country === '001') {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn country\r\n\t}\r\n\r\n\tdetermineTheCountryIfNeeded() {\r\n\t\t// Suppose a user enters a phone number in international format,\r\n\t\t// and there're several countries corresponding to that country calling code,\r\n\t\t// and a country has been derived from the number, and then\r\n\t\t// a user enters one more digit and the number is no longer\r\n\t\t// valid for the derived country, so the country should be re-derived\r\n\t\t// on every new digit in those cases.\r\n\t\t//\r\n\t\t// If the phone number is being input in national format,\r\n\t\t// then it could be a case when `defaultCountry` wasn't specified\r\n\t\t// when creating `AsYouType` instance, and just `defaultCallingCode` was specified,\r\n\t\t// and that \"calling code\" could correspond to a \"non-geographic entity\",\r\n\t\t// or there could be several countries corresponding to that country calling code.\r\n\t\t// In those cases, `this.country` is `undefined` and should be derived\r\n\t\t// from the number. Again, if country calling code is ambiguous, then\r\n\t\t// `this.country` should be re-derived with each new digit.\r\n\t\t//\r\n\t\tif (!this.state.country || this.isCountryCallingCodeAmbiguous()) {\r\n\t\t\tthis.determineTheCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t// Prepends `+CountryCode ` in case of an international phone number\r\n\tgetFullNumber(formattedNationalNumber) {\r\n\t\tif (this.isInternational()) {\r\n\t\t\tconst prefix = (text) => this.formatter.getInternationalPrefixBeforeCountryCallingCode(this.state, {\r\n\t\t\t\tspacing: text ? true : false\r\n\t\t\t}) + text\r\n\t\t\tconst { callingCode } = this.state\r\n\t\t\tif (!callingCode) {\r\n\t\t\t\treturn prefix(`${this.state.getDigitsWithoutInternationalPrefix()}`)\r\n\t\t\t}\r\n\t\t\tif (!formattedNationalNumber) {\r\n\t\t\t\treturn prefix(callingCode)\r\n\t\t\t}\r\n\t\t\treturn prefix(`${callingCode} ${formattedNationalNumber}`)\r\n\t\t}\r\n\t\treturn formattedNationalNumber\r\n\t}\r\n\r\n\tgetNonFormattedNationalNumberWithPrefix() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tcomplexPrefixBeforeNationalSignificantNumber,\r\n\t\t\tnationalPrefix\r\n\t\t} = this.state\r\n\t\tlet number = nationalSignificantNumber\r\n\t\tconst prefix = complexPrefixBeforeNationalSignificantNumber || nationalPrefix\r\n\t\tif (prefix) {\r\n\t\t\tnumber = prefix + number\r\n\t\t}\r\n\t\treturn number\r\n\t}\r\n\r\n\tgetNonFormattedNumber() {\r\n\t\tconst { nationalSignificantNumberMatchesInput } = this.state\r\n\t\treturn this.getFullNumber(\r\n\t\t\tnationalSignificantNumberMatchesInput\r\n\t\t\t\t? this.getNonFormattedNationalNumberWithPrefix()\r\n\t\t\t\t: this.state.getNationalDigits()\r\n\t\t)\r\n\t}\r\n\r\n\tgetNonFormattedTemplate() {\r\n\t\tconst number = this.getNonFormattedNumber()\r\n\t\tif (number) {\r\n\t\t\treturn number.replace(/[\\+\\d]/g, DIGIT_PLACEHOLDER)\r\n\t\t}\r\n\t}\r\n\r\n\tisCountryCallingCodeAmbiguous() {\r\n\t\tconst { callingCode } = this.state\r\n\t\tconst countryCodes = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\treturn countryCodes && countryCodes.length > 1\r\n\t}\r\n\r\n\t// Determines the country of the phone number\r\n\t// entered so far based on the country phone code\r\n\t// and the national phone number.\r\n\tdetermineTheCountry() {\r\n\t\tthis.state.setCountry(getCountryByCallingCode(\r\n\t\t\tthis.isInternational() ? this.state.callingCode : this.defaultCallingCode,\r\n\t\t\t{\r\n\t\t\t\tnationalNumber: this.state.nationalSignificantNumber,\r\n\t\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\t\tmetadata: this.metadata\r\n\t\t\t}\r\n\t\t))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a E.164 phone number value for the user's input.\r\n\t *\r\n\t * For example, for country `\"US\"` and input `\"(222) 333-4444\"`\r\n\t * it will return `\"+12223334444\"`.\r\n\t *\r\n\t * For international phone number input, it will also auto-correct\r\n\t * some minor errors such as using a national prefix when writing\r\n\t * an international phone number. For example, if the user inputs\r\n\t * `\"+44 0 7400 000000\"` then it will return an auto-corrected\r\n\t * `\"+447400000000\"` phone number value.\r\n\t *\r\n\t * Will return `undefined` if no digits have been input,\r\n\t * or when inputting a phone number in national format and no\r\n\t * default country or default \"country calling code\" have been set.\r\n\t *\r\n\t * @return {string} [value]\r\n\t */\r\n\tgetNumberValue() {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tcallingCode,\r\n\t\t\tcountry,\r\n\t\t\tnationalSignificantNumber\r\n\t\t} = this.state\r\n\r\n\t \t// Will return `undefined` if no digits have been input.\r\n\t\tif (!digits) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (this.isInternational()) {\r\n\t\t\tif (callingCode) {\r\n\t\t\t\treturn '+' + callingCode + nationalSignificantNumber\r\n\t\t\t} else {\r\n\t\t\t\treturn '+' + digits\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (country || callingCode) {\r\n\t\t\t\tconst callingCode_ = country ? this.metadata.countryCallingCode() : callingCode\r\n\t\t\t\treturn '+' + callingCode_ + nationalSignificantNumber\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an instance of `PhoneNumber` class.\r\n\t * Will return `undefined` if no national (significant) number\r\n\t * digits have been entered so far, or if no `defaultCountry` has been\r\n\t * set and the user enters a phone number not in international format.\r\n\t */\r\n\tgetNumber() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tcarrierCode,\r\n\t\t\tcallingCode\r\n\t\t} = this.state\r\n\r\n\t\t// `this._getCountry()` is basically same as `this.state.country`\r\n\t\t// with the only change that it return `undefined` in case of a\r\n\t\t// \"non-geographic\" numbering plan instead of `\"001\"` \"internal use\" value.\r\n\t\tlet country = this._getCountry()\r\n\r\n\t\tif (!nationalSignificantNumber) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t// For example, `country` could be `\"AR\"` and `callingCode` could be `undefined`.\r\n\t\t// So `country` and `callingCode` are totally independent.\r\n\r\n\t\tif (!country && !callingCode) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// By default, if `defaultCountry` parameter was passed when\r\n\t\t// creating `AsYouType` instance, `state.country` is gonna be\r\n\t\t// that `defaultCountry`, which doesn't entirely conform with\r\n\t\t// `parsePhoneNumber()`'s behavior where it attempts to determine\r\n\t\t// the country more precisely in cases when multiple countries\r\n\t\t// could correspond to the same `countryCallingCode`.\r\n\t\t// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/103#note_1417192969\r\n\t\t//\r\n\t\t// Because `AsYouType.getNumber()` method is supposed to be a 1:1\r\n\t\t// equivalent for `parsePhoneNumber(AsYouType.getNumberValue())`,\r\n\t\t// then it should also behave accordingly in cases of `country` ambiguity.\r\n\t\t// That's how users of this library would expect it to behave anyway.\r\n\t\t//\r\n\t\tif (country) {\r\n\t\t\tif (country === this.defaultCountry) {\r\n\t\t\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t\t\t// For example, `state.country` could be `\"AR\"` and `state.callingCode` could be `undefined`.\r\n\t\t\t\t// So `state.country` and `state.callingCode` are totally independent.\r\n\t\t\t\tconst metadata = new Metadata(this.metadata.metadata)\r\n\t\t\t\tmetadata.selectNumberingPlan(country)\r\n\t\t\t\tconst callingCode = metadata.numberingPlan.callingCode()\r\n\t\t\t\tconst ambiguousCountries = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\t\t\tif (ambiguousCountries.length > 1) {\r\n\t\t\t\t\tconst exactCountry = getCountryByNationalNumber(nationalSignificantNumber, {\r\n\t\t\t\t\t\tcountries: ambiguousCountries,\r\n\t\t\t\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\t\t\t\tmetadata: this.metadata.metadata\r\n\t\t\t\t\t})\r\n\t\t\t\t\tif (exactCountry) {\r\n\t\t\t\t\t\tcountry = exactCountry\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst phoneNumber = new PhoneNumber(\r\n\t\t\tcountry || callingCode,\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tthis.metadata.metadata\r\n\t\t)\r\n\t\tif (carrierCode) {\r\n\t\t\tphoneNumber.carrierCode = carrierCode\r\n\t\t}\r\n\t\t// Phone number extensions are not supported by \"As You Type\" formatter.\r\n\t\treturn phoneNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"possible\".\r\n\t * Is just a shortcut for `PhoneNumber.isPossible()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisPossible() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isPossible()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"valid\".\r\n\t * Is just a shortcut for `PhoneNumber.isValid()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisValid() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isValid()\r\n\t}\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * This method is used in `react-phone-number-input/source/input-control.js`\r\n\t * in versions before `3.0.16`.\r\n\t */\r\n\tgetNationalNumber() {\r\n\t\treturn this.state.nationalSignificantNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the phone number characters entered by the user.\r\n\t * @return {string}\r\n\t */\r\n\tgetChars() {\r\n\t\treturn (this.state.international ? '+' : '') + this.state.digits\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the template for the formatted phone number.\r\n\t * @return {string}\r\n\t */\r\n\tgetTemplate() {\r\n\t\treturn this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || ''\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,+BAA+B,GAAG,KAAxC;;IAEqBC,S;EACpB;AACD;AACA;AACA;EACC,mBAAYC,uBAAZ,EAAqCC,QAArC,EAA+C;IAAA;;IAC9C,KAAKA,QAAL,GAAgB,IAAIC,oBAAJ,CAAaD,QAAb,CAAhB;;IACA,4BAA6C,KAAKE,wBAAL,CAA8BH,uBAA9B,CAA7C;IAAA;IAAA,IAAOI,cAAP;IAAA,IAAuBC,kBAAvB,6BAF8C,CAG9C;IACA;IACA;;;IACA,KAAKD,cAAL,GAAsBA,cAAtB;IACA,KAAKC,kBAAL,GAA0BA,kBAA1B;IACA,KAAKC,KAAL;EACA;;;;WAED,kCAAyBN,uBAAzB,EAAkD;MACjD;MACA,IAAII,cAAJ;MACA,IAAIC,kBAAJ,CAHiD,CAIjD;;MACA,IAAIL,uB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kD,CAAtD,CAArB;;YAKA,IAAIkE,YAAJ,EAAkB;cACjBnC,OAAO,GAAGmC,YAAV;YACA;UACD;QACD;MACD;;MAED,IAAMG,WAAW,GAAG,IAAIC,uBAAJ,CACnBvC,OAAO,IAAIE,WADQ,EAEnBf,yBAFmB,EAGnB,KAAKlB,QAAL,CAAcA,QAHK,CAApB;;MAKA,IAAIgE,WAAJ,EAAiB;QAChBK,WAAW,CAACL,WAAZ,GAA0BA,WAA1B;MACA,CAlEU,CAmEX;;;MACA,OAAOK,WAAP;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,sBAAa;MACZ,IAAMA,WAAW,GAAG,KAAKE,SAAL,EAApB;;MACA,IAAI,CAACF,WAAL,EAAkB;QACjB,OAAO,KAAP;MACA;;MACD,OAAOA,WAAW,CAACG,UAAZ,EAAP;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,mBAAU;MACT,IAAMH,WAAW,GAAG,KAAKE,SAAL,EAApB;;MACA,IAAI,CAACF,WAAL,EAAkB;QACjB,OAAO,KAAP;MACA;;MACD,OAAOA,WAAW,CAACI,OAAZ,EAAP;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,6BAAoB;MACnB,OAAO,KAAK5D,KAAL,CAAWK,yBAAlB;IACA;IAED;AACD;AACA;AACA;;;;WACC,oBAAW;MACV,OAAO,CAAC,KAAKL,KAAL,CAAW0B,aAAX,GAA2B,GAA3B,GAAiC,EAAlC,IAAwC,KAAK1B,KAAL,CAAWC,MAA1D;IACA;IAED;AACD;AACA;AACA;;;;WACC,uBAAc;MACb,OAAO,KAAKK,SAAL,CAAeuD,WAAf,CAA2B,KAAK7D,KAAhC,KAA0C,KAAK8D,uBAAL,EAA1C,IAA4E,EAAnF;IACA"}
@@ -14,15 +14,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
14
14
  * The phone number can be either in E.164 format
15
15
  * or in a form of national number digits.
16
16
  * @param {string} value - A possibly incomplete phone number. Either in E.164 format or in a form of national number digits.
17
- * @param {string?} country - Two-letter ("ISO 3166-1 alpha-2") country code.
17
+ * @param {string|object} [optionsOrDefaultCountry] - A two-letter ("ISO 3166-1 alpha-2") country code, or an object of shape `{ defaultCountry?: string, defaultCallingCode?: string }`.
18
18
  * @return {string} Formatted (possibly incomplete) phone number.
19
19
  */
20
- function formatIncompletePhoneNumber(value, country, metadata) {
20
+ function formatIncompletePhoneNumber(value, optionsOrDefaultCountry, metadata) {
21
21
  if (!metadata) {
22
- metadata = country;
23
- country = undefined;
22
+ metadata = optionsOrDefaultCountry;
23
+ optionsOrDefaultCountry = undefined;
24
24
  }
25
25
 
26
- return new _AsYouType["default"](country, metadata).input(value);
26
+ return new _AsYouType["default"](optionsOrDefaultCountry, metadata).input(value);
27
27
  }
28
28
  //# sourceMappingURL=formatIncompletePhoneNumber.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatIncompletePhoneNumber.js","names":["formatIncompletePhoneNumber","value","country","metadata","undefined","AsYouType","input"],"sources":["../source/formatIncompletePhoneNumber.js"],"sourcesContent":["import AsYouType from './AsYouType.js'\r\n\r\n/**\r\n * Formats a (possibly incomplete) phone number.\r\n * The phone number can be either in E.164 format\r\n * or in a form of national number digits.\r\n * @param {string} value - A possibly incomplete phone number. Either in E.164 format or in a form of national number digits.\r\n * @param {string?} country - Two-letter (\"ISO 3166-1 alpha-2\") country code.\r\n * @return {string} Formatted (possibly incomplete) phone number.\r\n */\r\nexport default function formatIncompletePhoneNumber(value, country, metadata) {\r\n\tif (!metadata) {\r\n\t\tmetadata = country\r\n\t\tcountry = undefined\r\n\t}\r\n\treturn new AsYouType(country, metadata).input(value)\r\n}"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,2BAAT,CAAqCC,KAArC,EAA4CC,OAA5C,EAAqDC,QAArD,EAA+D;EAC7E,IAAI,CAACA,QAAL,EAAe;IACdA,QAAQ,GAAGD,OAAX;IACAA,OAAO,GAAGE,SAAV;EACA;;EACD,OAAO,IAAIC,qBAAJ,CAAcH,OAAd,EAAuBC,QAAvB,EAAiCG,KAAjC,CAAuCL,KAAvC,CAAP;AACA"}
1
+ {"version":3,"file":"formatIncompletePhoneNumber.js","names":["formatIncompletePhoneNumber","value","optionsOrDefaultCountry","metadata","undefined","AsYouType","input"],"sources":["../source/formatIncompletePhoneNumber.js"],"sourcesContent":["import AsYouType from './AsYouType.js'\r\n\r\n/**\r\n * Formats a (possibly incomplete) phone number.\r\n * The phone number can be either in E.164 format\r\n * or in a form of national number digits.\r\n * @param {string} value - A possibly incomplete phone number. Either in E.164 format or in a form of national number digits.\r\n * @param {string|object} [optionsOrDefaultCountry] - A two-letter (\"ISO 3166-1 alpha-2\") country code, or an object of shape `{ defaultCountry?: string, defaultCallingCode?: string }`.\r\n * @return {string} Formatted (possibly incomplete) phone number.\r\n */\r\nexport default function formatIncompletePhoneNumber(value, optionsOrDefaultCountry, metadata) {\r\n\tif (!metadata) {\r\n\t\tmetadata = optionsOrDefaultCountry\r\n\t\toptionsOrDefaultCountry = undefined\r\n\t}\r\n\treturn new AsYouType(optionsOrDefaultCountry, metadata).input(value)\r\n}"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,2BAAT,CAAqCC,KAArC,EAA4CC,uBAA5C,EAAqEC,QAArE,EAA+E;EAC7F,IAAI,CAACA,QAAL,EAAe;IACdA,QAAQ,GAAGD,uBAAX;IACAA,uBAAuB,GAAGE,SAA1B;EACA;;EACD,OAAO,IAAIC,qBAAJ,CAAcH,uBAAd,EAAuCC,QAAvC,EAAiDG,KAAjD,CAAuDL,KAAvD,CAAP;AACA"}
@@ -18,5 +18,13 @@ describe('formatIncompletePhoneNumber', function () {
18
18
 
19
19
  (0, _formatIncompletePhoneNumber["default"])('+780055535', 'RU', _metadataMin["default"]).should.equal('+7 800 555 35');
20
20
  });
21
+ it('should support an object argument', function () {
22
+ (0, _formatIncompletePhoneNumber["default"])('880055535', {
23
+ defaultCountry: 'RU'
24
+ }, _metadataMin["default"]).should.equal('8 (800) 555-35');
25
+ (0, _formatIncompletePhoneNumber["default"])('880055535', {
26
+ defaultCallingCode: '7'
27
+ }, _metadataMin["default"]).should.equal('8 (800) 555-35');
28
+ });
21
29
  });
22
30
  //# sourceMappingURL=formatIncompletePhoneNumber.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatIncompletePhoneNumber.test.js","names":["describe","it","result","formatIncompletePhoneNumber","metadata","should","equal"],"sources":["../source/formatIncompletePhoneNumber.test.js"],"sourcesContent":["import formatIncompletePhoneNumber from './formatIncompletePhoneNumber.js'\r\n\r\nimport metadata from '../metadata.min.json' assert { type: 'json' }\r\n\r\ndescribe('formatIncompletePhoneNumber', () => {\r\n\tit('should format parsed input value', () => {\r\n\t\tlet result\r\n\r\n\t\t// National input.\r\n\t\tformatIncompletePhoneNumber('880055535', 'RU', metadata).should.equal('8 (800) 555-35')\r\n\r\n\t\t// International input, no country.\r\n\t\tformatIncompletePhoneNumber('+780055535', null, metadata).should.equal('+7 800 555 35')\r\n\r\n\t\t// International input, no country argument.\r\n\t\tformatIncompletePhoneNumber('+780055535', metadata).should.equal('+7 800 555 35')\r\n\r\n\t\t// International input, with country.\r\n\t\tformatIncompletePhoneNumber('+780055535', 'RU', metadata).should.equal('+7 800 555 35')\r\n\t})\r\n})"],"mappings":";;AAAA;;AAEA;;;;AAEAA,QAAQ,CAAC,6BAAD,EAAgC,YAAM;EAC7CC,EAAE,CAAC,kCAAD,EAAqC,YAAM;IAC5C,IAAIC,MAAJ,CAD4C,CAG5C;;IACA,IAAAC,uCAAA,EAA4B,WAA5B,EAAyC,IAAzC,EAA+CC,uBAA/C,EAAyDC,MAAzD,CAAgEC,KAAhE,CAAsE,gBAAtE,EAJ4C,CAM5C;;IACA,IAAAH,uCAAA,EAA4B,YAA5B,EAA0C,IAA1C,EAAgDC,uBAAhD,EAA0DC,MAA1D,CAAiEC,KAAjE,CAAuE,eAAvE,EAP4C,CAS5C;;IACA,IAAAH,uCAAA,EAA4B,YAA5B,EAA0CC,uBAA1C,EAAoDC,MAApD,CAA2DC,KAA3D,CAAiE,eAAjE,EAV4C,CAY5C;;IACA,IAAAH,uCAAA,EAA4B,YAA5B,EAA0C,IAA1C,EAAgDC,uBAAhD,EAA0DC,MAA1D,CAAiEC,KAAjE,CAAuE,eAAvE;EACA,CAdC,CAAF;AAeA,CAhBO,CAAR"}
1
+ {"version":3,"file":"formatIncompletePhoneNumber.test.js","names":["describe","it","result","formatIncompletePhoneNumber","metadata","should","equal","defaultCountry","defaultCallingCode"],"sources":["../source/formatIncompletePhoneNumber.test.js"],"sourcesContent":["import formatIncompletePhoneNumber from './formatIncompletePhoneNumber.js'\r\n\r\nimport metadata from '../metadata.min.json' assert { type: 'json' }\r\n\r\ndescribe('formatIncompletePhoneNumber', () => {\r\n\tit('should format parsed input value', () => {\r\n\t\tlet result\r\n\r\n\t\t// National input.\r\n\t\tformatIncompletePhoneNumber('880055535', 'RU', metadata).should.equal('8 (800) 555-35')\r\n\r\n\t\t// International input, no country.\r\n\t\tformatIncompletePhoneNumber('+780055535', null, metadata).should.equal('+7 800 555 35')\r\n\r\n\t\t// International input, no country argument.\r\n\t\tformatIncompletePhoneNumber('+780055535', metadata).should.equal('+7 800 555 35')\r\n\r\n\t\t// International input, with country.\r\n\t\tformatIncompletePhoneNumber('+780055535', 'RU', metadata).should.equal('+7 800 555 35')\r\n\t})\r\n\r\n\tit('should support an object argument', () => {\r\n\t\tformatIncompletePhoneNumber('880055535', { defaultCountry: 'RU' }, metadata).should.equal('8 (800) 555-35')\r\n\t\tformatIncompletePhoneNumber('880055535', { defaultCallingCode: '7' }, metadata).should.equal('8 (800) 555-35')\r\n\t})\r\n})"],"mappings":";;AAAA;;AAEA;;;;AAEAA,QAAQ,CAAC,6BAAD,EAAgC,YAAM;EAC7CC,EAAE,CAAC,kCAAD,EAAqC,YAAM;IAC5C,IAAIC,MAAJ,CAD4C,CAG5C;;IACA,IAAAC,uCAAA,EAA4B,WAA5B,EAAyC,IAAzC,EAA+CC,uBAA/C,EAAyDC,MAAzD,CAAgEC,KAAhE,CAAsE,gBAAtE,EAJ4C,CAM5C;;IACA,IAAAH,uCAAA,EAA4B,YAA5B,EAA0C,IAA1C,EAAgDC,uBAAhD,EAA0DC,MAA1D,CAAiEC,KAAjE,CAAuE,eAAvE,EAP4C,CAS5C;;IACA,IAAAH,uCAAA,EAA4B,YAA5B,EAA0CC,uBAA1C,EAAoDC,MAApD,CAA2DC,KAA3D,CAAiE,eAAjE,EAV4C,CAY5C;;IACA,IAAAH,uCAAA,EAA4B,YAA5B,EAA0C,IAA1C,EAAgDC,uBAAhD,EAA0DC,MAA1D,CAAiEC,KAAjE,CAAuE,eAAvE;EACA,CAdC,CAAF;EAgBAL,EAAE,CAAC,mCAAD,EAAsC,YAAM;IAC7C,IAAAE,uCAAA,EAA4B,WAA5B,EAAyC;MAAEI,cAAc,EAAE;IAAlB,CAAzC,EAAmEH,uBAAnE,EAA6EC,MAA7E,CAAoFC,KAApF,CAA0F,gBAA1F;IACA,IAAAH,uCAAA,EAA4B,WAA5B,EAAyC;MAAEK,kBAAkB,EAAE;IAAtB,CAAzC,EAAsEJ,uBAAtE,EAAgFC,MAAhF,CAAuFC,KAAvF,CAA6F,gBAA7F;EACA,CAHC,CAAF;AAIA,CArBO,CAAR"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = isObject;
7
+ var objectConstructor = {}.constructor;
8
+
9
+ function isObject(object) {
10
+ return object !== undefined && object !== null && object.constructor === objectConstructor;
11
+ }
12
+ //# sourceMappingURL=isObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isObject.js","names":["objectConstructor","constructor","isObject","object","undefined"],"sources":["../../source/helpers/isObject.js"],"sourcesContent":["const objectConstructor = {}.constructor;\r\n\r\nexport default function isObject(object) {\r\n return object !== undefined && object !== null && object.constructor === objectConstructor;\r\n}\r\n"],"mappings":";;;;;;AAAA,IAAMA,iBAAiB,GAAG,GAAGC,WAA7B;;AAEe,SAASC,QAAT,CAAkBC,MAAlB,EAA0B;EACvC,OAAOA,MAAM,KAAKC,SAAX,IAAwBD,MAAM,KAAK,IAAnC,IAA2CA,MAAM,CAACF,WAAP,KAAuBD,iBAAzE;AACD"}
@@ -9,9 +9,9 @@ var _format = _interopRequireDefault(require("../format.js"));
9
9
 
10
10
  var _parse = _interopRequireDefault(require("../parse.js"));
11
11
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+ var _isObject = _interopRequireDefault(require("../helpers/isObject.js"));
13
13
 
14
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
15
 
16
16
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
17
 
@@ -91,7 +91,7 @@ function normalizeArguments(args) {
91
91
  }
92
92
  } // If the phone number is passed as a parsed number object.
93
93
  // `format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', [options], metadata)`.
94
- else if (is_object(arg_1)) {
94
+ else if ((0, _isObject["default"])(arg_1)) {
95
95
  input = arg_1;
96
96
  format = arg_2;
97
97
 
@@ -116,13 +116,5 @@ function normalizeArguments(args) {
116
116
  options: options,
117
117
  metadata: metadata
118
118
  };
119
- } // Babel transforms `typeof` into some "branches"
120
- // so istanbul will show this as "branch not covered".
121
-
122
- /* istanbul ignore next */
123
-
124
-
125
- var is_object = function is_object(_) {
126
- return _typeof(_) === 'object';
127
- };
119
+ }
128
120
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","names":["formatNumber","normalizeArguments","arguments","input","format","options","metadata","_formatNumber","args","Array","prototype","slice","call","arg_1","arg_2","arg_3","arg_4","arg_5","parse","defaultCountry","extended","Error","is_object","TypeError","_"],"sources":["../../source/legacy/format.js"],"sourcesContent":["import _formatNumber from '../format.js'\r\nimport parse from '../parse.js'\r\n\r\nexport default function formatNumber() {\r\n\tconst {\r\n\t\tinput,\r\n\t\tformat,\r\n\t\toptions,\r\n\t\tmetadata\r\n\t} = normalizeArguments(arguments)\r\n\r\n\treturn _formatNumber(input, format, options, metadata)\r\n}\r\n\r\n// Sort out arguments\r\nfunction normalizeArguments(args)\r\n{\r\n\tconst [arg_1, arg_2, arg_3, arg_4, arg_5] = Array.prototype.slice.call(args)\r\n\r\n\tlet input\r\n\tlet format\r\n\tlet options\r\n\tlet metadata\r\n\r\n\t// Sort out arguments.\r\n\r\n\t// If the phone number is passed as a string.\r\n\t// `format('8005553535', ...)`.\r\n\tif (typeof arg_1 === 'string')\r\n\t{\r\n\t\t// If country code is supplied.\r\n\t\t// `format('8005553535', 'RU', 'NATIONAL', [options], metadata)`.\r\n\t\tif (typeof arg_3 === 'string')\r\n\t\t{\r\n\t\t\tformat = arg_3\r\n\r\n\t\t\tif (arg_5)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_4\r\n\t\t\t\tmetadata = arg_5\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_4\r\n\t\t\t}\r\n\r\n\t\t\tinput = parse(arg_1, { defaultCountry: arg_2, extended: true }, metadata)\r\n\t\t}\r\n\t\t// Just an international phone number is supplied\r\n\t\t// `format('+78005553535', 'NATIONAL', [options], metadata)`.\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (typeof arg_2 !== 'string')\r\n\t\t\t{\r\n\t\t\t\tthrow new Error('`format` argument not passed to `formatNumber(number, format)`')\r\n\t\t\t}\r\n\r\n\t\t\tformat = arg_2\r\n\r\n\t\t\tif (arg_4)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_3\r\n\t\t\t\tmetadata = arg_4\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_3\r\n\t\t\t}\r\n\r\n\t\t\tinput = parse(arg_1, { extended: true }, metadata)\r\n\t\t}\r\n\t}\r\n\t// If the phone number is passed as a parsed number object.\r\n\t// `format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', [options], metadata)`.\r\n\telse if (is_object(arg_1))\r\n\t{\r\n\t\tinput = arg_1\r\n\t\tformat = arg_2\r\n\r\n\t\tif (arg_4)\r\n\t\t{\r\n\t\t\toptions = arg_3\r\n\t\t\tmetadata = arg_4\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmetadata = arg_3\r\n\t\t}\r\n\t}\r\n\telse throw new TypeError('A phone number must either be a string or an object of shape { phone, [country] }.')\r\n\r\n\t// Legacy lowercase formats.\r\n\tif (format === 'International') {\r\n\t\tformat = 'INTERNATIONAL'\r\n\t} else if (format === 'National') {\r\n\t\tformat = 'NATIONAL'\r\n\t}\r\n\r\n\treturn {\r\n\t\tinput,\r\n\t\tformat,\r\n\t\toptions,\r\n\t\tmetadata\r\n\t}\r\n}\r\n\r\n// Babel transforms `typeof` into some \"branches\"\r\n// so istanbul will show this as \"branch not covered\".\r\n/* istanbul ignore next */\r\nconst is_object = _ => typeof _ === 'object'"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;;;;;;;;;;;AAEe,SAASA,YAAT,GAAwB;EACtC,0BAKIC,kBAAkB,CAACC,SAAD,CALtB;EAAA,IACCC,KADD,uBACCA,KADD;EAAA,IAECC,MAFD,uBAECA,MAFD;EAAA,IAGCC,OAHD,uBAGCA,OAHD;EAAA,IAICC,QAJD,uBAICA,QAJD;;EAOA,OAAO,IAAAC,kBAAA,EAAcJ,KAAd,EAAqBC,MAArB,EAA6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AAb,EACL;IACCV,KAAK,GAAIU,KAAT;IACAT,MAAM,GAAGU,KAAT;;IAEA,IAAIE,KAAJ,EACA;MACCX,OAAO,GAAIU,KAAX;MACAT,QAAQ,GAAGU,KAAX;IACA,CAJD,MAMA;MACCV,QAAQ,GAAGS,KAAX;IACA;EACD,CAdI,MAeA,MAAM,IAAIQ,SAAJ,CAAc,oFAAd,CAAN,CAzEN,CA2EC;;;EACA,IAAInB,MAAM,KAAK,eAAf,EAAgC;IAC/BA,MAAM,GAAG,eAAT;EACA,CAFD,MAEO,IAAIA,MAAM,KAAK,UAAf,EAA2B;IACjCA,MAAM,GAAG,UAAT;EACA;;EAED,OAAO;IACND,KAAK,EAALA,KADM;IAENC,MAAM,EAANA,MAFM;IAGNC,OAAO,EAAPA,OAHM;IAINC,QAAQ,EAARA;EAJM,CAAP;AAMA,C,CAED;AACA;;AACA;;;AACA,IAAMgB,SAAS,GAAG,SAAZA,SAAY,CAAAE,CAAC;EAAA,OAAI,QAAOA,CAAP,MAAa,QAAjB;AAAA,CAAnB"}
1
+ {"version":3,"file":"format.js","names":["formatNumber","normalizeArguments","arguments","input","format","options","metadata","_formatNumber","args","Array","prototype","slice","call","arg_1","arg_2","arg_3","arg_4","arg_5","parse","defaultCountry","extended","Error","isObject","TypeError"],"sources":["../../source/legacy/format.js"],"sourcesContent":["import _formatNumber from '../format.js'\r\nimport parse from '../parse.js'\r\nimport isObject from '../helpers/isObject.js'\r\n\r\nexport default function formatNumber() {\r\n\tconst {\r\n\t\tinput,\r\n\t\tformat,\r\n\t\toptions,\r\n\t\tmetadata\r\n\t} = normalizeArguments(arguments)\r\n\r\n\treturn _formatNumber(input, format, options, metadata)\r\n}\r\n\r\n// Sort out arguments\r\nfunction normalizeArguments(args)\r\n{\r\n\tconst [arg_1, arg_2, arg_3, arg_4, arg_5] = Array.prototype.slice.call(args)\r\n\r\n\tlet input\r\n\tlet format\r\n\tlet options\r\n\tlet metadata\r\n\r\n\t// Sort out arguments.\r\n\r\n\t// If the phone number is passed as a string.\r\n\t// `format('8005553535', ...)`.\r\n\tif (typeof arg_1 === 'string')\r\n\t{\r\n\t\t// If country code is supplied.\r\n\t\t// `format('8005553535', 'RU', 'NATIONAL', [options], metadata)`.\r\n\t\tif (typeof arg_3 === 'string')\r\n\t\t{\r\n\t\t\tformat = arg_3\r\n\r\n\t\t\tif (arg_5)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_4\r\n\t\t\t\tmetadata = arg_5\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_4\r\n\t\t\t}\r\n\r\n\t\t\tinput = parse(arg_1, { defaultCountry: arg_2, extended: true }, metadata)\r\n\t\t}\r\n\t\t// Just an international phone number is supplied\r\n\t\t// `format('+78005553535', 'NATIONAL', [options], metadata)`.\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (typeof arg_2 !== 'string')\r\n\t\t\t{\r\n\t\t\t\tthrow new Error('`format` argument not passed to `formatNumber(number, format)`')\r\n\t\t\t}\r\n\r\n\t\t\tformat = arg_2\r\n\r\n\t\t\tif (arg_4)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_3\r\n\t\t\t\tmetadata = arg_4\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_3\r\n\t\t\t}\r\n\r\n\t\t\tinput = parse(arg_1, { extended: true }, metadata)\r\n\t\t}\r\n\t}\r\n\t// If the phone number is passed as a parsed number object.\r\n\t// `format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', [options], metadata)`.\r\n\telse if (isObject(arg_1))\r\n\t{\r\n\t\tinput = arg_1\r\n\t\tformat = arg_2\r\n\r\n\t\tif (arg_4)\r\n\t\t{\r\n\t\t\toptions = arg_3\r\n\t\t\tmetadata = arg_4\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmetadata = arg_3\r\n\t\t}\r\n\t}\r\n\telse throw new TypeError('A phone number must either be a string or an object of shape { phone, [country] }.')\r\n\r\n\t// Legacy lowercase formats.\r\n\tif (format === 'International') {\r\n\t\tformat = 'INTERNATIONAL'\r\n\t} else if (format === 'National') {\r\n\t\tformat = 'NATIONAL'\r\n\t}\r\n\r\n\treturn {\r\n\t\tinput,\r\n\t\tformat,\r\n\t\toptions,\r\n\t\tmetadata\r\n\t}\r\n}"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEe,SAASA,YAAT,GAAwB;EACtC,0BAKIC,kBAAkB,CAACC,SAAD,CALtB;EAAA,IACCC,KADD,uBACCA,KADD;EAAA,IAECC,MAFD,uBAECA,MAFD;EAAA,IAGCC,OAHD,uBAGCA,OAHD;EAAA,IAICC,QAJD,uBAICA,QAJD;;EAOA,OAAO,IAAAC,kBAAA,EAAcJ,KAAd,EAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,QAAtC,CAAP;AACA,C,CAED;;;AACA,SAASL,kBAAT,CAA4BO,IAA5B,EACA;EACC,4BAA4CC,KAAK,CAACC,SAAN,CAAgBC,KAAhB,CAAsBC,IAAtB,CAA2BJ,IAA3B,CAA5C;EAAA;EAAA,IAAOK,KAAP;EAAA,IAAcC,KAAd;EAAA,IAAqBC,KAArB;EAAA,IAA4BC,KAA5B;EAAA,IAAmCC,KAAnC;;EAEA,IAAId,KAAJ;EACA,IAAIC,MAAJ;EACA,IAAIC,OAAJ;EACA,IAAIC,QAAJ,CAND,CAQC;EAEA;EACA;;EACA,IAAI,OAAOO,KAAP,KAAiB,QAArB,EACA;IACC;IACA;IACA,IAAI,OAAOE,KAAP,KAAiB,QAArB,EACA;MACCX,MAAM,GAAGW,KAAT;;MAEA,IAAIE,KAAJ,EACA;QACCZ,OAAO,GAAIW,KAAX;QACAV,QAAQ,GAAGW,KAAX;MACA,CAJD,MAMA;QACCX,QAAQ,GAAGU,KAAX;MACA;;MAEDb,KAAK,GAAG,IAAAe,iBAAA,EAAML,KAAN,EAAa;QAAEM,cAAc,EAAEL,KAAlB;QAAyBM,QAAQ,EAAE;MAAnC,CAAb,EAAwDd,QAAxD,CAAR;IACA,CAfD,CAgBA;IACA;IAjBA,KAmBA;MACC,IAAI,OAAOQ,KAAP,KAAiB,QAArB,EACA;QACC,MAAM,IAAIO,KAAJ,CAAU,gEAAV,CAAN;MACA;;MAEDjB,MAAM,GAAGU,KAAT;;MAEA,IAAIE,KAAJ,EACA;QACCX,OAAO,GAAIU,KAAX;QACAT,QAAQ,GAAGU,KAAX;MACA,CAJD,MAMA;QACCV,QAAQ,GAAGS,KAAX;MACA;;MAEDZ,KAAK,GAAG,IAAAe,iBAAA,EAAML,KAAN,EAAa;QAAEO,QAAQ,EAAE;MAAZ,CAAb,EAAiCd,QAAjC,CAAR;IACA;EACD,CA3CD,CA4CA;EACA;EA7CA,KA8CK,IAAI,IAAAgB,oBAAA,EAAST,KAAT,CAAJ,EACL;IACCV,KAAK,GAAIU,KAAT;IACAT,MAAM,GAAGU,KAAT;;IAEA,IAAIE,KAAJ,EACA;MACCX,OAAO,GAAIU,KAAX;MACAT,QAAQ,GAAGU,KAAX;IACA,CAJD,MAMA;MACCV,QAAQ,GAAGS,KAAX;IACA;EACD,CAdI,MAeA,MAAM,IAAIQ,SAAJ,CAAc,oFAAd,CAAN,CAzEN,CA2EC;;;EACA,IAAInB,MAAM,KAAK,eAAf,EAAgC;IAC/BA,MAAM,GAAG,eAAT;EACA,CAFD,MAEO,IAAIA,MAAM,KAAK,UAAf,EAA2B;IACjCA,MAAM,GAAG,UAAT;EACA;;EAED,OAAO;IACND,KAAK,EAALA,KADM;IAENC,MAAM,EAANA,MAFM;IAGNC,OAAO,EAAPA,OAHM;IAINC,QAAQ,EAARA;EAJM,CAAP;AAMA"}
@@ -10,12 +10,12 @@ var _isViablePhoneNumber = _interopRequireDefault(require("../helpers/isViablePh
10
10
 
11
11
  var _getNumberType2 = _interopRequireDefault(require("../helpers/getNumberType.js"));
12
12
 
13
+ var _isObject = _interopRequireDefault(require("../helpers/isObject.js"));
14
+
13
15
  var _parse = _interopRequireDefault(require("../parse.js"));
14
16
 
15
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
18
 
17
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
18
-
19
19
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
20
20
 
21
21
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -61,7 +61,7 @@ function normalizeArguments(args) {
61
61
  // If "default country" argument is being passed
62
62
  // then convert it to an `options` object.
63
63
  // `getNumberType('88005553535', 'RU', metadata)`.
64
- if (_typeof(arg_2) !== 'object') {
64
+ if (!(0, _isObject["default"])(arg_2)) {
65
65
  if (arg_4) {
66
66
  options = arg_3;
67
67
  metadata = arg_4;
@@ -105,7 +105,7 @@ function normalizeArguments(args) {
105
105
  }
106
106
  } // If the phone number is passed as a parsed phone number.
107
107
  // `getNumberType({ phone: '88005553535', country: 'RU' }, ...)`.
108
- else if (is_object(arg_1)) {
108
+ else if ((0, _isObject["default"])(arg_1)) {
109
109
  input = arg_1;
110
110
 
111
111
  if (arg_3) {
@@ -121,13 +121,5 @@ function normalizeArguments(args) {
121
121
  options: options,
122
122
  metadata: metadata
123
123
  };
124
- } // Babel transforms `typeof` into some "branches"
125
- // so istanbul will show this as "branch not covered".
126
-
127
- /* istanbul ignore next */
128
-
129
-
130
- var is_object = function is_object(_) {
131
- return _typeof(_) === 'object';
132
- };
124
+ }
133
125
  //# sourceMappingURL=getNumberType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNumberType.js","names":["getNumberType","normalizeArguments","arguments","input","options","metadata","phone","_getNumberType","args","Array","prototype","slice","call","arg_1","arg_2","arg_3","arg_4","isViablePhoneNumber","parse","defaultCountry","undefined","is_object","TypeError","_"],"sources":["../../source/legacy/getNumberType.js"],"sourcesContent":["import isViablePhoneNumber from '../helpers/isViablePhoneNumber.js'\r\nimport _getNumberType from '../helpers/getNumberType.js'\r\nimport parse from '../parse.js'\r\n\r\n// Finds out national phone number type (fixed line, mobile, etc)\r\nexport default function getNumberType() {\r\n\tconst { input, options, metadata } = normalizeArguments(arguments)\r\n\t// `parseNumber()` would return `{}` when no phone number could be parsed from the input.\r\n\tif (!input.phone) {\r\n\t\treturn\r\n\t}\r\n\treturn _getNumberType(input, options, metadata)\r\n}\r\n\r\n// Sort out arguments\r\nexport function normalizeArguments(args)\r\n{\r\n\tconst [arg_1, arg_2, arg_3, arg_4] = Array.prototype.slice.call(args)\r\n\r\n\tlet input\r\n\tlet options = {}\r\n\tlet metadata\r\n\r\n\t// If the phone number is passed as a string.\r\n\t// `getNumberType('88005553535', ...)`.\r\n\tif (typeof arg_1 === 'string')\r\n\t{\r\n\t\t// If \"default country\" argument is being passed\r\n\t\t// then convert it to an `options` object.\r\n\t\t// `getNumberType('88005553535', 'RU', metadata)`.\r\n\t\tif (typeof arg_2 !== 'object')\r\n\t\t{\r\n\t\t\tif (arg_4)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_3\r\n\t\t\t\tmetadata = arg_4\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_3\r\n\t\t\t}\r\n\r\n\t\t\t// `parse` extracts phone numbers from raw text,\r\n\t\t\t// therefore it will cut off all \"garbage\" characters,\r\n\t\t\t// while this `validate` function needs to verify\r\n\t\t\t// that the phone number contains no \"garbage\"\r\n\t\t\t// therefore the explicit `isViablePhoneNumber` check.\r\n\t\t\tif (isViablePhoneNumber(arg_1))\r\n\t\t\t{\r\n\t\t\t\tinput = parse(arg_1, { defaultCountry: arg_2 }, metadata)\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tinput = {}\r\n\t\t\t}\r\n\t\t}\r\n\t\t// No \"resrict country\" argument is being passed.\r\n\t\t// International phone number is passed.\r\n\t\t// `getNumberType('+78005553535', metadata)`.\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (arg_3)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_2\r\n\t\t\t\tmetadata = arg_3\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_2\r\n\t\t\t}\r\n\r\n\t\t\t// `parse` extracts phone numbers from raw text,\r\n\t\t\t// therefore it will cut off all \"garbage\" characters,\r\n\t\t\t// while this `validate` function needs to verify\r\n\t\t\t// that the phone number contains no \"garbage\"\r\n\t\t\t// therefore the explicit `isViablePhoneNumber` check.\r\n\t\t\tif (isViablePhoneNumber(arg_1))\r\n\t\t\t{\r\n\t\t\t\tinput = parse(arg_1, undefined, metadata)\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tinput = {}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t// If the phone number is passed as a parsed phone number.\r\n\t// `getNumberType({ phone: '88005553535', country: 'RU' }, ...)`.\r\n\telse if (is_object(arg_1))\r\n\t{\r\n\t\tinput = arg_1\r\n\r\n\t\tif (arg_3)\r\n\t\t{\r\n\t\t\toptions = arg_2\r\n\t\t\tmetadata = arg_3\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmetadata = arg_2\r\n\t\t}\r\n\t}\r\n\telse throw new TypeError('A phone number must either be a string or an object of shape { phone, [country] }.')\r\n\r\n\treturn {\r\n\t\tinput,\r\n\t\toptions,\r\n\t\tmetadata\r\n\t}\r\n}\r\n\r\n// Babel transforms `typeof` into some \"branches\"\r\n// so istanbul will show this as \"branch not covered\".\r\n/* istanbul ignore next */\r\nconst is_object = _ => typeof _ === 'object'"],"mappings":";;;;;;;;AAAA;;AACA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AQ,GAAGU,KAAX;MACA,CAJD,MAMA;QACCV,QAAQ,GAAGS,KAAX;MACA,CATF,CAWC;MACA;MACA;MACA;MACA;;;MACA,IAAI,IAAAG,+BAAA,EAAoBJ,KAApB,CAAJ,EACA;QACCV,KAAK,GAAG,IAAAe,iBAAA,EAAML,KAAN,EAAaO,SAAb,EAAwBf,QAAxB,CAAR;MACA,CAHD,MAKA;QACCF,KAAK,GAAG,EAAR;MACA;IACD;EACD,CA5DD,CA6DA;EACA;EA9DA,KA+DK,IAAIkB,SAAS,CAACR,KAAD,CAAb,EACL;IACCV,KAAK,GAAGU,KAAR;;IAEA,IAAIE,KAAJ,EACA;MACCX,OAAO,GAAGU,KAAV;MACAT,QAAQ,GAAGU,KAAX;IACA,CAJD,MAMA;MACCV,QAAQ,GAAGS,KAAX;IACA;EACD,CAbI,MAcA,MAAM,IAAIQ,SAAJ,CAAc,oFAAd,CAAN;;EAEL,OAAO;IACNnB,KAAK,EAALA,KADM;IAENC,OAAO,EAAPA,OAFM;IAGNC,QAAQ,EAARA;EAHM,CAAP;AAKA,C,CAED;AACA;;AACA;;;AACA,IAAMgB,SAAS,GAAG,SAAZA,SAAY,CAAAE,CAAC;EAAA,OAAI,QAAOA,CAAP,MAAa,QAAjB;AAAA,CAAnB"}
1
+ {"version":3,"file":"getNumberType.js","names":["getNumberType","normalizeArguments","arguments","input","options","metadata","phone","_getNumberType","args","Array","prototype","slice","call","arg_1","arg_2","arg_3","arg_4","isObject","isViablePhoneNumber","parse","defaultCountry","undefined","TypeError"],"sources":["../../source/legacy/getNumberType.js"],"sourcesContent":["import isViablePhoneNumber from '../helpers/isViablePhoneNumber.js'\r\nimport _getNumberType from '../helpers/getNumberType.js'\r\nimport isObject from '../helpers/isObject.js'\r\nimport parse from '../parse.js'\r\n\r\n// Finds out national phone number type (fixed line, mobile, etc)\r\nexport default function getNumberType() {\r\n\tconst { input, options, metadata } = normalizeArguments(arguments)\r\n\t// `parseNumber()` would return `{}` when no phone number could be parsed from the input.\r\n\tif (!input.phone) {\r\n\t\treturn\r\n\t}\r\n\treturn _getNumberType(input, options, metadata)\r\n}\r\n\r\n// Sort out arguments\r\nexport function normalizeArguments(args)\r\n{\r\n\tconst [arg_1, arg_2, arg_3, arg_4] = Array.prototype.slice.call(args)\r\n\r\n\tlet input\r\n\tlet options = {}\r\n\tlet metadata\r\n\r\n\t// If the phone number is passed as a string.\r\n\t// `getNumberType('88005553535', ...)`.\r\n\tif (typeof arg_1 === 'string')\r\n\t{\r\n\t\t// If \"default country\" argument is being passed\r\n\t\t// then convert it to an `options` object.\r\n\t\t// `getNumberType('88005553535', 'RU', metadata)`.\r\n\t\tif (!isObject(arg_2))\r\n\t\t{\r\n\t\t\tif (arg_4)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_3\r\n\t\t\t\tmetadata = arg_4\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_3\r\n\t\t\t}\r\n\r\n\t\t\t// `parse` extracts phone numbers from raw text,\r\n\t\t\t// therefore it will cut off all \"garbage\" characters,\r\n\t\t\t// while this `validate` function needs to verify\r\n\t\t\t// that the phone number contains no \"garbage\"\r\n\t\t\t// therefore the explicit `isViablePhoneNumber` check.\r\n\t\t\tif (isViablePhoneNumber(arg_1))\r\n\t\t\t{\r\n\t\t\t\tinput = parse(arg_1, { defaultCountry: arg_2 }, metadata)\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tinput = {}\r\n\t\t\t}\r\n\t\t}\r\n\t\t// No \"resrict country\" argument is being passed.\r\n\t\t// International phone number is passed.\r\n\t\t// `getNumberType('+78005553535', metadata)`.\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (arg_3)\r\n\t\t\t{\r\n\t\t\t\toptions = arg_2\r\n\t\t\t\tmetadata = arg_3\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmetadata = arg_2\r\n\t\t\t}\r\n\r\n\t\t\t// `parse` extracts phone numbers from raw text,\r\n\t\t\t// therefore it will cut off all \"garbage\" characters,\r\n\t\t\t// while this `validate` function needs to verify\r\n\t\t\t// that the phone number contains no \"garbage\"\r\n\t\t\t// therefore the explicit `isViablePhoneNumber` check.\r\n\t\t\tif (isViablePhoneNumber(arg_1))\r\n\t\t\t{\r\n\t\t\t\tinput = parse(arg_1, undefined, metadata)\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tinput = {}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t// If the phone number is passed as a parsed phone number.\r\n\t// `getNumberType({ phone: '88005553535', country: 'RU' }, ...)`.\r\n\telse if (isObject(arg_1))\r\n\t{\r\n\t\tinput = arg_1\r\n\r\n\t\tif (arg_3)\r\n\t\t{\r\n\t\t\toptions = arg_2\r\n\t\t\tmetadata = arg_3\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmetadata = arg_2\r\n\t\t}\r\n\t}\r\n\telse throw new TypeError('A phone number must either be a string or an object of shape { phone, [country] }.')\r\n\r\n\treturn {\r\n\t\tinput,\r\n\t\toptions,\r\n\t\tmetadata\r\n\t}\r\n}"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEA;AACe,SAASA,aAAT,GAAyB;EACvC,0BAAqCC,kBAAkB,CAACC,SAAD,CAAvD;EAAA,IAAQC,KAAR,uBAAQA,KAAR;EAAA,IAAeC,OAAf,uBAAeA,OAAf;EAAA,IAAwBC,QAAxB,uBAAwBA,QAAxB,CADuC,CAEvC;;;EACA,IAAI,CAACF,KAAK,CAACG,KAAX,EAAkB;IACjB;EACA;;EACD,OAAO,IAAAC,0BAAA,EAAeJ,KAAf,EAAsBC,OAAtB,EAA+BC,QAA/B,CAAP;AACA,C,CAED;;;AACO,SAASJ,kBAAT,CAA4BO,IAA5B,EACP;EACC,4BAAqCC,KAAK,CAACC,SAAN,CAAgBC,KAAhB,CAAsBC,IAAtB,CAA2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GU,KAAX;IACA,CAJD,MAMA;MACCV,QAAQ,GAAGS,KAAX;IACA;EACD,CAbI,MAcA,MAAM,IAAIQ,SAAJ,CAAc,oFAAd,CAAN;;EAEL,OAAO;IACNnB,KAAK,EAALA,KADM;IAENC,OAAO,EAAPA,OAFM;IAGNC,QAAQ,EAARA;EAHM,CAAP;AAKA"}
package/build/metadata.js CHANGED
@@ -11,6 +11,8 @@ exports.validateMetadata = validateMetadata;
11
11
 
12
12
  var _semverCompare = _interopRequireDefault(require("./tools/semver-compare.js"));
13
13
 
14
+ var _isObject = _interopRequireDefault(require("./helpers/isObject.js"));
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
17
 
16
18
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
@@ -585,8 +587,8 @@ function validateMetadata(metadata) {
585
587
  // `country_calling_codes` in `1.0.18`.
586
588
 
587
589
 
588
- if (!is_object(metadata) || !is_object(metadata.countries)) {
589
- throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(is_object(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + type_of(metadata) + ': ' + metadata, "."));
590
+ if (!(0, _isObject["default"])(metadata) || !(0, _isObject["default"])(metadata.countries)) {
591
+ throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat((0, _isObject["default"])(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + typeOf(metadata) + ': ' + metadata, "."));
590
592
  }
591
593
  } // Babel transforms `typeof` into some "branches"
592
594
  // so istanbul will show this as "branch not covered".
@@ -594,15 +596,7 @@ function validateMetadata(metadata) {
594
596
  /* istanbul ignore next */
595
597
 
596
598
 
597
- var is_object = function is_object(_) {
598
- return _typeof(_) === 'object';
599
- }; // Babel transforms `typeof` into some "branches"
600
- // so istanbul will show this as "branch not covered".
601
-
602
- /* istanbul ignore next */
603
-
604
-
605
- var type_of = function type_of(_) {
599
+ var typeOf = function typeOf(_) {
606
600
  return _typeof(_);
607
601
  };
608
602
  /**