npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

phone-formater-eth

v1.1.8

Published

Format Ethiopian phone numbers and check ISP under the number.

Downloads

507

Readme

Ethiopia Phone Number Formatter 🇪🇹

A simple npm package to format Ethiopian phone numbers to the ISP standard code.

Installation via npm

npm install  --save phone-formater-eth

Via CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"></script>

Usage

const { formatPhone, checkOperator, isValid, parse} = require('phone-formater-eth');
  
  Or

import { formatPhone, checkOperator, isValid, parse } from 'phone-formater-eth';
  1. formatPhone - Formats an Ethiopian phone number to the ISP standard code.
    Parameters - phone (string), type (string) ("local" | "international" (default)): The phone number to format.
    Returns - (string): The formatted phone number in ISP standard code.

    Examples

console.log(formatPhone('0912345678'));            // Outputs: +251912345678 - Int'l format
console.log(formatPhone('+251712345678',"local")); // Outputs: 0712345678    - Local
console.log(formatPhone('251912345678'."local"));  // Outputs: 0912345678    - Local
console.log(formatPhone('09123456789'));           // Outputs: +2519123456789
console.log(formatPhone('0712345678',"local"));    // Outputs: 0712345678    - Local
console.log(formatPhone('25191234567'));           // Outputs: +25191234567
console.log(formatPhone('0801234567'));            // Outputs: Invalid Phone
  1. checkOperator - Checks the phone operator based on the formatted Ethiopian phone number.
    Parameters - phone (string): The phone number to check.
    Returns - (string): The operator name or "Unknown" if the operator can't be determined.

    Examples

console.log(checkOperator('712345678'));      // Outputs: Safaricom
console.log(checkOperator('+251912345678'));  // Outputs: Ethio Telecom
console.log(checkOperator('0712345678'));     // Outputs: Safaricom
console.log(checkOperator('251912345678'));   // Outputs: Ethio Telecom
console.log(checkOperator('0812345678'));     // Outputs: Unknown
  1. isValid - Checks if phone number is valid or not
    Parameters - phone (string): The phone number to check.
    Returns - (boolean): true if the phone is valid else false

    Examples

console.log(isValid('712345678'));      // Outputs: true
console.log(isValid('+251912345678'));  // Outputs: true
console.log(isValid('07812345678'));    // Outputs: false
console.log(isValid('251912345678'));   // Outputs: true
console.log(isValid('0812345678'));     // Outputs: false
  1. parse - Parse phone number to remove special characters like '-' and '(' ')'
    Parameters - phone (string): The phone number to cleaned.
    Returns - (string): The cleaned phone number if the phone is valid else "INVALID_PHONE_NUMBER"

    Examples

console.log(parse("(251) 911-123-456")); //25191112456
console.log(parse("(251) 911-123-456")); //25191112456
console.log(parse("251-911-123-456"));   //25191112456
console.log(parse("2519-11-123-456"));   //25191112456

TODO ☑️

  1. isMobile - check if it's mobile sim. eg 09/07/+2519/7

  2. isLandline - check if it's landline sim. eg. +2511

Contributions

PLease submit your contributions as PRs and also leave a good description for the PR

License

This project is licensed under the MIT License. See the LICENSE file for more information.