index.cjs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. 'use strict'
  2. var min = require('./min/index.cjs')
  3. var metadata = require('./metadata.min.json')
  4. function withMetadataArgument(func, _arguments) {
  5. var args = Array.prototype.slice.call(_arguments)
  6. args.push(metadata)
  7. return func.apply(this, args)
  8. }
  9. // ES5 `require()` "default" "interoperability" hack.
  10. // https://github.com/babel/babel/issues/2212#issuecomment-131827986
  11. // An alternative approach:
  12. // https://www.npmjs.com/package/babel-plugin-add-module-exports
  13. exports = module.exports = min.parsePhoneNumberFromString
  14. exports['default'] = min.parsePhoneNumberFromString
  15. // `parsePhoneNumberFromString()` named export is now considered legacy:
  16. // it has been promoted to a default export due to being too verbose.
  17. exports.parsePhoneNumberFromString = min.parsePhoneNumberFromString
  18. exports.ParseError = min.ParseError
  19. // `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
  20. exports.parsePhoneNumber = min.parsePhoneNumberWithError
  21. exports.parsePhoneNumberWithError = min.parsePhoneNumberWithError
  22. exports.isValidPhoneNumber = min.isValidPhoneNumber
  23. exports.isPossiblePhoneNumber = min.isPossiblePhoneNumber
  24. exports.validatePhoneNumberLength = min.validatePhoneNumberLength
  25. // `parse()` and `parseNumber()` functions are deprecated.
  26. var parse_ = require('./build/legacy/parse.js').default
  27. exports.parse = function parse() {
  28. return withMetadataArgument(parse_, arguments)
  29. }
  30. exports.parseNumber = exports.parse
  31. // `format()` and `formatNumber()` functions are deprecated.
  32. var format_ = require('./build/legacy/format.js').default
  33. exports.format = function format() {
  34. return withMetadataArgument(format_, arguments)
  35. }
  36. exports.formatNumber = exports.format
  37. // Deprecated.
  38. var getNumberType_ = require('./build/legacy/getNumberType.js').default
  39. exports.getNumberType = function getNumberType() {
  40. return withMetadataArgument(getNumberType_, arguments)
  41. }
  42. // Deprecated.
  43. var isPossibleNumber_ = require('./build/legacy/isPossibleNumber.js').default
  44. exports.isPossibleNumber = function isPossibleNumber() {
  45. return withMetadataArgument(isPossibleNumber_, arguments)
  46. }
  47. // Deprecated.
  48. var isValidNumber_ = require('./build/legacy/isValidNumber.js').default
  49. exports.isValidNumber = function isValidNumber() {
  50. return withMetadataArgument(isValidNumber_, arguments)
  51. }
  52. // Deprecated.
  53. var isValidNumberForRegion_ = require('./build/legacy/isValidNumberForRegion.js').default
  54. exports.isValidNumberForRegion = function isValidNumberForRegion() {
  55. return withMetadataArgument(isValidNumberForRegion_, arguments)
  56. }
  57. exports.getExampleNumber = min.getExampleNumber
  58. exports.Metadata = min.Metadata
  59. // Deprecated.
  60. var findPhoneNumbers_ = require('./build/legacy/findPhoneNumbers.js').default
  61. exports.findPhoneNumbers = function findPhoneNumbers() {
  62. return withMetadataArgument(findPhoneNumbers_, arguments)
  63. }
  64. // Deprecated.
  65. var searchPhoneNumbers_ = require('./build/legacy/findPhoneNumbers.js').searchPhoneNumbers
  66. exports.searchPhoneNumbers = function searchPhoneNumbers() {
  67. return withMetadataArgument(searchPhoneNumbers_, arguments)
  68. }
  69. // Deprecated.
  70. var PhoneNumberSearch_ = require('./build/legacy/findPhoneNumbersInitialImplementation.js').PhoneNumberSearch
  71. exports.PhoneNumberSearch = function PhoneNumberSearch(text, options) {
  72. return PhoneNumberSearch_.call(this, text, options, metadata)
  73. }
  74. exports.PhoneNumberSearch.prototype = Object.create(PhoneNumberSearch_.prototype, {})
  75. exports.PhoneNumberSearch.prototype.constructor = exports.PhoneNumberSearch
  76. // Deprecated.
  77. exports.findNumbers = min.findNumbers
  78. // Deprecated.
  79. exports.searchNumbers = min.searchNumbers
  80. exports.findPhoneNumbersInText = min.findPhoneNumbersInText
  81. exports.searchPhoneNumbersInText = min.searchPhoneNumbersInText
  82. exports.PhoneNumberMatcher = min.PhoneNumberMatcher
  83. exports.AsYouType = min.AsYouType
  84. exports.getCountries = min.getCountries
  85. exports.getCountryCallingCode = min.getCountryCallingCode
  86. exports.isSupportedCountry = min.isSupportedCountry
  87. exports.getExtPrefix = min.getExtPrefix
  88. exports.parseRFC3966 = min.parseRFC3966
  89. exports.formatRFC3966 = min.formatRFC3966
  90. // Deprecated: `DIGITS` were used by `react-phone-number-input`.
  91. // Replaced by `parseDigits()`.
  92. exports.DIGITS = require('./build/helpers/parseDigits.js').DIGITS
  93. exports.DIGIT_PLACEHOLDER = min.DIGIT_PLACEHOLDER
  94. // `getPhoneCode` name is deprecated
  95. exports.getPhoneCode = min.getCountryCallingCode
  96. exports.formatIncompletePhoneNumber = min.formatIncompletePhoneNumber
  97. exports.parseIncompletePhoneNumber = min.parseIncompletePhoneNumber
  98. exports.parsePhoneNumberCharacter = min.parsePhoneNumberCharacter
  99. exports.parseDigits = min.parseDigits