ingeniuscliq-core 0.5.38 → 0.5.39
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.
- package/dist/components/common/form/FormPhone.d.ts.map +1 -1
- package/dist/components/common/form/FormPhone.js +6 -13
- package/dist/node_modules/libphonenumber-js/es6/metadata.js +1 -6
- package/package.json +1 -1
- package/dist/node_modules/libphonenumber-js/es6/ParseError.js +0 -34
- package/dist/node_modules/libphonenumber-js/es6/PhoneNumber.js +0 -194
- package/dist/node_modules/libphonenumber-js/es6/constants.js +0 -32
- package/dist/node_modules/libphonenumber-js/es6/format.js +0 -208
- package/dist/node_modules/libphonenumber-js/es6/helpers/RFC3966.js +0 -17
- package/dist/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +0 -37
- package/dist/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +0 -82
- package/dist/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +0 -96
- package/dist/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js +0 -31
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +0 -142
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +0 -47
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +0 -66
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +0 -117
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +0 -103
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js +0 -82
- package/dist/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +0 -32
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +0 -23
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +0 -81
- package/dist/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js +0 -27
- package/dist/node_modules/libphonenumber-js/es6/helpers/getNumberType.js +0 -86
- package/dist/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +0 -29
- package/dist/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +0 -78
- package/dist/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +0 -13
- package/dist/node_modules/libphonenumber-js/es6/helpers/parseDigits.js +0 -82
- package/dist/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js +0 -31
- package/dist/node_modules/libphonenumber-js/es6/isPossible.js +0 -78
- package/dist/node_modules/libphonenumber-js/es6/isValid.js +0 -58
- package/dist/node_modules/libphonenumber-js/es6/isValidPhoneNumber.js +0 -22
- package/dist/node_modules/libphonenumber-js/es6/normalizeArguments.js +0 -70
- package/dist/node_modules/libphonenumber-js/es6/parse.js +0 -326
- package/dist/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +0 -62
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js +0 -15
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js +0 -29
- package/dist/node_modules/libphonenumber-js/min/exports/isValidPhoneNumber.js +0 -8
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Metadata from '../metadata.js';
|
|
2
|
-
import { VALID_DIGITS } from '../constants.js';
|
|
3
|
-
|
|
4
|
-
var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
|
|
5
|
-
function stripIddPrefix(number, country, callingCode, metadata) {
|
|
6
|
-
if (!country) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
// Check if the number is IDD-prefixed.
|
|
10
|
-
var countryMetadata = new Metadata(metadata);
|
|
11
|
-
countryMetadata.selectNumberingPlan(country, callingCode);
|
|
12
|
-
var IDDPrefixPattern = new RegExp(countryMetadata.IDDPrefix());
|
|
13
|
-
if (number.search(IDDPrefixPattern) !== 0) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
// Strip IDD prefix.
|
|
17
|
-
number = number.slice(number.match(IDDPrefixPattern)[0].length);
|
|
18
|
-
// If there're any digits after an IDD prefix,
|
|
19
|
-
// then those digits are a country calling code.
|
|
20
|
-
// Since no country code starts with a `0`,
|
|
21
|
-
// the code below validates that the next digit (if present) is not `0`.
|
|
22
|
-
var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
|
|
23
|
-
if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
|
|
24
|
-
if (matchedGroups[1] === '0') {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { stripIddPrefix as default };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import Metadata from './metadata.js';
|
|
2
|
-
import checkNumberLength from './helpers/checkNumberLength.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Checks if a phone number is "possible" (basically just checks its length).
|
|
6
|
-
*
|
|
7
|
-
* isPossible(phoneNumberInstance, { ..., v2: true }, metadata)
|
|
8
|
-
*
|
|
9
|
-
* isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
|
|
10
|
-
* isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
|
|
11
|
-
*
|
|
12
|
-
* @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
|
|
13
|
-
* @param {object} [options]
|
|
14
|
-
* @param {object} metadata
|
|
15
|
-
* @return {string}
|
|
16
|
-
*/
|
|
17
|
-
function isPossiblePhoneNumber(input, options, metadata) {
|
|
18
|
-
/* istanbul ignore if */
|
|
19
|
-
if (options === undefined) {
|
|
20
|
-
options = {};
|
|
21
|
-
}
|
|
22
|
-
metadata = new Metadata(metadata);
|
|
23
|
-
if (options.v2) {
|
|
24
|
-
if (!input.countryCallingCode) {
|
|
25
|
-
throw new Error('Invalid phone number object passed');
|
|
26
|
-
}
|
|
27
|
-
metadata.selectNumberingPlan(input.countryCallingCode);
|
|
28
|
-
} else {
|
|
29
|
-
if (!input.phone) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
if (input.country) {
|
|
33
|
-
if (!metadata.hasCountry(input.country)) {
|
|
34
|
-
throw new Error("Unknown country: ".concat(input.country));
|
|
35
|
-
}
|
|
36
|
-
metadata.selectNumberingPlan(input.country);
|
|
37
|
-
} else {
|
|
38
|
-
if (!input.countryCallingCode) {
|
|
39
|
-
throw new Error('Invalid phone number object passed');
|
|
40
|
-
}
|
|
41
|
-
metadata.selectNumberingPlan(input.countryCallingCode);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Old metadata (< 1.0.18) had no "possible length" data.
|
|
46
|
-
if (metadata.possibleLengths()) {
|
|
47
|
-
return isPossibleNumber(input.phone || input.nationalNumber, input.country, metadata);
|
|
48
|
-
} else {
|
|
49
|
-
// There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
|
|
50
|
-
// were missing for "non-geographical" numbering plans.
|
|
51
|
-
// Just assume the number is possible in such cases:
|
|
52
|
-
// it's unlikely that anyone generated their custom metadata
|
|
53
|
-
// in that short period of time (one day).
|
|
54
|
-
// This code can be removed in some future major version update.
|
|
55
|
-
if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
|
|
56
|
-
// "Non-geographic entities" did't have `possibleLengths`
|
|
57
|
-
// due to a bug in metadata generation process.
|
|
58
|
-
return true;
|
|
59
|
-
} else {
|
|
60
|
-
throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function isPossibleNumber(nationalNumber, country, metadata) {
|
|
65
|
-
//, isInternational) {
|
|
66
|
-
switch (checkNumberLength(nationalNumber, country, metadata)) {
|
|
67
|
-
case 'IS_POSSIBLE':
|
|
68
|
-
return true;
|
|
69
|
-
// This library ignores "local-only" phone numbers (for simplicity).
|
|
70
|
-
// See the readme for more info on what are "local-only" phone numbers.
|
|
71
|
-
// case 'IS_POSSIBLE_LOCAL_ONLY':
|
|
72
|
-
// return !isInternational
|
|
73
|
-
default:
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { isPossiblePhoneNumber as default, isPossibleNumber };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import Metadata from './metadata.js';
|
|
2
|
-
import matchesEntirely from './helpers/matchesEntirely.js';
|
|
3
|
-
import getNumberType from './helpers/getNumberType.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Checks if a given phone number is valid.
|
|
7
|
-
*
|
|
8
|
-
* isValid(phoneNumberInstance, { ..., v2: true }, metadata)
|
|
9
|
-
*
|
|
10
|
-
* isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
|
|
11
|
-
* isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
|
|
12
|
-
*
|
|
13
|
-
* If the `number` is a string, it will be parsed to an object,
|
|
14
|
-
* but only if it contains only valid phone number characters (including punctuation).
|
|
15
|
-
* If the `number` is an object, it is used as is.
|
|
16
|
-
*
|
|
17
|
-
* The optional `defaultCountry` argument is the default country.
|
|
18
|
-
* I.e. it does not restrict to just that country,
|
|
19
|
-
* e.g. in those cases where several countries share
|
|
20
|
-
* the same phone numbering rules (NANPA, Britain, etc).
|
|
21
|
-
* For example, even though the number `07624 369230`
|
|
22
|
-
* belongs to the Isle of Man ("IM" country code)
|
|
23
|
-
* calling `isValidNumber('07624369230', 'GB', metadata)`
|
|
24
|
-
* still returns `true` because the country is not restricted to `GB`,
|
|
25
|
-
* it's just that `GB` is the default one for the phone numbering rules.
|
|
26
|
-
* For restricting the country see `isValidNumberForRegion()`
|
|
27
|
-
* though restricting a country might not be a good idea.
|
|
28
|
-
* https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
|
|
29
|
-
*
|
|
30
|
-
* Examples:
|
|
31
|
-
*
|
|
32
|
-
* ```js
|
|
33
|
-
* isValidNumber('+78005553535', metadata)
|
|
34
|
-
* isValidNumber('8005553535', 'RU', metadata)
|
|
35
|
-
* isValidNumber('88005553535', 'RU', metadata)
|
|
36
|
-
* isValidNumber({ phone: '8005553535', country: 'RU' }, metadata)
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
function isValidNumber(input, options, metadata) {
|
|
40
|
-
// If assigning the `{}` default value is moved to the arguments above,
|
|
41
|
-
// code coverage would decrease for some weird reason.
|
|
42
|
-
options = options || {};
|
|
43
|
-
metadata = new Metadata(metadata);
|
|
44
|
-
metadata.selectNumberingPlan(input.country, input.countryCallingCode);
|
|
45
|
-
|
|
46
|
-
// By default, countries only have type regexps when it's required for
|
|
47
|
-
// distinguishing different countries having the same `countryCallingCode`.
|
|
48
|
-
if (metadata.hasTypes()) {
|
|
49
|
-
return getNumberType(input, options, metadata.metadata) !== undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// If there are no type regexps for this country in metadata then use
|
|
53
|
-
// `nationalNumberPattern` as a "better than nothing" replacement.
|
|
54
|
-
var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
|
|
55
|
-
return matchesEntirely(nationalNumber, metadata.nationalNumberPattern());
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { isValidNumber as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import normalizeArguments from './normalizeArguments.js';
|
|
2
|
-
import parsePhoneNumber from './parsePhoneNumber_.js';
|
|
3
|
-
|
|
4
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "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(o); }
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
function isValidPhoneNumber() {
|
|
11
|
-
var _normalizeArguments = normalizeArguments(arguments),
|
|
12
|
-
text = _normalizeArguments.text,
|
|
13
|
-
options = _normalizeArguments.options,
|
|
14
|
-
metadata = _normalizeArguments.metadata;
|
|
15
|
-
options = _objectSpread(_objectSpread({}, options), {}, {
|
|
16
|
-
extract: false
|
|
17
|
-
});
|
|
18
|
-
var phoneNumber = parsePhoneNumber(text, options, metadata);
|
|
19
|
-
return phoneNumber && phoneNumber.isValid() || false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { isValidPhoneNumber as default };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import isObject from './helpers/isObject.js';
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "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(o); }
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
10
|
-
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."); }
|
|
11
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(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(r, a) : void 0; } }
|
|
12
|
-
function _arrayLikeToArray(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; }
|
|
13
|
-
function _iterableToArrayLimit(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; } }
|
|
14
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
15
|
-
|
|
16
|
-
// Extracts the following properties from function arguments:
|
|
17
|
-
// * input `text`
|
|
18
|
-
// * `options` object
|
|
19
|
-
// * `metadata` JSON
|
|
20
|
-
function normalizeArguments(args) {
|
|
21
|
-
var _Array$prototype$slic = Array.prototype.slice.call(args),
|
|
22
|
-
_Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
|
|
23
|
-
arg_1 = _Array$prototype$slic2[0],
|
|
24
|
-
arg_2 = _Array$prototype$slic2[1],
|
|
25
|
-
arg_3 = _Array$prototype$slic2[2],
|
|
26
|
-
arg_4 = _Array$prototype$slic2[3];
|
|
27
|
-
var text;
|
|
28
|
-
var options;
|
|
29
|
-
var metadata;
|
|
30
|
-
|
|
31
|
-
// If the phone number is passed as a string.
|
|
32
|
-
// `parsePhoneNumber('88005553535', ...)`.
|
|
33
|
-
if (typeof arg_1 === 'string') {
|
|
34
|
-
text = arg_1;
|
|
35
|
-
} else throw new TypeError('A text for parsing must be a string.');
|
|
36
|
-
|
|
37
|
-
// If "default country" argument is being passed then move it to `options`.
|
|
38
|
-
// `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
|
|
39
|
-
if (!arg_2 || typeof arg_2 === 'string') {
|
|
40
|
-
if (arg_4) {
|
|
41
|
-
options = arg_3;
|
|
42
|
-
metadata = arg_4;
|
|
43
|
-
} else {
|
|
44
|
-
options = undefined;
|
|
45
|
-
metadata = arg_3;
|
|
46
|
-
}
|
|
47
|
-
if (arg_2) {
|
|
48
|
-
options = _objectSpread({
|
|
49
|
-
defaultCountry: arg_2
|
|
50
|
-
}, options);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// `defaultCountry` is not passed.
|
|
54
|
-
// Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
|
|
55
|
-
else if (isObject(arg_2)) {
|
|
56
|
-
if (arg_3) {
|
|
57
|
-
options = arg_2;
|
|
58
|
-
metadata = arg_3;
|
|
59
|
-
} else {
|
|
60
|
-
metadata = arg_2;
|
|
61
|
-
}
|
|
62
|
-
} else throw new Error("Invalid second argument: ".concat(arg_2));
|
|
63
|
-
return {
|
|
64
|
-
text: text,
|
|
65
|
-
options: options,
|
|
66
|
-
metadata: metadata
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export { normalizeArguments as default };
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import { MIN_LENGTH_FOR_NSN, MAX_LENGTH_FOR_NSN, PLUS_CHARS, VALID_DIGITS } from './constants.js';
|
|
2
|
-
import ParseError from './ParseError.js';
|
|
3
|
-
import Metadata, { getCountryCallingCode } from './metadata.js';
|
|
4
|
-
import isViablePhoneNumber, { isViablePhoneNumberStart } from './helpers/isViablePhoneNumber.js';
|
|
5
|
-
import extractExtension from './helpers/extension/extractExtension.js';
|
|
6
|
-
import parseIncompletePhoneNumber from './parseIncompletePhoneNumber.js';
|
|
7
|
-
import { isPossibleNumber } from './isPossible.js';
|
|
8
|
-
import PhoneNumber from './PhoneNumber.js';
|
|
9
|
-
import matchesEntirely from './helpers/matchesEntirely.js';
|
|
10
|
-
import extractCountryCallingCode from './helpers/extractCountryCallingCode.js';
|
|
11
|
-
import extractNationalNumber from './helpers/extractNationalNumber.js';
|
|
12
|
-
import getCountryByCallingCode from './helpers/getCountryByCallingCode.js';
|
|
13
|
-
import extractFormattedPhoneNumberFromPossibleRfc3966NumberUri from './helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js';
|
|
14
|
-
|
|
15
|
-
// This is a port of Google Android `libphonenumber`'s
|
|
16
|
-
// `phonenumberutil.js` of December 31th, 2018.
|
|
17
|
-
//
|
|
18
|
-
// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// We don't allow input strings for parsing to be longer than 250 chars.
|
|
22
|
-
// This prevents malicious input from consuming CPU.
|
|
23
|
-
var MAX_INPUT_STRING_LENGTH = 250;
|
|
24
|
-
|
|
25
|
-
// This consists of the plus symbol, digits, and arabic-indic digits.
|
|
26
|
-
var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']');
|
|
27
|
-
|
|
28
|
-
// Regular expression of trailing characters that we want to remove.
|
|
29
|
-
// A trailing `#` is sometimes used when writing phone numbers with extensions in US.
|
|
30
|
-
// Example: "+1 (645) 123 1234-910#" number has extension "910".
|
|
31
|
-
var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
|
|
32
|
-
|
|
33
|
-
// Examples:
|
|
34
|
-
//
|
|
35
|
-
// ```js
|
|
36
|
-
// parse('8 (800) 555-35-35', 'RU')
|
|
37
|
-
// parse('8 (800) 555-35-35', 'RU', metadata)
|
|
38
|
-
// parse('8 (800) 555-35-35', { country: { default: 'RU' } })
|
|
39
|
-
// parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
|
|
40
|
-
// parse('+7 800 555 35 35')
|
|
41
|
-
// parse('+7 800 555 35 35', metadata)
|
|
42
|
-
// ```
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Parses a phone number.
|
|
47
|
-
*
|
|
48
|
-
* parse('123456789', { defaultCountry: 'RU', v2: true }, metadata)
|
|
49
|
-
* parse('123456789', { defaultCountry: 'RU' }, metadata)
|
|
50
|
-
* parse('123456789', undefined, metadata)
|
|
51
|
-
*
|
|
52
|
-
* @param {string} input
|
|
53
|
-
* @param {object} [options]
|
|
54
|
-
* @param {object} metadata
|
|
55
|
-
* @return {object|PhoneNumber?} If `options.v2: true` flag is passed, it returns a `PhoneNumber?` instance. Otherwise, returns an object of shape `{ phone: '...', country: '...' }` (or just `{}` if no phone number was parsed).
|
|
56
|
-
*/
|
|
57
|
-
function parse(text, options, metadata) {
|
|
58
|
-
// If assigning the `{}` default value is moved to the arguments above,
|
|
59
|
-
// code coverage would decrease for some weird reason.
|
|
60
|
-
options = options || {};
|
|
61
|
-
metadata = new Metadata(metadata);
|
|
62
|
-
|
|
63
|
-
// Validate `defaultCountry`.
|
|
64
|
-
if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
|
|
65
|
-
if (options.v2) {
|
|
66
|
-
throw new ParseError('INVALID_COUNTRY');
|
|
67
|
-
}
|
|
68
|
-
throw new Error("Unknown country: ".concat(options.defaultCountry));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Parse the phone number.
|
|
72
|
-
var _parseInput = parseInput(text, options.v2, options.extract),
|
|
73
|
-
formattedPhoneNumber = _parseInput.number,
|
|
74
|
-
ext = _parseInput.ext,
|
|
75
|
-
error = _parseInput.error;
|
|
76
|
-
|
|
77
|
-
// If the phone number is not viable then return nothing.
|
|
78
|
-
if (!formattedPhoneNumber) {
|
|
79
|
-
if (options.v2) {
|
|
80
|
-
if (error === 'TOO_SHORT') {
|
|
81
|
-
throw new ParseError('TOO_SHORT');
|
|
82
|
-
}
|
|
83
|
-
throw new ParseError('NOT_A_NUMBER');
|
|
84
|
-
}
|
|
85
|
-
return {};
|
|
86
|
-
}
|
|
87
|
-
var _parsePhoneNumber = parsePhoneNumber(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
|
|
88
|
-
country = _parsePhoneNumber.country,
|
|
89
|
-
nationalNumber = _parsePhoneNumber.nationalNumber,
|
|
90
|
-
countryCallingCode = _parsePhoneNumber.countryCallingCode,
|
|
91
|
-
countryCallingCodeSource = _parsePhoneNumber.countryCallingCodeSource,
|
|
92
|
-
carrierCode = _parsePhoneNumber.carrierCode;
|
|
93
|
-
if (!metadata.hasSelectedNumberingPlan()) {
|
|
94
|
-
if (options.v2) {
|
|
95
|
-
throw new ParseError('INVALID_COUNTRY');
|
|
96
|
-
}
|
|
97
|
-
return {};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Validate national (significant) number length.
|
|
101
|
-
if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
|
|
102
|
-
// Won't throw here because the regexp already demands length > 1.
|
|
103
|
-
/* istanbul ignore if */
|
|
104
|
-
if (options.v2) {
|
|
105
|
-
throw new ParseError('TOO_SHORT');
|
|
106
|
-
}
|
|
107
|
-
// Google's demo just throws an error in this case.
|
|
108
|
-
return {};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Validate national (significant) number length.
|
|
112
|
-
//
|
|
113
|
-
// A sidenote:
|
|
114
|
-
//
|
|
115
|
-
// They say that sometimes national (significant) numbers
|
|
116
|
-
// can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
|
|
117
|
-
// https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
|
|
118
|
-
// Such numbers will just be discarded.
|
|
119
|
-
//
|
|
120
|
-
if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
|
|
121
|
-
if (options.v2) {
|
|
122
|
-
throw new ParseError('TOO_LONG');
|
|
123
|
-
}
|
|
124
|
-
// Google's demo just throws an error in this case.
|
|
125
|
-
return {};
|
|
126
|
-
}
|
|
127
|
-
if (options.v2) {
|
|
128
|
-
var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
|
|
129
|
-
if (country) {
|
|
130
|
-
phoneNumber.country = country;
|
|
131
|
-
}
|
|
132
|
-
if (carrierCode) {
|
|
133
|
-
phoneNumber.carrierCode = carrierCode;
|
|
134
|
-
}
|
|
135
|
-
if (ext) {
|
|
136
|
-
phoneNumber.ext = ext;
|
|
137
|
-
}
|
|
138
|
-
phoneNumber.__countryCallingCodeSource = countryCallingCodeSource;
|
|
139
|
-
return phoneNumber;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Check if national phone number pattern matches the number.
|
|
143
|
-
// National number pattern is different for each country,
|
|
144
|
-
// even for those ones which are part of the "NANPA" group.
|
|
145
|
-
var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
|
|
146
|
-
if (!options.extended) {
|
|
147
|
-
return valid ? result(country, nationalNumber, ext) : {};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// isInternational: countryCallingCode !== undefined
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
country: country,
|
|
154
|
-
countryCallingCode: countryCallingCode,
|
|
155
|
-
carrierCode: carrierCode,
|
|
156
|
-
valid: valid,
|
|
157
|
-
possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, country, metadata) ? true : false,
|
|
158
|
-
phone: nationalNumber,
|
|
159
|
-
ext: ext
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Extracts a formatted phone number from text.
|
|
165
|
-
* Doesn't guarantee that the extracted phone number
|
|
166
|
-
* is a valid phone number (for example, doesn't validate its length).
|
|
167
|
-
* @param {string} text
|
|
168
|
-
* @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.
|
|
169
|
-
* @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.
|
|
170
|
-
* @return {string}
|
|
171
|
-
* @example
|
|
172
|
-
* // Returns "(213) 373-4253".
|
|
173
|
-
* extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
|
|
174
|
-
*/
|
|
175
|
-
function _extractFormattedPhoneNumber(text, extract, throwOnError) {
|
|
176
|
-
if (!text) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (text.length > MAX_INPUT_STRING_LENGTH) {
|
|
180
|
-
if (throwOnError) {
|
|
181
|
-
throw new ParseError('TOO_LONG');
|
|
182
|
-
}
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (extract === false) {
|
|
186
|
-
return text;
|
|
187
|
-
}
|
|
188
|
-
// Attempt to extract a possible number from the string passed in
|
|
189
|
-
var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
|
|
190
|
-
if (startsAt < 0) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
return text
|
|
194
|
-
// Trim everything to the left of the phone number
|
|
195
|
-
.slice(startsAt)
|
|
196
|
-
// Remove trailing non-numerical characters
|
|
197
|
-
.replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @param {string} text - Input.
|
|
202
|
-
* @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
|
|
203
|
-
* @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
|
|
204
|
-
* @return {object} `{ ?number, ?ext }`.
|
|
205
|
-
*/
|
|
206
|
-
function parseInput(text, v2, extract) {
|
|
207
|
-
// // Parse RFC 3966 phone number URI.
|
|
208
|
-
// if (text && text.indexOf('tel:') === 0) {
|
|
209
|
-
// return parseRFC3966(text)
|
|
210
|
-
// }
|
|
211
|
-
// let number = extractFormattedPhoneNumber(text, extract, v2)
|
|
212
|
-
var number = extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(text, {
|
|
213
|
-
extractFormattedPhoneNumber: function extractFormattedPhoneNumber(text) {
|
|
214
|
-
return _extractFormattedPhoneNumber(text, extract, v2);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
// If the phone number is not viable, then abort.
|
|
218
|
-
if (!number) {
|
|
219
|
-
return {};
|
|
220
|
-
}
|
|
221
|
-
if (!isViablePhoneNumber(number)) {
|
|
222
|
-
if (isViablePhoneNumberStart(number)) {
|
|
223
|
-
return {
|
|
224
|
-
error: 'TOO_SHORT'
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
return {};
|
|
228
|
-
}
|
|
229
|
-
// Attempt to parse extension first, since it doesn't require region-specific
|
|
230
|
-
// data and we want to have the non-normalised number here.
|
|
231
|
-
var withExtensionStripped = extractExtension(number);
|
|
232
|
-
if (withExtensionStripped.ext) {
|
|
233
|
-
return withExtensionStripped;
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
number: number
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Creates `parse()` result object.
|
|
242
|
-
*/
|
|
243
|
-
function result(country, nationalNumber, ext) {
|
|
244
|
-
var result = {
|
|
245
|
-
country: country,
|
|
246
|
-
phone: nationalNumber
|
|
247
|
-
};
|
|
248
|
-
if (ext) {
|
|
249
|
-
result.ext = ext;
|
|
250
|
-
}
|
|
251
|
-
return result;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Parses a viable phone number.
|
|
256
|
-
* @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
|
|
257
|
-
* @param {string} [defaultCountry]
|
|
258
|
-
* @param {string} [defaultCallingCode]
|
|
259
|
-
* @param {Metadata} metadata
|
|
260
|
-
* @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
|
|
261
|
-
*/
|
|
262
|
-
function parsePhoneNumber(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
|
|
263
|
-
// Extract calling code from phone number.
|
|
264
|
-
var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), undefined, defaultCountry, defaultCallingCode, metadata.metadata),
|
|
265
|
-
countryCallingCodeSource = _extractCountryCallin.countryCallingCodeSource,
|
|
266
|
-
countryCallingCode = _extractCountryCallin.countryCallingCode,
|
|
267
|
-
number = _extractCountryCallin.number;
|
|
268
|
-
|
|
269
|
-
// The exact country of the phone number
|
|
270
|
-
var country;
|
|
271
|
-
|
|
272
|
-
// If `formattedPhoneNumber` is passed in "international" format,
|
|
273
|
-
// choose a country by `countryCallingCode`.
|
|
274
|
-
if (countryCallingCode) {
|
|
275
|
-
metadata.selectNumberingPlan(countryCallingCode);
|
|
276
|
-
}
|
|
277
|
-
// Else, if `formattedPhoneNumber` is passed in "national" format,
|
|
278
|
-
// then `number` is defined and `countryCallingCode` is `undefined`.
|
|
279
|
-
else if (number && (defaultCountry || defaultCallingCode)) {
|
|
280
|
-
metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
|
|
281
|
-
if (defaultCountry) {
|
|
282
|
-
country = defaultCountry;
|
|
283
|
-
}
|
|
284
|
-
countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
|
|
285
|
-
} else return {};
|
|
286
|
-
if (!number) {
|
|
287
|
-
return {
|
|
288
|
-
countryCallingCodeSource: countryCallingCodeSource,
|
|
289
|
-
countryCallingCode: countryCallingCode
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), country, metadata),
|
|
293
|
-
nationalNumber = _extractNationalNumbe.nationalNumber,
|
|
294
|
-
carrierCode = _extractNationalNumbe.carrierCode;
|
|
295
|
-
|
|
296
|
-
// Sometimes there are several countries
|
|
297
|
-
// corresponding to the same country phone code
|
|
298
|
-
// (e.g. NANPA countries all having `1` country phone code).
|
|
299
|
-
// Therefore, to reliably determine the exact country,
|
|
300
|
-
// national (significant) number should have been parsed first.
|
|
301
|
-
//
|
|
302
|
-
// When `metadata.json` is generated, all "ambiguous" country phone codes
|
|
303
|
-
// get their countries populated with the full set of
|
|
304
|
-
// "phone number type" regular expressions.
|
|
305
|
-
//
|
|
306
|
-
var exactCountry = getCountryByCallingCode(countryCallingCode, {
|
|
307
|
-
nationalNumber: nationalNumber,
|
|
308
|
-
metadata: metadata
|
|
309
|
-
});
|
|
310
|
-
if (exactCountry) {
|
|
311
|
-
country = exactCountry;
|
|
312
|
-
/* istanbul ignore if */
|
|
313
|
-
if (exactCountry === '001') ; else {
|
|
314
|
-
metadata.selectNumberingPlan(country);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return {
|
|
318
|
-
country: country,
|
|
319
|
-
countryCallingCode: countryCallingCode,
|
|
320
|
-
countryCallingCodeSource: countryCallingCodeSource,
|
|
321
|
-
nationalNumber: nationalNumber,
|
|
322
|
-
carrierCode: carrierCode
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export { parse as default };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { parseDigit } from './helpers/parseDigits.js';
|
|
2
|
-
|
|
3
|
-
function _createForOfIteratorHelperLoose(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(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."); }
|
|
4
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(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(r, a) : void 0; } }
|
|
5
|
-
function _arrayLikeToArray(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; }
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Parses phone number characters from a string.
|
|
9
|
-
* Drops all punctuation leaving only digits and the leading `+` sign (if any).
|
|
10
|
-
* Also converts wide-ascii and arabic-indic numerals to conventional numerals.
|
|
11
|
-
* E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
|
|
12
|
-
* @param {string} string
|
|
13
|
-
* @return {string}
|
|
14
|
-
* @example
|
|
15
|
-
* ```js
|
|
16
|
-
* // Outputs '8800555'.
|
|
17
|
-
* parseIncompletePhoneNumber('8 (800) 555')
|
|
18
|
-
* // Outputs '+7800555'.
|
|
19
|
-
* parseIncompletePhoneNumber('+7 800 555')
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
function parseIncompletePhoneNumber(string) {
|
|
23
|
-
var result = '';
|
|
24
|
-
// Using `.split('')` here instead of normal `for ... of`
|
|
25
|
-
// because the importing application doesn't neccessarily include an ES6 polyfill.
|
|
26
|
-
// The `.split('')` approach discards "exotic" UTF-8 characters
|
|
27
|
-
// (the ones consisting of four bytes) but digits
|
|
28
|
-
// (including non-European ones) don't fall into that range
|
|
29
|
-
// so such "exotic" characters would be discarded anyway.
|
|
30
|
-
for (var _iterator = _createForOfIteratorHelperLoose(string.split('')), _step; !(_step = _iterator()).done;) {
|
|
31
|
-
var character = _step.value;
|
|
32
|
-
result += parsePhoneNumberCharacter(character, result) || '';
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Parses next character while parsing phone number digits (including a `+`)
|
|
39
|
-
* from text: discards everything except `+` and digits, and `+` is only allowed
|
|
40
|
-
* at the start of a phone number.
|
|
41
|
-
* For example, is used in `react-phone-number-input` where it uses
|
|
42
|
-
* [`input-format`](https://gitlab.com/catamphetamine/input-format).
|
|
43
|
-
* @param {string} character - Yet another character from raw input string.
|
|
44
|
-
* @param {string?} prevParsedCharacters - Previous parsed characters.
|
|
45
|
-
* @param {function?} eventListener - An optional "on event" function.
|
|
46
|
-
* @return {string?} The parsed character.
|
|
47
|
-
*/
|
|
48
|
-
function parsePhoneNumberCharacter(character, prevParsedCharacters, eventListener) {
|
|
49
|
-
// Only allow a leading `+`.
|
|
50
|
-
if (character === '+') {
|
|
51
|
-
// If this `+` is not the first parsed character
|
|
52
|
-
// then discard it.
|
|
53
|
-
if (prevParsedCharacters) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
return '+';
|
|
57
|
-
}
|
|
58
|
-
// Allow digits.
|
|
59
|
-
return parseDigit(character);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { parseIncompletePhoneNumber as default, parsePhoneNumberCharacter };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import parse from './parse.js';
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "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(o); }
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
-
function parsePhoneNumberWithError(text, options, metadata) {
|
|
10
|
-
return parse(text, _objectSpread(_objectSpread({}, options), {}, {
|
|
11
|
-
v2: true
|
|
12
|
-
}), metadata);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { parsePhoneNumberWithError as default };
|