UNPKG

2.57 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = findPhoneNumbersInText;
7exports.getArguments = getArguments;
8
9var _findNumbers = _interopRequireDefault(require("./findNumbers"));
10
11function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13function _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
15function _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
17function _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
19function findPhoneNumbersInText(text, defaultCountry, options, metadata) {
20 var args = getArguments(defaultCountry, options, metadata);
21 return (0, _findNumbers["default"])(text, args.options, args.metadata);
22}
23
24function getArguments(defaultCountry, options, metadata) {
25 if (metadata) {
26 if (defaultCountry) {
27 options = _objectSpread({}, options, {
28 defaultCountry: defaultCountry
29 });
30 }
31 } else {
32 if (options) {
33 metadata = options;
34
35 if (defaultCountry) {
36 if (is_object(defaultCountry)) {
37 options = defaultCountry;
38 } else {
39 options = {
40 defaultCountry: defaultCountry
41 };
42 }
43 } else {
44 options = undefined;
45 }
46 } else {
47 metadata = defaultCountry;
48 options = undefined;
49 }
50 }
51
52 return {
53 options: _objectSpread({}, options, {
54 v2: true
55 }),
56 metadata: metadata
57 };
58} // Babel transforms `typeof` into some "branches"
59// so istanbul will show this as "branch not covered".
60
61/* istanbul ignore next */
62
63
64var is_object = function is_object(_) {
65 return _typeof(_) === 'object';
66};
67//# sourceMappingURL=findPhoneNumbersInText.js.map
\No newline at end of file