@phonecheck/phone-number-validator-js 1.7.0 → 1.7.1

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.
@@ -835,9 +835,9 @@
835
835
  return new RegExp('^(?:' + regularExpressionText + ')$').test(text);
836
836
  }
837
837
 
838
- function _createForOfIteratorHelperLoose$7(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$a(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
839
- function _unsupportedIterableToArray$a(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$a(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$a(r, a) : void 0; } }
840
- function _arrayLikeToArray$a(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
838
+ function _createForOfIteratorHelperLoose$8(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$b(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
839
+ function _unsupportedIterableToArray$b(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$b(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$b(r, a) : void 0; } }
840
+ function _arrayLikeToArray$b(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
841
841
  var NON_FIXED_LINE_PHONE_TYPES = ['MOBILE', 'PREMIUM_RATE', 'TOLL_FREE', 'SHARED_COST', 'VOIP', 'PERSONAL_NUMBER', 'PAGER', 'UAN', 'VOICEMAIL'];
842
842
 
843
843
  // Finds out national phone number type (fixed line, mobile, etc)
@@ -893,7 +893,7 @@
893
893
  }
894
894
  return 'FIXED_LINE';
895
895
  }
896
- for (var _iterator = _createForOfIteratorHelperLoose$7(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
896
+ for (var _iterator = _createForOfIteratorHelperLoose$8(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
897
897
  var type = _step.value;
898
898
  if (isNumberTypeEqualTo(nationalNumber, type, metadata)) {
899
899
  return type;
@@ -1156,9 +1156,9 @@
1156
1156
  };
1157
1157
  }
1158
1158
 
1159
- function _createForOfIteratorHelperLoose$6(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$9(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1160
- function _unsupportedIterableToArray$9(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$9(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$9(r, a) : void 0; } }
1161
- function _arrayLikeToArray$9(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1159
+ function _createForOfIteratorHelperLoose$7(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$a(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1160
+ function _unsupportedIterableToArray$a(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$a(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$a(r, a) : void 0; } }
1161
+ function _arrayLikeToArray$a(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1162
1162
 
1163
1163
  // Returns the exact country that the `nationalPhoneNumber` belongs to
1164
1164
  // in cases of ambiguity, i.e. when multiple countries share the same "country calling code".
@@ -1170,7 +1170,7 @@
1170
1170
 
1171
1171
  // const matchingCountries = []
1172
1172
 
1173
- for (var _iterator = _createForOfIteratorHelperLoose$6(countries), _step; !(_step = _iterator()).done;) {
1173
+ for (var _iterator = _createForOfIteratorHelperLoose$7(countries), _step; !(_step = _iterator()).done;) {
1174
1174
  var country = _step.value;
1175
1175
  metadata.selectNumberingPlan(country);
1176
1176
  // "Leading digits" patterns are only defined for about 20% of all countries.
@@ -1797,13 +1797,13 @@
1797
1797
  return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
1798
1798
  }
1799
1799
 
1800
- function _slicedToArray$3(r, e) { return _arrayWithHoles$3(r) || _iterableToArrayLimit$3(r, e) || _unsupportedIterableToArray$8(r, e) || _nonIterableRest$3(); }
1800
+ function _slicedToArray$3(r, e) { return _arrayWithHoles$3(r) || _iterableToArrayLimit$3(r, e) || _unsupportedIterableToArray$9(r, e) || _nonIterableRest$3(); }
1801
1801
  function _nonIterableRest$3() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1802
1802
  function _iterableToArrayLimit$3(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = true, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
1803
1803
  function _arrayWithHoles$3(r) { if (Array.isArray(r)) return r; }
1804
- function _createForOfIteratorHelperLoose$5(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$8(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1805
- function _unsupportedIterableToArray$8(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$8(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$8(r, a) : void 0; } }
1806
- function _arrayLikeToArray$8(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1804
+ function _createForOfIteratorHelperLoose$6(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$9(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1805
+ function _unsupportedIterableToArray$9(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$9(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$9(r, a) : void 0; } }
1806
+ function _arrayLikeToArray$9(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1807
1807
 
1808
1808
  // https://www.ietf.org/rfc/rfc3966.txt
1809
1809
 
@@ -1817,7 +1817,7 @@
1817
1817
 
1818
1818
  // Replace "tel:" with "tel=" for parsing convenience.
1819
1819
  text = text.replace(/^tel:/, 'tel=');
1820
- for (var _iterator = _createForOfIteratorHelperLoose$5(text.split(';')), _step; !(_step = _iterator()).done;) {
1820
+ for (var _iterator = _createForOfIteratorHelperLoose$6(text.split(';')), _step; !(_step = _iterator()).done;) {
1821
1821
  var part = _step.value;
1822
1822
  var _part$split = part.split('='),
1823
1823
  _part$split2 = _slicedToArray$3(_part$split, 2),
@@ -2302,9 +2302,9 @@
2302
2302
  }
2303
2303
  }
2304
2304
 
2305
- function _createForOfIteratorHelperLoose$4(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$7(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2306
- function _unsupportedIterableToArray$7(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$7(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$7(r, a) : void 0; } }
2307
- function _arrayLikeToArray$7(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2305
+ function _createForOfIteratorHelperLoose$5(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$8(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2306
+ function _unsupportedIterableToArray$8(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$8(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$8(r, a) : void 0; } }
2307
+ function _arrayLikeToArray$8(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2308
2308
  // These mappings map a character (key) to a specific digit that should
2309
2309
  // replace it for normalization purposes. Non-European digits that
2310
2310
  // may be used in phone numbers are mapped to a European equivalent.
@@ -2407,7 +2407,7 @@
2407
2407
  // (the ones consisting of four bytes) but digits
2408
2408
  // (including non-European ones) don't fall into that range
2409
2409
  // so such "exotic" characters would be discarded anyway.
2410
- for (var _iterator = _createForOfIteratorHelperLoose$4(string.split('')), _step; !(_step = _iterator()).done;) {
2410
+ for (var _iterator = _createForOfIteratorHelperLoose$5(string.split('')), _step; !(_step = _iterator()).done;) {
2411
2411
  var character = _step.value;
2412
2412
  var digit = parseDigit(character);
2413
2413
  if (digit) {
@@ -2417,9 +2417,9 @@
2417
2417
  return result;
2418
2418
  }
2419
2419
 
2420
- function _createForOfIteratorHelperLoose$3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$6(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2421
- function _unsupportedIterableToArray$6(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$6(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$6(r, a) : void 0; } }
2422
- function _arrayLikeToArray$6(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2420
+ function _createForOfIteratorHelperLoose$4(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$7(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2421
+ function _unsupportedIterableToArray$7(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$7(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$7(r, a) : void 0; } }
2422
+ function _arrayLikeToArray$7(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2423
2423
 
2424
2424
  /**
2425
2425
  * Parses phone number characters from a string.
@@ -2444,7 +2444,7 @@
2444
2444
  // (the ones consisting of four bytes) but digits
2445
2445
  // (including non-European ones) don't fall into that range
2446
2446
  // so such "exotic" characters would be discarded anyway.
2447
- for (var _iterator = _createForOfIteratorHelperLoose$3(string.split('')), _step; !(_step = _iterator()).done;) {
2447
+ for (var _iterator = _createForOfIteratorHelperLoose$4(string.split('')), _step; !(_step = _iterator()).done;) {
2448
2448
  var character = _step.value;
2449
2449
  result += parsePhoneNumberCharacter(character, result) || '';
2450
2450
  }
@@ -2960,10 +2960,10 @@
2960
2960
  function _defineProperty$7(e, r, t) { return (r = _toPropertyKey$h(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; }
2961
2961
  function _toPropertyKey$h(t) { var i = _toPrimitive$h(t, "string"); return "symbol" == _typeof$h(i) ? i : i + ""; }
2962
2962
  function _toPrimitive$h(t, r) { if ("object" != _typeof$h(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof$h(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2963
- function _slicedToArray$2(r, e) { return _arrayWithHoles$2(r) || _iterableToArrayLimit$2(r, e) || _unsupportedIterableToArray$5(r, e) || _nonIterableRest$2(); }
2963
+ function _slicedToArray$2(r, e) { return _arrayWithHoles$2(r) || _iterableToArrayLimit$2(r, e) || _unsupportedIterableToArray$6(r, e) || _nonIterableRest$2(); }
2964
2964
  function _nonIterableRest$2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2965
- function _unsupportedIterableToArray$5(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$5(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$5(r, a) : void 0; } }
2966
- function _arrayLikeToArray$5(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2965
+ function _unsupportedIterableToArray$6(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$6(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$6(r, a) : void 0; } }
2966
+ function _arrayLikeToArray$6(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
2967
2967
  function _iterableToArrayLimit$2(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = true, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
2968
2968
  function _arrayWithHoles$2(r) { if (Array.isArray(r)) return r; }
2969
2969
 
@@ -3702,6 +3702,9 @@
3702
3702
  }
3703
3703
 
3704
3704
  function _typeof$a(o) { "@babel/helpers - typeof"; return _typeof$a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$a(o); }
3705
+ function _createForOfIteratorHelperLoose$3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$5(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3706
+ function _unsupportedIterableToArray$5(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$5(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$5(r, a) : void 0; } }
3707
+ function _arrayLikeToArray$5(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
3705
3708
  function _classCallCheck$7(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3706
3709
  function _defineProperties$7(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$a(o.key), o); } }
3707
3710
  function _createClass$7(e, r, t) { return r && _defineProperties$7(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e; }
@@ -3721,7 +3724,7 @@
3721
3724
  */
3722
3725
  var INNER_MATCHES = [
3723
3726
  // Breaks on the slash - e.g. "651-234-2345/332-445-1234"
3724
- '\\/+(.*)/',
3727
+ '/+(.*)',
3725
3728
  // Note that the bracket here is inside the capturing group, since we consider it part of the
3726
3729
  // phone number. Will match a pattern like "(650) 223 3345 (754) 223 3321".
3727
3730
  '(\\([^(]*)', // Breaks on a hyphen - e.g. "12345 - 332-445-1234 is my number."
@@ -3841,7 +3844,12 @@
3841
3844
 
3842
3845
  /** The maximum number of retries after matching an invalid number. */
3843
3846
  this.maxTries = options.maxTries;
3847
+
3848
+ // Compile regular expressions.
3844
3849
  this.PATTERN = new RegExp(PATTERN, 'ig');
3850
+ this.INNER_MATCHES = INNER_MATCHES.map(function (pattern) {
3851
+ return new RegExp(pattern, 'g');
3852
+ });
3845
3853
 
3846
3854
  /** The iteration tristate. */
3847
3855
  this.state = 'NOT_READY';
@@ -3865,10 +3873,9 @@
3865
3873
  */
3866
3874
  return _createClass$7(PhoneNumberMatcher, [{
3867
3875
  key: "find",
3868
- value: function find() {
3869
- // // Reset the regular expression.
3870
- // this.PATTERN.lastIndex = index
3871
-
3876
+ value: function find(index) {
3877
+ // Reset the regular expression.
3878
+ this.PATTERN.lastIndex = index;
3872
3879
  var matches;
3873
3880
  while (this.maxTries > 0 && (matches = this.PATTERN.exec(this.text)) !== null) {
3874
3881
  var candidate = matches[0];
@@ -3921,11 +3928,12 @@
3921
3928
  }, {
3922
3929
  key: "extractInnerMatch",
3923
3930
  value: function extractInnerMatch(substring, offset, text) {
3924
- for (var _i = 0, _INNER_MATCHES = INNER_MATCHES; _i < _INNER_MATCHES.length; _i++) {
3925
- var innerMatchPattern = _INNER_MATCHES[_i];
3931
+ for (var _iterator = _createForOfIteratorHelperLoose$3(this.INNER_MATCHES), _step; !(_step = _iterator()).done;) {
3932
+ var innerMatchRegExp = _step.value;
3933
+ // Reset regular expression.
3934
+ innerMatchRegExp.lastIndex = 0;
3926
3935
  var isFirstMatch = true;
3927
3936
  var candidateMatch = void 0;
3928
- var innerMatchRegExp = new RegExp(innerMatchPattern, 'g');
3929
3937
  while (this.maxTries > 0 && (candidateMatch = innerMatchRegExp.exec(substring)) !== null) {
3930
3938
  if (isFirstMatch) {
3931
3939
  // We should handle any group before this one too.
@@ -3997,10 +4005,9 @@
3997
4005
  key: "hasNext",
3998
4006
  value: function hasNext() {
3999
4007
  if (this.state === 'NOT_READY') {
4000
- this.lastMatch = this.find(); // (this.searchIndex)
4001
-
4008
+ this.lastMatch = this.find(this.searchIndex);
4002
4009
  if (this.lastMatch) {
4003
- // this.searchIndex = this.lastMatch.endsAt
4010
+ this.searchIndex = this.lastMatch.endsAt;
4004
4011
  this.state = 'READY';
4005
4012
  } else {
4006
4013
  this.state = 'DONE';
@@ -6602,7 +6609,17 @@
6602
6609
  function PhoneNumber(number) {
6603
6610
  return PhoneNumber$1.call(this, number, metadata)
6604
6611
  }
6605
- PhoneNumber.prototype = Object.create(PhoneNumber$1.prototype, {});
6612
+ // Setting `PhoneNumber.prototype` via `Object.create()`
6613
+ // didn't work with `instanceof` operator for some strange reason.
6614
+ // https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/201
6615
+ // Because of that issue, the `Object.create()` call had to be removed.
6616
+ // It didn't result in any drawbacks because the `{}` argument of that call
6617
+ // means that the `PhoneNumber` class created here adds 0 new properties
6618
+ // to the existing `PhoneNumber` class it attempts to extend here.
6619
+ // Hence, the `Object.create()` call can be omitted
6620
+ // and the `prototype` can just be copied over as is.
6621
+ // PhoneNumber.prototype = Object.create(_PhoneNumber.prototype, {})
6622
+ PhoneNumber.prototype = PhoneNumber$1.prototype;
6606
6623
  PhoneNumber.prototype.constructor = PhoneNumber;
6607
6624
 
6608
6625
  function parseNumber() {