libphonenumber-geo-carrier
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -5,1 +5,2 @@ import { PhoneNumber } from 'libphonenumber-js'; | ||
export declare const carrier: (phonenumber: PhoneNumber | undefined, locale?: CarrierLocale) => Promise<string | null>; | ||
export declare const timezones: (phonenumber: PhoneNumber | undefined) => Promise<string[] | null>; |
@@ -143,3 +143,23 @@ import fs from 'fs'; | ||
}; | ||
var timezones = function (phonenumber) { return __awaiter(void 0, void 0, void 0, function () { | ||
var countryCallingCode, dataPath, zones; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!phonenumber) { | ||
return [2 /*return*/, null]; | ||
} | ||
countryCallingCode = phonenumber.countryCallingCode; | ||
dataPath = path.join(__dirname, '../resources/timezones.bson'); | ||
return [4 /*yield*/, getCode(dataPath, countryCallingCode)]; | ||
case 1: | ||
zones = _a.sent(); | ||
if (typeof zones === 'string') { | ||
return [2 /*return*/, zones.split('&')]; | ||
} | ||
return [2 /*return*/, null]; | ||
} | ||
}); | ||
}); }; | ||
export { carrier, geocoder }; | ||
export { carrier, geocoder, timezones }; |
@@ -149,4 +149,25 @@ 'use strict'; | ||
}; | ||
var timezones = function (phonenumber) { return __awaiter(void 0, void 0, void 0, function () { | ||
var countryCallingCode, dataPath, zones; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!phonenumber) { | ||
return [2 /*return*/, null]; | ||
} | ||
countryCallingCode = phonenumber.countryCallingCode; | ||
dataPath = path.join(__dirname, '../resources/timezones.bson'); | ||
return [4 /*yield*/, getCode(dataPath, countryCallingCode)]; | ||
case 1: | ||
zones = _a.sent(); | ||
if (typeof zones === 'string') { | ||
return [2 /*return*/, zones.split('&')]; | ||
} | ||
return [2 /*return*/, null]; | ||
} | ||
}); | ||
}); }; | ||
exports.carrier = carrier; | ||
exports.geocoder = geocoder; | ||
exports.timezones = timezones; |
{ | ||
"name": "libphonenumber-geo-carrier", | ||
"version": "1.0.1", | ||
"description": "This library includes the geocoding and carrier mapping functionalities that are available in some of googles libphonenumber libraries but not in libphonenumber-js (a port of libphonenumber).", | ||
"version": "1.1.0", | ||
"description": "This library includes the geocoding, carrier mapping and timezone mapping functionalities that are available in some of googles libphonenumber libraries but not in libphonenumber-js (a port of libphonenumber).", | ||
"main": "lib/index.js", | ||
@@ -17,9 +17,13 @@ "module": "lib/index.es.js", | ||
"watch": "rimraf lib && rollup -cw", | ||
"prepublish": "yarn build", | ||
"preparemetadata": "rimraf resources && node tools/prepare.js && rimraf resources/libphonenumber" | ||
"prepublishOnly": "yarn build", | ||
"preparemetadata": "rimraf resources && node tools/prepare.js && rimraf resources/libphonenumber", | ||
"test": "jest" | ||
}, | ||
"devDependencies": { | ||
"@types/bson": "^4.0.2", | ||
"@types/jest": "^25.1.4", | ||
"@types/node": "^13.9.3", | ||
"@types/shelljs": "^0.8.7", | ||
"jest": "^25.1.0", | ||
"libphonenumber-js": "^1.7.48", | ||
"prettier": "^2.0.1", | ||
@@ -30,2 +34,3 @@ "rimraf": "^3.0.2", | ||
"shelljs": "^0.8.3", | ||
"ts-jest": "^25.2.1", | ||
"tslib": "^1.11.1", | ||
@@ -46,3 +51,14 @@ "typescript": "^3.8.3" | ||
"url": "https://github.com/mmende/libphonenumber-geo-carrier/issues" | ||
} | ||
}, | ||
"keywords": [ | ||
"telephone", | ||
"phone", | ||
"number", | ||
"geo", | ||
"geocode", | ||
"location", | ||
"carrier", | ||
"international", | ||
"libphonenumber" | ||
] | ||
} |
# What does this library do? | ||
This library includes the geocoding and carrier mapping functionalities that are available in some of googles libphonenumber libraries but not in libphonenumber-js (a port of libphonenumber). | ||
This library includes the geocoding, carrier mapping and timezone mapping functionalities that are available in some of googles libphonenumber libraries but not in libphonenumber-js (a port of libphonenumber). | ||
To reduce the amount of data that needs to be loaded to geocode / carrier map a phonenumber for each mapping only the relevant number prefixes are loaded from a binary json file (BSON). | ||
@@ -24,3 +24,3 @@ When the prefix could not be found in the provided locale the library tries to fallback to `en` as locale. | ||
import { parsePhoneNumberFromString } from 'libphonenumber-js' | ||
import { geocoder, carrier } from 'libphonenumber-geo-carrier' | ||
import { geocoder, carrier, timezone } from 'libphonenumber-geo-carrier' | ||
@@ -33,8 +33,10 @@ const main = async () => { | ||
const mobileNumber = parsePhoneNumberFromString('01701234567', 'DE') | ||
const originalCarrier = await carrier(mobileNumber) // T-Mobile | ||
// Works with locale as well, but there are not so much translations available for carriers: | ||
// const originalCarrier = await carrier(fixedLineNumber, 'zh') | ||
const mobileNumber = parsePhoneNumberFromString('+8619912345678') | ||
const carrierEN = await carrier(mobileNumber) // China Telecom | ||
const carrierZH = await carrier(mobileNumber, 'zh') // 中国电信 | ||
const fixedLineNumber2 = parsePhoneNumberFromString('+49301234567') | ||
const tzones = await timezone(fixedLineNumber2) // ['Europe/Berlin'] | ||
} | ||
main() | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
13097376
326
41
14