Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-libphonenumber

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-libphonenumber

The up-to-date and reliable Google's libphonenumber package for node.js.

  • 3.2.39
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
increased by6.76%
Maintainers
1
Weekly downloads
 
Created

What is google-libphonenumber?

The google-libphonenumber npm package is a JavaScript port of Google's libphonenumber library, which provides robust tools for parsing, formatting, and validating international phone numbers. It is designed to help developers work with phone numbers in various formats and provides functionalities such as number validation, formatting numbers for display, and extracting possible number types.

What are google-libphonenumber's main functionalities?

Parsing and validating phone numbers

This feature allows you to parse a phone number from a string and validate whether it is a possible number. The example demonstrates parsing and validating a US phone number.

const { PhoneNumberUtil } = require('google-libphonenumber');
const phoneUtil = PhoneNumberUtil.getInstance();
const number = phoneUtil.parseAndKeepRawInput('202-456-1111', 'US');
const isValid = phoneUtil.isValidNumber(number);

Formatting phone numbers

This feature enables the formatting of parsed phone numbers into various formats, such as international and national formats. The code sample shows how to format a US phone number into an international format.

const { PhoneNumberFormat, PhoneNumberUtil } = require('google-libphonenumber');
const phoneUtil = PhoneNumberUtil.getInstance();
const number = phoneUtil.parse('2024561111', 'US');
const formattedNumber = phoneUtil.format(number, PhoneNumberFormat.INTERNATIONAL);

Getting the type of a number

This functionality allows you to determine the type of a phone number (e.g., mobile, fixed-line). The example demonstrates how to parse a US phone number and get its type.

const { PhoneNumberType, PhoneNumberUtil } = require('google-libphonenumber');
const phoneUtil = PhoneNumberUtil.getInstance();
const number = phoneUtil.parse('202-456-1111', 'US');
const numberType = phoneUtil.getNumberType(number);

Other packages similar to google-libphonenumber

Keywords

FAQs

Package last updated on 24 Nov 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc