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-number-generator-js

v1.2.12

Published

Generates a random phone number following the E.164 international standard

Downloads

9,349

Readme

Phone number generator · PRs Welcome

What is phone number generator?

phone-number-generator-js a versatile JavaScript library that generates random mobile phone numbers in the E.164 format.

With this library, you can easily generate a completely random phone number or configure it to generate numbers specific to a particular country.

It supports a wide range of countries, with a total of 227 supported countries, allowing you to generate phone numbers that are valid and appropriate for various regions across the globe.

By default, if no configuration is provided, a totally random phone number will be generated from any of the 226 supported countries.

Relevant links:

Install

npm install phone-number-generator-js

// or

yarn add phone-number-generator-js

Usage

const { generatePhoneNumber } = require("phone-number-generator-js");

// or

import { generatePhoneNumber } from "phone-number-generator-js";

1. Simple usage

generatePhoneNumber(); // '+85265698900'

2. With config

Using countryName enum

generatePhoneNumber({ countryName: CountryNames.Austria }); // '+436508162890'

Using withoutCountryCode flag (defaults to false)

generatePhoneNumber({
  countryName: CountryNames.Austria,
  withoutCountryCode: true,
}); // '5483746575'

Test

npm run test

// or

yarn test

Build

npm run build

// or

yarn build

Supported countries:

