phones

2.0.1 • Public • Published

phones Build Status

Parse, format, and validate US phone numbers

Install

$ npm install --save phones

Usage

var phones = require('phones')
 
phones.parse('415-555-1234')
//=> 4155551234
 
phones.format('4155551234')
//=> 415 555 1234
 
phones.validate('4155551234')
//=> true

API

phones.parse(phone) -> string

phone

Required
Type: string

A phone number to parse. A leading 1 country code will be stripped.

phones.format(phone, [separator]) -> string

Format a 10 digit phone string by adding separators and truncating extra digits.

phone

Required
Type: string

A phone number to format. Digits only.

separator

Type: string
Default: '-'

phones.validate(phone) -> boolean

phone

Required
Type: string

A phone number to validate as a 10 digit string.

License

MIT © Ben Drucker

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.1
    80
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.1
    80
  • 2.0.0
    0
  • 1.0.1
    1
  • 1.0.0
    0
  • 0.1.0
    1

Package Sidebar

Install

npm i phones

Weekly Downloads

82

Version

2.0.1

License

MIT

Last publish

Collaborators

  • bendrucker