formatIncompletePhoneNumber.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = formatIncompletePhoneNumber;
  6. var _AsYouType = _interopRequireDefault(require("./AsYouType.js"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8. /**
  9. * Formats a (possibly incomplete) phone number.
  10. * The phone number can be either in E.164 format
  11. * or in a form of national number digits.
  12. * @param {string} value - A possibly incomplete phone number. Either in E.164 format or in a form of national number digits.
  13. * @param {string|object} [optionsOrDefaultCountry] - A two-letter ("ISO 3166-1 alpha-2") country code, or an object of shape `{ defaultCountry?: string, defaultCallingCode?: string }`.
  14. * @return {string} Formatted (possibly incomplete) phone number.
  15. */
  16. function formatIncompletePhoneNumber(value, optionsOrDefaultCountry, metadata) {
  17. if (!metadata) {
  18. metadata = optionsOrDefaultCountry;
  19. optionsOrDefaultCountry = undefined;
  20. }
  21. return new _AsYouType["default"](optionsOrDefaultCountry, metadata).input(value);
  22. }
  23. //# sourceMappingURL=formatIncompletePhoneNumber.js.map