Socket
Socket
Sign inDemoInstall

phones

Package Overview
Dependencies
3
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    phones

Parse, format, and validate US phone numbers


Version published
Weekly downloads
91
increased by10.98%
Maintainers
1
Install size
18.6 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 24 Sep 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc