guess-calling-code
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

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)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.8
    1,396
    • latest

Version History

Package Sidebar

Install

npm i guess-calling-code

Weekly Downloads

1,396

Version

1.1.8

License

MIT

Unpacked Size

41.9 kB

Total Files

7

Last publish

Collaborators

  • suiko