1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports["default"] = parsePhoneNumber;
|
7 | exports.normalizeArguments = normalizeArguments;
|
8 |
|
9 | var _parsePhoneNumber_ = _interopRequireDefault(require("./parsePhoneNumber_"));
|
10 |
|
11 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
12 |
|
13 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
14 |
|
15 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
16 |
|
17 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
18 |
|
19 | function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
20 |
|
21 | function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
22 |
|
23 | function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
24 |
|
25 | function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
26 |
|
27 | function parsePhoneNumber() {
|
28 | var _normalizeArguments = normalizeArguments(arguments),
|
29 | text = _normalizeArguments.text,
|
30 | options = _normalizeArguments.options,
|
31 | metadata = _normalizeArguments.metadata;
|
32 |
|
33 | return (0, _parsePhoneNumber_["default"])(text, options, metadata);
|
34 | }
|
35 |
|
36 | function normalizeArguments(args) {
|
37 | var _Array$prototype$slic = Array.prototype.slice.call(args),
|
38 | _Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
|
39 | arg_1 = _Array$prototype$slic2[0],
|
40 | arg_2 = _Array$prototype$slic2[1],
|
41 | arg_3 = _Array$prototype$slic2[2],
|
42 | arg_4 = _Array$prototype$slic2[3];
|
43 |
|
44 | var text;
|
45 | var options;
|
46 | var metadata;
|
47 |
|
48 |
|
49 | if (typeof arg_1 === 'string') {
|
50 | text = arg_1;
|
51 | } else throw new TypeError('A text for parsing must be a string.');
|
52 |
|
53 |
|
54 |
|
55 | if (!arg_2 || typeof arg_2 === 'string') {
|
56 | if (arg_4) {
|
57 | options = arg_3;
|
58 | metadata = arg_4;
|
59 | } else {
|
60 | options = undefined;
|
61 | metadata = arg_3;
|
62 | }
|
63 |
|
64 | if (arg_2) {
|
65 | options = _objectSpread({
|
66 | defaultCountry: arg_2
|
67 | }, options);
|
68 | }
|
69 | }
|
70 |
|
71 | else if (isObject(arg_2)) {
|
72 | if (arg_3) {
|
73 | options = arg_2;
|
74 | metadata = arg_3;
|
75 | } else {
|
76 | metadata = arg_2;
|
77 | }
|
78 | } else throw new Error("Invalid second argument: ".concat(arg_2));
|
79 |
|
80 | return {
|
81 | text: text,
|
82 | options: options,
|
83 | metadata: metadata
|
84 | };
|
85 | }
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | var isObject = function isObject(_) {
|
91 | return _typeof(_) === 'object';
|
92 | };
|
93 |
|
\ | No newline at end of file |