number_info
v0.0.1
Published
Useful tools to translate telephone numbers to and from E164
Downloads
66
Maintainers
Readme
number_info
This library is used to resolve a dialed phone number, returning country information along with area codes, phone type, etc. It uses the NodeJS port of the Google's libphonenumber.
Installing
Add this library to your package.json configuration:
"dependencies": {
"number_info": "latest"
}
Using it
var number_info = require('number_info');
var result = number_info.resolve(dialedString, numberingPlan);
numberingPlan
is optional. When not supplied, it will be assumed that
dialedString
is an E164 number without the leading +
.
If supplied, it must be a 2-letter ISO country code that will be used to translate this number from a local dialed number into an E164 number. In essence, the country specifices the numbering plan used to interpret the dialed number.
For example, from the US you will dial 011+number to reach an international destination, while other countries will have different ways for dialing local, long distance, and international destinations (e.g: 00+number).
Examples
Below you will find a few examples for the most common usage. More examples can be found in the tests.
Resolving an E164 number
var result = number_info.resolve('18009997777');
Resolving a number using the US numbering plan
var result = number_info.resolve('005491145556666');
Developers
This project uses standard npm scripts. Current tasks include:
- test: Runs Mocha tests.
- jsdoc: Runs JSDoc3.
- eslint: Runs ESLint.
- coverage: Runs the tests and then Instanbul to get a coverage report.
- build: This is the default task, and will run all the other tasks.
Running an npm task
To run a task, just do:
npm run build
Contributing
To contribute:
- Make sure you open a concise and short pull request.
- Throw in any needed unit tests to accomodate the new code or the changes involved.
- Run
npm run build
and make sure everything is ok before submitting the pull request (make eslint happy). - Your code must comply with the Javascript Standard Style, ESLint should take care of that.
License
The source code is released under Apache 2 License.
Check LICENSE file for more information.