| Countries | | | | | --------------------------------------------- | ----------------------------------- | ----------------------------------- | ------------------------------ | | Afghanistan 🇦🇫 | Albania 🇦🇱 | Algeria 🇩🇿 | American Samoa 🇦🇸 | | Andorra 🇦🇩 | Angola 🇦🇴 | Anguilla 🇦🇮 | Antigua and Barbuda 🇦🇬 | | Argentina 🇦🇷 | Armenia 🇦🇲 | Aruba 🇦🇼 | Australia 🇦🇺 | | Austria 🇦🇹 | Azerbaijan 🇦🇿 | Bahamas 🇧🇸 | Bahrain 🇧🇭 | | Bangladesh 🇧🇩 | Barbados 🇧🇧 | Belarus 🇧🇾 | Belgium 🇧🇪 | | Belize 🇧🇿 | Benin 🇧🇯 | Bermuda 🇧🇲 | Bhutan 🇧🇹 | | Bolivia 🇧🇴 | Bosnia and Herzegovina 🇧🇦 | Botswana 🇧🇼 | Brazil 🇧🇷 | | British Virgin Islands 🇻🇬 | Brunei Darussalam 🇧🇳 | Bulgaria 🇧🇬 | Burkina Faso 🇧🇫 | | Burundi 🇧🇮 | Cambodia 🇰🇭 | Cameroon 🇨🇲 | Canada 🇨🇦 | | Cape Verde 🇨🇻 | Cayman Islands 🇰🇾 | Central African Republic 🇨🇫 | Chad 🇹🇩 | | Chile 🇨🇱 | China 🇨🇳 | Colombia 🇨🇴 | Comoros 🇰🇲 | | Congo 🇨🇩 | Cook Islands 🇨🇰 | Costa Rica 🇨🇷 | Côte D'Ivoire 🇨🇮 | | Croatia 🇭🇷 | Cuba 🇨🇺 | Curaçao 🇨🇼 | Cyprus 🇨🇾 | | Czech Republic 🇨🇿 | Democratic Republic of the Congo 🇨🇩 | Denmark 🇩🇰 | Djibouti 🇩🇯 | | Dominica 🇩🇲 | Dominican Republic 🇩🇴 | East Timor 🇹🇱 | Ecuador 🇪🇨 | | Egypt 🇪🇬 | El Salvador 🇸🇻 | Equatorial Guinea 🇬🇶 | Eritrea 🇪🇷 | | Estonia 🇪🇪 | Eswatini 🇸🇿 | Ethiopia 🇪🇹 | Falkland Islands (Malvinas) 🇫🇰 | | Faroe Islands 🇫🇴 | Fiji 🇫🇯 | Finland 🇫🇮 | France 🇫🇷 | | French Guiana 🇬🇫 | French Polynesia 🇵🇫 | Gabon 🇬🇦 | Gambia 🇬🇲 | | Georgia 🇬🇪 | Germany 🇩🇪 | Ghana 🇬🇭 | Gibraltar 🇬🇮 | | Greece 🇬🇷 | Greenland 🇬🇱 | Grenada 🇬🇩 | Guadeloupe 🇬🇵 | | Guam 🇬🇺 | Guatemala 🇬🇹 | Guinea 🇬🇳 | Guinea-Bissau 🇬🇼 | | Guyana 🇬🇾 | Haiti 🇭🇹 | Honduras 🇭🇳 | Hong Kong 🇭🇰 | | Hungary 🇭🇺 | Iceland 🇮🇸 | India 🇮🇳 | Indonesia 🇮🇩 | | Iran 🇮🇷 | Iraq 🇮🇶 | Ireland 🇮🇪 | Israel 🇮🇱 | | Italy 🇮🇹 | Jamaica 🇯🇲 | Japan 🇯🇵 | Jordan 🇯🇴 | | Kazakhstan 🇰🇿 | Kenya 🇰🇪 | Korea, Republic of 🇰🇷 | | Kuwait 🇰🇼 | Kyrgyzstan 🇰🇬 | Lao People's Democratic Republic 🇱🇦 | Latvia 🇱🇻 | | Lebanon 🇱🇧 | Lesotho 🇱🇸 | Liberia 🇱🇷 | Libya 🇱🇾 | | Liechtenstein 🇱🇮 | Lithuania 🇱🇹 | Luxembourg 🇱🇺 | Macao 🇲🇴 | | Macedonia, the Former Yugoslav Republic Of 🇲🇰 | Madagascar 🇲🇬 | Malawi 🇲🇼 | Malaysia 🇲🇾 | | Maldives 🇲🇻 | Mali 🇲🇱 | Malta 🇲🇹 | Marshall Islands 🇲🇭 | | Martinique 🇲🇶 | Mauritania 🇲🇷 | Mauritius 🇲🇺 | Mexico 🇲🇽 | | Micronesia, Federated States Of 🇫🇲 | Moldova, Republic of 🇲🇩 | Monaco 🇲🇨 | | Mongolia 🇲🇳 | Montenegro 🇲🇪 | Montserrat 🇲🇸 | Morocco 🇲🇦 | | Mozambique 🇲🇿 | Myanmar 🇲🇲 | Namibia 🇳🇦 | Nauru 🇳🇷 | | Nepal 🇳🇵 | Netherlands 🇳🇱 | New Caledonia 🇳🇨 | New Zealand 🇳🇿 | | Nicaragua 🇳🇮 | Niger 🇳🇪 | Nigeria 🇳🇬 | Niue 🇳🇺 | | Norfolk Island 🇳🇫 | Northern Mariana Islands 🇲🇵 | Norway 🇳🇴 | Oman 🇴🇲 | | Pakistan 🇵🇰 | Palau 🇵🇼 | Panama 🇵🇦 | Papua New Guinea 🇵🇬 | | Paraguay 🇵🇾 | Peru 🇵🇪 | Philippines 🇵🇭 | Pitcairn 🇵🇳 | | Poland 🇵🇱 | Portugal 🇵🇹 | Puerto Rico 🇵🇷 | Qatar 🇶🇦 | | Réunion 🇷🇪 | Romania 🇷🇴 | Russian Federation 🇷🇺 | Rwanda 🇷🇼 | | Saint Helena 🇸🇭 | Saint Kitts And Nevis 🇰🇳 | Saint Lucia 🇱🇨 | Saint Pierre And Miquelon 🇵🇲 | | Saint Vincent And The Grenedines 🇻🇨 | Samoa 🇼🇸 | San Marino 🇸🇲 | Sao Tome and Principe 🇸🇹 | | Saudi Arabia 🇸🇦 | Senegal 🇸🇳 | Serbia 🇷🇸 | Seychelles 🇸🇨 | | Sierra Leone 🇸🇱 | Singapore 🇸🇬 | Sint Maarten 🇸🇽 | Slovakia 🇸🇰 | | Slovenia 🇸🇮 | Solomon Islands 🇸🇧 | Somalia 🇸🇴 | South Africa 🇿🇦 | | South Sudan 🇸🇸 | Spain 🇪🇸 | Sri Lanka 🇱🇰 | Sudan 🇸🇩 | | Suriname 🇸🇷 | Sweden 🇸🇪 | Switzerland 🇨🇭 | Syrian Arab Republic 🇸🇾 | | Taiwan 🇹🇼 | Tajikistan 🇹🇯 | Tanzania, United Republic of 🇹🇿 | Thailand 🇹🇭 | | Timor-Leste 🇹🇱 | Togo 🇹🇬 | Tokelau 🇹🇰 | Tonga 🇹🇴 | | Trinidad and Tobago 🇹🇹 | Tunisia 🇹🇳 | Turkey 🇹🇷 | Turkmenistan 🇹🇲 | | Turks and Caicos Islands 🇹🇨 | Tuvalu 🇹🇻 | Uganda 🇺🇬 | Ukraine 🇺🇦 | | United Arab Emirates 🇦🇪 | United Kingdom 🇬🇧 | United States 🇺🇸 | Uruguay 🇺🇾 | | Uzbekistan 🇺🇿 | Vanuatu 🇻🇺 | Vietnam 🇻🇳 | Yemen 🇾🇪 | | Virgin Islands, British 🇻🇬 | Virgin Islands, U.S. 🇻🇮 | Wallis and Futuna 🇼🇫 | | Zambia 🇿🇲 | Zimbabwe 🇿🇼 |

Credits

  1. Validating that the generated phone number is valid & following the E.164 format - libphonenumber-js
  2. Countries phone number data (country code, mobile starting digits & length) - phone