Giter Club home page Giter Club logo

guess-calling-code's Introduction

guess-calling-code

npm FOSSA Status Codecov

Client-side resolution for acquiring the user's dialing code enables seamless phone number input within browsers, and this library is also compatible with Node.js!

Install

Using npm:

npm install guess-calling-code

Using yarn:

yarn add guess-calling-code

Usage

This library can be used in both browser and Node.js environments.

Browser Usage

First, include the library in your HTML file:

<script src="https://cdn.jsdelivr.net/npm/guess-calling-code/dist/index.umd.js"></script>

Then, in your JavaScript code:

const guessCallingCode = window.guessCallingCode;
const callingCode = guessCallingCode(); // example output: "1" (for United States users)

Node.js Usage

npm install guess-calling-code

or

yarn add guess-calling-code

Then, in your JavaScript code:

const guessCallingCode = require("guess-calling-code");
const callingCode = guessCallingCode(); // example output: "1" (for United States users)

TypeScript Usage

import guessCallingCode from "guess-calling-code";
const callingCode = guessCallingCode(); // example output: "1" (for United States users)

API

guessCallingCode(): string | undefined

This function returns the calling code as a string based on the user's current time zone city.

Support

If you have any questions or need help, please open an issue on the GitHub repository, and we will do our best to assist you.

Further Reading

Curious about how it works? Check out this blog post.

License

LICENSE (MIT)

guess-calling-code's People

Contributors

fossabot avatar suikodev avatar unclebill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

guess-calling-code's Issues

A new API to include country name

It would be useful to have another API (maybe a wrapper around the current one) which returns the country name as well

e.g. +1 (United States)

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.