npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

format-phone

v0.0.5

Published

Convert text to international friendly phone number format

Downloads

44

Readme

format-phone NPM version Build Status Dependency Status Coverage percentage

Convert text to international friendly phone number format

A library that attempts to simplify and assist in dealing with phone number formats including international numbers. Piggybacks off the google libphonenumber library for the heavy lifting and adds some syntactical sugar.

Installation

$ npm install --save format-phone

Usage

var phoneFormat = require('format-phone');
var parsednumber = phoneFormat.parsePhoneNumber('212-555-1234', 'US');
console.log(parsednumber);

{ e164: '+12125551234',
  rfc3966: 'tel:+1-212-555-1234',
  intl: '+1 212-555-1234',
  national: '(212) 555-1234',
  countryCode: 'US',
  countryName: 'United States',
  phoneType: 'FIXED_LINE_OR_MOBILE',
  region: 'US',
  validNumberForRegion: true,
  hasExtension: false }
  

Development

source location: ./src

language: CoffeeScript

build system: gulp (browserify, coffeelint)

`gulp` - compiles for npm (default)
`gulp bower` - compiles for bower 

Directory structure

alt text

Testing

CI provided by TravisCI

npm test

Example test results
FormatPhone number parser
  Valid number tests
    CHINA TEST NUMBERS
      ✓ mobile China (CN) number - +86 189 6902 0603
      ✓ mobile China (CN) number - +8618918682107
      ✓ mobile China (CN) number - +8615229253024
      ✓ Beijing landline - +861057684020
      ✓ shanghai landline - 862154170345
      ✓ mobile hong kong - +85260700179
    INTERNATIONAL TEST NUMBERS
      ✓ landline New Zealand (NZ) number /no countryCode w/ plus sign - +64 6 833 6001
      ✓ landline Argentina (AR) number /no country code - +011 54 11 4727 1158
      ✓ landline Denmark (DK) number /no country code - +0045 30822784
      ✓ landline Denmark (DK) number - +00 (45) 3268-8422
      ✓ Singapore (SG) number - +6568764880
    INTERNATIONAL TEST UK NUMBERS
      ✓ mobile GB number w/spaces and plus sign - +44(0)777 55 55 613
      ✓ mobile GB number - no spaces - w/ country code - +44(0)7775555613
      ✓ London number - +44 20 7529 4600
      ✓ London number - +44 (0) 20 7529 4600
      ✓ Cardiff number - +44 29 1234 5678
      ✓ Leeds number - +44 113 123 4567
      ✓ Leicester number - +44 116 123 4567
      ✓ Edinburgh number - +44 131 123 4567
      ✓ Liverpool number - +44 151 123 4567
      ✓ Evesham number - +44 1386 234567
      ✓ Oxford number - +44 1865 123456
      ✓ Swansea number - +44 1792 123456
      ✓ Bolton number - +44 1204 123456
      ✓ Sedbergh number - +44 15396 12345
      ✓ Brampton number - +44 16977 12345
    LOCAL UK TEST NUMBERS
      ✓ landline London number - (020) 1234 5678,GB
      ✓ landline Cardiff number - (029) 1234 5678,GB
      ✓ landline Leeds number - (0113) 123 4567,GB
      ✓ landline Leicester number - (0116) 123 4567,GB
      ✓ landline Edinburgh number - (0131) 123 4567,GB
      ✓ landline Liverpool number - (0151) 123 4567,GB
      ✓ landline Dundee number - (01382) 123456,GB
      ✓ landline Evesham number - (01386) 123456,GB
      ✓ landline Oxford number - (01865) 123456,GB
      ✓ landline Swansea number - (01792) 123456,GB
      ✓ landline Bolton number - (01204) 123456,GB
      ✓ landline Brampton number - (016977) 12345,GB
    US TEST NUMBERS
      ✓ US number /no countryCode /no plus sign - 9179951689
      ✓ Number with forward and back slashes - parses to a valid number - 0212\345/6789
      ✓ US number /with countryCode - dots - 917.291.5910,US
      ✓ US number /with leading 011 /no spaces - 0113106999684,US
      ✓ US number - 8886563726
      ✓ US number /with extension /no plus sign - 203.866.8886 x111
      ✓ US number alpha-numeric - 1800-ALPHNUM
      ✓ Number with dash and comma - parses to a valid number - 1212-364,4321
      ✓ Number with forward and back slashes - parses to a valid number - 0212\345/6789
  Invalid number tests
    FAKE TEST NUMBERS
      ✓ All zero's with plus sign- invalid phone number - +00000000000
      ✓ Super fake - (555)-555-5555
      ✓ All leading zero's - invalid phone number - 00000000001
      ✓ Number with plus sign in middle - 123+1234567890
      ✓ Number that's too long - +12345678909999999999
      ✓ Invalid Alpha-numeric number - +1234567890AAAAAAAAAA
      ✓ Looks like a number but has a foward slash - (012) 123/1234
      ✓ Starts like a phone number but too long - (212) 123 12345234234234234234234
      ✓ Looks like a valid number but in reverse format - (123)-1234-123
      ✓ Invalid number with leading zero and dash - 0-212364345
      ✓ Invalid number-kinda not real - but sort of real - 123-1234
      ✓ Invalid number - incomplete - +1 (617) 603-23xx

License

MIT © Fritz G. Batroni