# guess-calling-code

> 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!

Latest version **1.1.8** (published 2023-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install guess-calling-code
pnpm add guess-calling-code
yarn add guess-calling-code
bun add guess-calling-code
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2023-06-26 |
| First published | 2023-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 40.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Suiko |
| Maintainers | suiko |
| Keywords | calling, code, phone, number, input, country, countries, country-code, country-calling-code, phone-number, phone-input, phone-number-input |

## Links

- npm: https://www.npmjs.com/package/guess-calling-code
- Repository: https://github.com/AstraSurge/guess-calling-code
- Homepage: https://guess-calling-code.astrasurge.com/
- Issues: https://github.com/astrasurge/guess-calling-code/issues
- npm.io page: https://npm.io/package/guess-calling-code

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 1.1.8 (latest) — 2023-06-26
- 1.1.7 — 2023-03-26
- 1.1.6 — 2023-03-22
- 1.1.5 — 2023-03-20
- 1.1.4 — 2023-03-19
- 1.1.2 — 2023-03-19
- 1.1.1 — 2023-03-19
- 1.1.0 — 2023-03-19
- 1.0.0 — 2023-03-19

## README

# guess-calling-code

[![npm](https://img.shields.io/npm/v/guess-calling-code)](https://www.npmjs.com/package/guess-calling-code)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FAnarchStudio%2Fguess-calling-code.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FAnarchStudio%2Fguess-calling-code?ref=badge_shield)
[![Codecov](https://img.shields.io/codecov/c/github/anarchStudio/guess-calling-code?token=N4MIOTA82O)](https://codecov.io/gh/AnarchStudio/guess-calling-code)

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:

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

Then, in your JavaScript code:

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

### Node.js Usage

```sh
npm install guess-calling-code
```

or

```sh
yarn add guess-calling-code
```

Then, in your JavaScript code:

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

### TypeScript Usage

```typescript
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](https://dev.to/suikodev/javascript-trick-guessing-users-country-calling-codes-by-time-zone-2p9a).

## License

[LICENSE (MIT)](/LICENSE)

---
_Source: https://npm.io/package/guess-calling-code · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
