libphonenumber-js 1.10.38 → 1.10.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/metadata.js +1 -1
- package/build/metadata.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/core/index.d.cts +115 -0
- package/es6/metadata.js +1 -1
- package/es6/metadata.js.map +1 -1
- package/examples.mobile.json.d.cts +4 -0
- package/index.d.cts +170 -0
- package/metadata.full.json +1 -1
- package/metadata.full.json.d.cts +4 -0
- package/metadata.full.json.js +1 -1
- package/metadata.max.json +1 -1
- package/metadata.max.json.d.cts +4 -0
- package/metadata.max.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.d.cts +4 -0
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.d.cts +4 -0
- package/metadata.mobile.json.js +1 -1
- package/min/index.d.cts +102 -0
- package/package.json +5 -21
- package/source/metadata.js +1 -1
package/min/index.d.cts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MetadataJson,
|
|
3
|
+
Examples,
|
|
4
|
+
PhoneNumber,
|
|
5
|
+
E164Number,
|
|
6
|
+
CountryCallingCode,
|
|
7
|
+
CountryCode,
|
|
8
|
+
CarrierCode,
|
|
9
|
+
NationalNumber,
|
|
10
|
+
Extension,
|
|
11
|
+
ParseError,
|
|
12
|
+
NumberFoundLegacy,
|
|
13
|
+
NumberFound,
|
|
14
|
+
NumberType,
|
|
15
|
+
NumberFormat,
|
|
16
|
+
NumberingPlan,
|
|
17
|
+
ValidatePhoneNumberLengthResult
|
|
18
|
+
} from '../types.d.js';
|
|
19
|
+
|
|
20
|
+
// They say this re-export is required.
|
|
21
|
+
// https://github.com/catamphetamine/libphonenumber-js/pull/290#issuecomment-453281180
|
|
22
|
+
export {
|
|
23
|
+
MetadataJson,
|
|
24
|
+
Examples,
|
|
25
|
+
PhoneNumber,
|
|
26
|
+
E164Number,
|
|
27
|
+
CountryCallingCode,
|
|
28
|
+
CountryCode,
|
|
29
|
+
CarrierCode,
|
|
30
|
+
NationalNumber,
|
|
31
|
+
Extension,
|
|
32
|
+
ParseError,
|
|
33
|
+
NumberFoundLegacy,
|
|
34
|
+
NumberFound,
|
|
35
|
+
NumberType,
|
|
36
|
+
NumberFormat,
|
|
37
|
+
NumberingPlan,
|
|
38
|
+
ValidatePhoneNumberLengthResult
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// `parsePhoneNumber()` named export has been renamed to `parsePhoneNumberWithError()`.
|
|
42
|
+
export function parsePhoneNumber(text: string, defaultCountry?: CountryCode): PhoneNumber;
|
|
43
|
+
|
|
44
|
+
export function parsePhoneNumberWithError(text: string, defaultCountry?: CountryCode): PhoneNumber;
|
|
45
|
+
|
|
46
|
+
// `parsePhoneNumberFromString()` named export is now considered legacy:
|
|
47
|
+
// it has been promoted to a default export due to being too verbose.
|
|
48
|
+
export function parsePhoneNumberFromString(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extract?: boolean }): PhoneNumber | undefined;
|
|
49
|
+
|
|
50
|
+
export default parsePhoneNumberFromString;
|
|
51
|
+
|
|
52
|
+
export function isValidPhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
53
|
+
export function isPossiblePhoneNumber(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): boolean;
|
|
54
|
+
export function validatePhoneNumberLength(text: string, defaultCountry?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string }): ValidatePhoneNumberLengthResult | undefined;
|
|
55
|
+
|
|
56
|
+
export function findNumbers(text: string, options?: CountryCode): NumberFoundLegacy[];
|
|
57
|
+
export function searchNumbers(text: string, options?: CountryCode): IterableIterator<NumberFoundLegacy>;
|
|
58
|
+
|
|
59
|
+
export function findNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): NumberFound[];
|
|
60
|
+
export function searchNumbers(text: string, options?: { defaultCountry?: CountryCode, v2: true }): IterableIterator<NumberFound>;
|
|
61
|
+
|
|
62
|
+
export function findPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extended?: boolean }): NumberFound[];
|
|
63
|
+
export function searchPhoneNumbersInText(text: string, options?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string, extended?: boolean }): IterableIterator<NumberFound>;
|
|
64
|
+
|
|
65
|
+
export class PhoneNumberMatcher {
|
|
66
|
+
constructor(text: string, options?: { defaultCountry?: CountryCode, v2: true });
|
|
67
|
+
hasNext(): boolean;
|
|
68
|
+
next(): NumberFound | undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function isSupportedCountry(countryCode: CountryCode): boolean;
|
|
72
|
+
export function getCountries(): CountryCode[];
|
|
73
|
+
export function getCountryCallingCode(countryCode: CountryCode): CountryCallingCode;
|
|
74
|
+
export function getExtPrefix(countryCode: CountryCode): string;
|
|
75
|
+
|
|
76
|
+
export function getExampleNumber(country: CountryCode, examples: Examples): PhoneNumber | undefined;
|
|
77
|
+
|
|
78
|
+
export function formatIncompletePhoneNumber(number: string, countryCode?: CountryCode): string;
|
|
79
|
+
export function parseIncompletePhoneNumber(text: string): string;
|
|
80
|
+
export function parsePhoneNumberCharacter(character: string): string;
|
|
81
|
+
export function parseDigits(character: string): string;
|
|
82
|
+
|
|
83
|
+
export class AsYouType {
|
|
84
|
+
constructor(defaultCountryCode?: CountryCode | { defaultCountry?: CountryCode, defaultCallingCode?: string });
|
|
85
|
+
input(text: string): string;
|
|
86
|
+
reset(): void;
|
|
87
|
+
getNumber(): PhoneNumber | undefined;
|
|
88
|
+
getNumberValue(): E164Number | undefined;
|
|
89
|
+
getChars(): string;
|
|
90
|
+
getTemplate(): string;
|
|
91
|
+
getCallingCode(): string | undefined;
|
|
92
|
+
getCountry(): CountryCode | undefined;
|
|
93
|
+
isInternational(): boolean;
|
|
94
|
+
isPossible(): boolean;
|
|
95
|
+
isValid(): boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class Metadata {
|
|
99
|
+
constructor();
|
|
100
|
+
selectNumberingPlan(country: CountryCode): void;
|
|
101
|
+
numberingPlan?: NumberingPlan;
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -1,103 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libphonenumber-js",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.40",
|
|
4
4
|
"description": "A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript",
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./index.d.ts",
|
|
11
10
|
"import": "./index.js",
|
|
12
11
|
"require": "./index.cjs"
|
|
13
12
|
},
|
|
14
13
|
"./min": {
|
|
15
|
-
"types": "./min/index.d.ts",
|
|
16
14
|
"import": "./min/index.js",
|
|
17
15
|
"require": "./min/index.cjs"
|
|
18
16
|
},
|
|
19
17
|
"./max": {
|
|
20
|
-
"types": "./min/index.d.ts",
|
|
21
18
|
"import": "./max/index.js",
|
|
22
19
|
"require": "./max/index.cjs"
|
|
23
20
|
},
|
|
24
21
|
"./mobile": {
|
|
25
|
-
"types": "./min/index.d.ts",
|
|
26
22
|
"import": "./mobile/index.js",
|
|
27
23
|
"require": "./mobile/index.cjs"
|
|
28
24
|
},
|
|
29
25
|
"./core": {
|
|
30
|
-
"types": "./core/index.d.ts",
|
|
31
26
|
"import": "./core/index.js",
|
|
32
27
|
"require": "./core/index.cjs"
|
|
33
28
|
},
|
|
34
29
|
"./min/metadata": {
|
|
35
|
-
"types": "./metadata.min.json.d.ts",
|
|
36
30
|
"import": "./metadata.min.json.js",
|
|
37
31
|
"require": "./metadata.min.json"
|
|
38
32
|
},
|
|
39
33
|
"./metadata.min": {
|
|
40
|
-
"types": "./metadata.min.json.d.ts",
|
|
41
34
|
"import": "./metadata.min.json.js",
|
|
42
35
|
"require": "./metadata.min.json"
|
|
43
36
|
},
|
|
44
37
|
"./metadata.min.json": {
|
|
45
|
-
"types": "./metadata.min.json.d.ts",
|
|
46
38
|
"import": "./metadata.min.json.js",
|
|
47
39
|
"require": "./metadata.min.json"
|
|
48
40
|
},
|
|
49
41
|
"./metadata.full": {
|
|
50
|
-
"types": "./metadata.max.json.d.ts",
|
|
51
42
|
"import": "./metadata.max.json.js",
|
|
52
43
|
"require": "./metadata.max.json"
|
|
53
44
|
},
|
|
54
45
|
"./metadata.full.json": {
|
|
55
|
-
"types": "./metadata.max.json.d.ts",
|
|
56
46
|
"import": "./metadata.max.json.js",
|
|
57
47
|
"require": "./metadata.max.json"
|
|
58
48
|
},
|
|
59
49
|
"./max/metadata": {
|
|
60
|
-
"types": "./metadata.max.json.d.ts",
|
|
61
50
|
"import": "./metadata.max.json.js",
|
|
62
51
|
"require": "./metadata.max.json"
|
|
63
52
|
},
|
|
64
53
|
"./metadata.max": {
|
|
65
|
-
"types": "./metadata.max.json.d.ts",
|
|
66
54
|
"import": "./metadata.max.json.js",
|
|
67
55
|
"require": "./metadata.max.json"
|
|
68
56
|
},
|
|
69
57
|
"./metadata.max.json": {
|
|
70
|
-
"types": "./metadata.max.json.d.ts",
|
|
71
58
|
"import": "./metadata.max.json.js",
|
|
72
59
|
"require": "./metadata.max.json"
|
|
73
60
|
},
|
|
74
61
|
"./mobile/metadata": {
|
|
75
|
-
"types": "./metadata.mobile.json.d.ts",
|
|
76
62
|
"import": "./metadata.mobile.json.js",
|
|
77
63
|
"require": "./metadata.mobile.json"
|
|
78
64
|
},
|
|
79
65
|
"./metadata.mobile": {
|
|
80
|
-
"types": "./metadata.mobile.json.d.ts",
|
|
81
66
|
"import": "./metadata.mobile.json.js",
|
|
82
67
|
"require": "./metadata.mobile.json"
|
|
83
68
|
},
|
|
84
69
|
"./metadata.mobile.json": {
|
|
85
|
-
"types": "./metadata.mobile.json.d.ts",
|
|
86
70
|
"import": "./metadata.mobile.json.js",
|
|
87
71
|
"require": "./metadata.mobile.json"
|
|
88
72
|
},
|
|
89
73
|
"./mobile/examples": {
|
|
90
|
-
"types": "./examples.mobile.json.d.ts",
|
|
91
74
|
"import": "./examples.mobile.json.js",
|
|
92
75
|
"require": "./examples.mobile.json"
|
|
93
76
|
},
|
|
94
77
|
"./examples.mobile": {
|
|
95
|
-
"types": "./examples.mobile.json.d.ts",
|
|
96
78
|
"import": "./examples.mobile.json.js",
|
|
97
79
|
"require": "./examples.mobile.json"
|
|
98
80
|
},
|
|
99
81
|
"./examples.mobile.json": {
|
|
100
|
-
"types": "./examples.mobile.json.d.ts",
|
|
101
82
|
"import": "./examples.mobile.json.js",
|
|
102
83
|
"require": "./examples.mobile.json"
|
|
103
84
|
},
|
|
@@ -113,6 +94,7 @@
|
|
|
113
94
|
"@babel/register": "^7.17.7",
|
|
114
95
|
"babel-plugin-istanbul": "^6.1.1",
|
|
115
96
|
"chai": "^4.3.6",
|
|
97
|
+
"cpy-cli": "^5.0.0",
|
|
116
98
|
"crlf": "^1.1.1",
|
|
117
99
|
"cross-env": "^7.0.3",
|
|
118
100
|
"istanbul": "^1.1.0-alpha.1",
|
|
@@ -121,6 +103,7 @@
|
|
|
121
103
|
"mocha": "^10.0.0",
|
|
122
104
|
"npm-run-all": "^4.1.5",
|
|
123
105
|
"nyc": "^15.1.0",
|
|
106
|
+
"renamer": "^4.0.0",
|
|
124
107
|
"rimraf": "^3.0.2",
|
|
125
108
|
"rollup": "^2.73.0",
|
|
126
109
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -155,10 +138,11 @@
|
|
|
155
138
|
"coveralls--nyc-is-very-slow-and-is-not-used": "nyc report --reporter=text-lcov | coveralls",
|
|
156
139
|
"test-travis": "node --experimental-json-modules node_modules/istanbul/lib/cli.js cover -x \"build/**\" -x \"es6/**\" -x \"*.test.js\" -x \"source/findNumbers/Leniency.js\" -x \"source/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js\" -x \"source/findNumbers/RegExpCache.js\" -x \"source/findNumbers/LRUCache.js\" -x \"source/PhoneNumberMatcher.js\" -x \"source/tools/semver-compare.js\" node_modules/mocha/bin/_mocha --report lcovonly -- --colors --reporter spec --require ./test/setup.js \"source/**/*.test.js\" \"test/**/*.test.js\" --recursive",
|
|
157
140
|
"clean": "rimraf ./build/**/* ./es6/**/*",
|
|
158
|
-
"build:commonjs": "npm-run-all build:commonjs:with-tests build:commonjs:package.json",
|
|
141
|
+
"build:commonjs": "npm-run-all build:commonjs:with-tests build:commonjs:package.json build:commonjs:create-typescript-definitions",
|
|
159
142
|
"build:commonjs:before-es-modules": "cross-env BABEL_ENV=commonjs babel ./source --out-dir ./build --source-maps --ignore test.js",
|
|
160
143
|
"build:commonjs:with-tests": "cross-env BABEL_ENV=commonjs babel ./source --out-dir ./build --source-maps",
|
|
161
144
|
"build:commonjs:package.json": "node runnable/create-commonjs-package-json.js",
|
|
145
|
+
"build:commonjs:create-typescript-definitions": "rimraf --verbose --glob ./*.d.cts ./!(node_modules)/**/*.d.cts && cpy **/{index,metadata*,examples*}.d.ts . --rename={{basename}}.cts && renamer --find d.cts.ts --replace d.cts ./*.d.cts.ts ./!(node_modules)/**/*.d.cts.ts",
|
|
162
146
|
"build:modules": "cross-env BABEL_ENV=es6 babel ./source --out-dir ./es6 --source-maps --ignore test.js",
|
|
163
147
|
"build:bundle": "rollup --config rollup.config.mjs",
|
|
164
148
|
"build": "npm-run-all clean build:commonjs build:modules build:bundle",
|
package/source/metadata.js
CHANGED
|
@@ -511,7 +511,7 @@ export function getCountryCallingCode(country, metadata) {
|
|
|
511
511
|
export function isSupportedCountry(country, metadata) {
|
|
512
512
|
// metadata = new Metadata(metadata)
|
|
513
513
|
// return metadata.hasCountry(country)
|
|
514
|
-
return metadata.countries
|
|
514
|
+
return metadata.countries.hasOwnProperty(country)
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
function setVersion(metadata) {
|