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

ethiopian-phone

v1.4.6

Published

Set of helper utilities to validate, parse and format Ethiopian phone numbers.

Downloads

21

Readme

Ethiopian-phone

Set of helper utilities to validate, parse and format Ethiopian phone numbers.

Build Status Coverage Status

Features

  • Ethiopian phone number validation and formatting.
  • Find location data of phone numbers.
  • Check whether number is mobile or landline.
  • Works in the browser and Node.JS
  • <4 KB minified and gzipped.

Demo : https://etphone.herokuapp.com

Install

npm install ethiopian-phone

Import

ES6 module

import { validate, findArea } from 'ethiopian-phone'

Node.JS

const etPhone = require('ethiopian-phone')

Import to the browser from a CDN

<script src="https://unpkg.com/ethiopian-phone/dist/ethiopian-phone.min.js"></script>

Note

If you only need to validate a phone number on an input form before submission, go with simple web best practices.

<input type='tel' maxlength='10' pattern='^09\d{8}$' value='09' autocomplete='on' required>

Usage

const etPhone = require('ethiopian-phone');

let phone = '0911346652';

etPhone.validate(phone) // True
etPhone.format(phone)   // 09 11 34 66 52

Validate

Checks whether given input is a valid Ethiopian phone number.

etPhone.validate('0911885641')     // True
etPhone.validate('+251115150126')  // True
etPhone.validate('09 11 52 39 17') // True

etPhone.validate('09135692')    // False
etPhone.validate('+4604121343') // False

Parse

Cleans up | normalizes phone number.

etPhone.parse('09-21-31-43-32')  // 0921314332
etPhone.parse('+(251)116625697') // 251116625697

// Raises detailed error when input is invalid
etPhone.parse('09135692')    // TypeError: Phone number too short
etPhone.parse('+460721343') // TypeError: Not Ethiopian phone number

Format

Converts phone number into an easily readable format.

etPhone.format('+251116625697') // 251 112 70 56 97
etPhone.format('0112702784')    // 011 270 27 84
etPhone.format('0911885641')    // 09 11 88 56 41

Find Area

Retrieves location data of given phone number based on area code.

etPhone.findArea('0113215476') // Mekanisa, South West Addis Ababa
etPhone.findArea('0112702784') // Asko, Western Addis Ababa

etPhone.findArea('0223319750') // Asela, South East Ethiopia
etPhone.findArea('0587764412') // Dejen, North West Ethiopia
etPhone.findArea('0916771836') // South Ethiopia
  • Location data is based on https://www.itu.int/oth/T0202000044/en
  • Some of the data might be outdated due to naming changes.
  • Detailed location is only available for Landline numbers, you can get some regional info for mobile phones.
  • The location data for mobile phones only indicates where the simcard was bought from and does not necessarily reflect the current location of the phone.

toLocal

Converts phone number to local | Ethiopian format.

etPhone.toLocal('251911885641')  // 0911885641
etPhone.toLocal('+251116625697') // 0116625697

toInternational

Converts phone number to International format.

etPhone.toInternational('0911885641') // +251911885641
etPhone.toInternational('0116625697') // +251116625697

isMobile

Checks whether given number is a mobile sim.

etPhone.isMobile('0911885641') // True
etPhone.isMobile('0116625697') // False

isLandline

Checks whether given number is a landline.

etPhone.isLandline('0116625697') // True
etPhone.isLandline('0911885641') // False

isLocal

Checks whether given number is in local | Ethiopian format.

etPhone.isLocal('0911885641')    // True
etPhone.isLocal('+251116625697') // False

isInternational

Checks whether given number is in international format.

etPhone.isInternational('+251116625697') // True
etPhone.isInternational('0911885641')    // False

Test

$ npm run test

License

MIT © Michael Tsegaye