UNPKG

3.31 kBJavaScriptView Raw
1'use strict'
2
3var metadata = require('../metadata.mobile.json')
4var core = require('../core/index.commonjs')
5
6function call(func, _arguments) {
7 var args = Array.prototype.slice.call(_arguments)
8 args.push(metadata)
9 return func.apply(this, args)
10}
11
12function parsePhoneNumberFromString() {
13 return call(core.parsePhoneNumberFromString, arguments)
14}
15
16// ES5 `require()` "default" "interoperability" hack.
17// https://github.com/babel/babel/issues/2212#issuecomment-131827986
18// An alternative approach:
19// https://www.npmjs.com/package/babel-plugin-add-module-exports
20exports = module.exports = parsePhoneNumberFromString
21exports['default'] = parsePhoneNumberFromString
22
23exports.ParseError = core.ParseError
24
25function parsePhoneNumberWithError() {
26 return call(core.parsePhoneNumberWithError, arguments)
27}
28
29// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
30exports.parsePhoneNumber = parsePhoneNumberWithError
31exports.parsePhoneNumberWithError = parsePhoneNumberWithError
32
33// `parsePhoneNumberFromString()` named export is now considered legacy:
34// it has been promoted to a default export due to being too verbose.
35exports.parsePhoneNumberFromString = parsePhoneNumberFromString
36
37exports.findNumbers = function findNumbers() {
38 return call(core.findNumbers, arguments)
39}
40
41exports.searchNumbers = function searchNumbers() {
42 return call(core.searchNumbers, arguments)
43}
44
45exports.findPhoneNumbersInText = function findPhoneNumbersInText() {
46 return call(core.findPhoneNumbersInText, arguments)
47}
48
49exports.searchPhoneNumbersInText = function searchPhoneNumbersInText() {
50 return call(core.searchPhoneNumbersInText, arguments)
51}
52
53exports.PhoneNumberMatcher = function PhoneNumberMatcher(text, options) {
54 return core.PhoneNumberMatcher.call(this, text, options, metadata)
55}
56exports.PhoneNumberMatcher.prototype = Object.create(core.PhoneNumberMatcher.prototype, {})
57exports.PhoneNumberMatcher.prototype.constructor = exports.PhoneNumberMatcher
58
59exports.AsYouType = function AsYouType(country) {
60 return core.AsYouType.call(this, country, metadata)
61}
62exports.AsYouType.prototype = Object.create(core.AsYouType.prototype, {})
63exports.AsYouType.prototype.constructor = exports.AsYouType
64
65exports.isSupportedCountry = function isSupportedCountry(country) {
66 return call(core.isSupportedCountry, arguments)
67}
68
69exports.getCountries = function getCountries() {
70 return call(core.getCountries, arguments)
71}
72
73exports.getCountryCallingCode = function getCountryCallingCode() {
74 return call(core.getCountryCallingCode, arguments)
75}
76
77exports.getExtPrefix = function getExtPrefix(country) {
78 return call(core.getExtPrefix, arguments)
79}
80
81exports.getExampleNumber = function getExampleNumber() {
82 return call(core.getExampleNumber, arguments)
83}
84
85exports.formatIncompletePhoneNumber = function formatIncompletePhoneNumber() {
86 return call(core.formatIncompletePhoneNumber, arguments)
87}
88
89exports.parseIncompletePhoneNumber = core.parseIncompletePhoneNumber
90exports.parsePhoneNumberCharacter = core.parsePhoneNumberCharacter
91exports.parseDigits = core.parseDigits
92exports.DIGIT_PLACEHOLDER = core.DIGIT_PLACEHOLDER
93
94exports.parseRFC3966 = core.parseRFC3966
95exports.formatRFC3966 = core.formatRFC3966
\No newline at end of file