npm

Need private packages and team management tools?Check out npm Orgs. »

phoneify

1.1.3 • Public • Published

Phoneify

A very simple module that can parse an input to a readble, clean format for phone numbers.

Installation

Through npm:

$ npm install phoneify

API Documentation:

There's only one function implemented:

var phoneify = require('phoneify'); // phoneify is a function that takes one parameter
var input = 12345678901;
console.log(phoneify(input)); // parameter will be the number

You can choose to either include the leading "1" at the beginning of the phone number or leave it. But the length, initially, should be either 10 or 11 characters long.

Example output (will always return an object):

{
    "original": "12345678901",
    "removeInitialNumber": "2345678901",
    "withPlus": "+12345678901",
    "countryCodeIntact": {
        "addParentheses": "1 (234) 567 8901",
        "addDashes": "1-234-567-8901",
        "addParenthesesWithDashes": "1-(234)-567-8901",
        "addDots": "1.234.567.8901",
        "addSlashes": "1/234/567/8901",
        "addTrailingSlashes": "1 (234) 567-8901"
        },
    "countryCodeRemoved": {
        "addParentheses": "(234) 567 8901",
        "addDashes": "234-567-8901",
        "addParenthesesWithDashes": "(234)-567-8901",
        "addDots": "234.567.8901",
        "addSlashes": "234/567/8901",
        "addTrailingSlashes": "(234) 567-8901"
        }
}

To access a specific format:

var phoneify = require('phoneify');
var input = 12345678901;
format = phoneify(input);
console.log(format.withPlus);
console.log(format.countryCodeRemoved.addParenthesesWithDashes);

Output:

+12345678901
(234)-567-8901

License

MIT.

install

npm i phoneify

Downloadsweekly downloads

0

version

1.1.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability