Coder Social home page Coder Social logo

kaungmyatlwin / myanmar-phonenumber Goto Github PK

View Code? Open in Web Editor NEW
57.0 4.0 14.0 49 KB

Javascript module port (for browsers and node) of (https://github.com/Melomap/mm_phonenumber) to check valid myanmar mobile numbers, get mobile operator's name, sanitize mobile numbers and get mobile network types.

License: Apache License 2.0

JavaScript 100.00%
myanmar phone-number ooredoo telenor mpt mobile-networks javascript mytel

myanmar-phonenumber's Introduction

Javascript module port (for browsers and node) of mm_phonenumber to check valid myanmar mobile numbers, get mobile operator's name, sanitize mobile numbers and get mobile network types.

Credit: Original script (Python)

Demo: Web Demo

Installation

If you have NPM installed,

npm install myanmar-phonenumber --save

Or if you're using for browser, download it and include in your document as shown below.

For CDN users, include the following URL.

https://unpkg.com/myanmar-phonenumber

Usage

In browser

// this is example script
<script src="path/to/myanmar.phonenumber.js"></script>
<script>
    console.log(myanmarPhoneNumber.normalizeInput('+၉၅၉၇၈၄၁၂၃၄၅၆')); // returns 09784123456
    console.log(myanmarPhoneNumber.normalizeInput('+959784123456')); // returns 09784123456
    console.log(myanmarPhoneNumber.getTelecomName('09978412345')); // returns Ooredoo
    console.log(myanmarPhoneNumber.getPhoneNetworkType('09978412345')); // returns GSM
    console.log(myanmarPhoneNumber.isValidMMPhoneNumber('09978412345')); // returns true if it meets Myanmar Phone Number conditions
</script>

In Node environment

var myanmarPhoneNumber = require('/path/to/myanmar.phonenumber.js');
console.log(myanmarPhoneNumber.normalizeInput('+၉၅၉၇၈၄၁၂၃၄၅၆')); // returns 09784123456
console.log(myanmarPhoneNumber.normalizeInput('+959784123456')); // returns 09784123456
console.log(myanmarPhoneNumber.getTelecomName('09978412345')); // returns Ooredoo
console.log(myanmarPhoneNumber.getPhoneNetworkType('09978412345')); // returns GSM
console.log(myanmarPhoneNumber.isValidMMPhoneNumber('09978412345')); // returns true if it meets Myanmar Phone Number conditions

TypeScript

For the usage with TypeScript, refer to @types/myanmar-phonenumber. Big thanks to @HtetOoWaiYan for the contribution on DefinitelyTyped repo.

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.