Coder Social home page Coder Social logo

kaungmyatlwin / myanmar-phonenumber Goto Github PK

View Code? Open in Web Editor NEW
56.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.

myanmar-phonenumber's People

Contributors

greenlikeorange avatar kaungmyatlwin avatar thurahtetaung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

myanmar-phonenumber's Issues

Use dash instead of dot in module filename (aka myanmar-phonenumber.js)

I am trying to use your package in one of my react native application and running into the problem below.

error: bundling failed: Error: While trying to resolve module myanmar-phonenumber from file /Users/thurahlaing/Devel/.../src/screens/signin/First.js, the package /Users/thurahlaing/Devel/.../node_modules/myanmar-phonenumber/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/thurahlaing/Devel/.../node_modules/myanmar-phonenumber/myanmar-phonenumber.js. Indeed, none of these files exist:

/Users/thurahlaing/Devel/.../node_modules/myanmar-phonenumber/myanmar-phonenumber.js(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)

/Users/thurahlaing/Devel/.../node_modules/myanmar-phonenumber/myanmar-phonenumber.js/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)

It should be resolved if you change the filename to have the same name as package name.

Not working with empty string

let phone=""
when calling isValidMMPhoneNumber(phone) return nothing.
and
let phone=" ";
when calling isValidMMPhoneNumber(phone) return false.

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.