https://github.com/juliandavidmr/prefix-number
Obtains the code, name and prefix of a telephone number
https://github.com/juliandavidmr/prefix-number
country-codes iso nodejs npm-package phone-number prefix
Last synced: 3 months ago
JSON representation
Obtains the code, name and prefix of a telephone number
- Host: GitHub
- URL: https://github.com/juliandavidmr/prefix-number
- Owner: juliandavidmr
- License: mit
- Created: 2017-03-19T05:06:31.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-02T09:54:30.000Z (about 9 years ago)
- Last Synced: 2025-10-27T06:59:07.668Z (8 months ago)
- Topics: country-codes, iso, nodejs, npm-package, phone-number, prefix
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/prefix-number
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prefix-number
Get the name of the country in three different languages, the prefix and the ISO.
```sh
$ npm install --save prefix-number
```
## Usage
### By prefix
Import
```js
var Prefixnum = require('prefix-number');
```
```js
var prefix = new Prefixnum("+57");
console.log(prefix.toISO()); //=> CO
console.log(prefix.toISO3()); //=> COL
console.log(prefix.toCountry()); //=> Colombia
console.log(prefix.toPrefix()); //=> 57
```
### By name
```js
var prefix = new Prefixnum("Australia");
console.log(prefix.toISO()); //=> AU
console.log(prefix.toISO3()); //=> AUS
console.log(prefix.toPrefix()); //=> 61
```
### By ISO
```js
var prefix = new Prefixnum("BG");
console.log(prefix.toISO()); //=> BG
console.log(prefix.toISO3()); //=> BGR
console.log(prefix.toCountry()); //=> Bulgaria
console.log(prefix.toPrefix()); //=> 359
```
### Change language
Available in Spanish, English and French. Default `en`.
```js
var prefix = new Prefixnum("United States of America");
prefix.language('es'); // es|en|fr
console.log(prefix.toCountry()); //=> Estados Unidos de América
prefix.language('fr'); // es|en|fr
console.log(prefix.toCountry()); //=> États-Unis d'Amérique
```
### LICENSE
MIT