GithubHelp home page GithubHelp logo

kushanshamika / phone-lk Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 2.0 109 KB

NPM package to validate and reformat the Sri Lanka telephone number. ๐Ÿ‡ฑ๐Ÿ‡ฐ

License: MIT License

JavaScript 100.00%
sms npm-package phone-number nodejs

phone-lk's Introduction

npm npm Node.js CI codecov CodeFactor PRs Welcome Featured on Openbase

phone-lk

With a given phone number, validate and reformat the mobile phone number to the 94XXXXXXXXX and reveal information about phone numbers such as device category(mobile/landline), Service provider information, and landline geolocation. The purpose of this is to allow us to identify mobile numbers and format number to 94XXXXXXXXX that requires most local SMS gateway providers in Sri Lanka. ๐Ÿ‡ฑ๐Ÿ‡ฐ

Install

npm install phone-lk

or

yarn add phone-lk

Basic usage

Array Format

const {phone} = require('phone-lk');

phone("0775489485");        // -> [ '94775489485', 'mobile', 'dialog', null ]
phone("912225492");         // -> [ '94912225492', 'landline', 'sri lanka telecom', 'galle' ]
phone("0792225492");        // -> return [] as it is not valid Sri Lanka phone number

Object Format

const {phone} = require('phone-lk');

phone("0775489485", true);        // -> { isValid: true, formattedNumber: '94775489485', category: 'mobile', operator: 'dialog', area: null }
phone("912225492", true);         // -> { isValid: true, formattedNumber: '94912225492', category: 'landline', operator: 'sri lanka telecom', area: 'galle' ]
phone("0792225492", true);        // -> { isValid: false }

Returned Values

Category

  • mobile
  • landline

Landline Operators

  • sri lanka telecom
  • dialog
  • lanka bell
  • tritel

Mobile Operators

  • mobitel
  • dialog
  • hutch
  • airtel

Area Codes

  • ampara
  • anuradhapura
  • avissawella
  • bandarawela
  • batticalo
  • chilaw
  • colombo
  • galle
  • gampaha
  • hambantota
  • hatton
  • jaffna
  • kalmunai
  • kalutara
  • kandy
  • kegalle
  • kurunagala
  • mannar
  • matale
  • matara
  • monaragala
  • nawalapitiya
  • negombo
  • nuwara eliya
  • panadura
  • polonnaruwa
  • ratnapura
  • trincomalee
  • vauniya

License

This project is licensed under the MIT license.

phone-lk's People

Contributors

kushanshamika avatar bhanukauom avatar rprabhashvara avatar

Stargazers

Geethmaka Dissanayake avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.