phone-carrier

1.0.5 • Public • Published

phone-carrier

Installation

npm install phone-carrier

Description

  1. You have a VALID cell phone number.
  2. You want the cell phone carrier's name!
  3. Input it into the mapper this package provides to get it.
  • Use it as you would Google's libphonenumber's PhoneNumberToCarrierMapper in Java
  • Is a TypeScript rendition of PhoneNumberToCarrierMapper because the JavaScript version of libphonenumber on NPM didn't have a PhoneNumberToCarrierMapper
  • Batteries included. Mobile carrier names are read from included binary-encoded files.
  • Has no error handling (we read from files). Be sure to try-catch your async functions and .catch your promises.
  • Depends upon NPM package libphonenumber-js

Quick Start / API

// Example 1: ESM and await syntax
import PhoneNumberToCarrierMapper from 'phone-carrier';

async function lookup(msisdn) {
    const mapper = PhoneNumberToCarrierMapper.getInstance();
    const carrierName = await mapper.getNameForValidNumber(msisdn);
    return carrierName;
}
console.log(lookup(`+41798765432`)); // Swisscom
// Example 2: CommonJS and promise syntax
const { PhoneNumberToCarrierMapper } = require('phone-carrier')

const mapper = PhoneNumberToCarrierMapper.getInstance()
mapper.getNameForValidNumber(`+917897888888`).then(console.log) // AirTel

Package Sidebar

Install

npm i phone-carrier

Weekly Downloads

0

Version

1.0.5

License

none

Unpacked Size

244 kB

Total Files

258

Last publish

Collaborators

  • featurerich1