phonelookup

2019-11-10 admin

phonelookup是什么

什么是phonelookup,Phone lookup

phonelookup使用教程帮助文档

phone-lookup

Phone validation and number formatting library based on google libphonenumber

Install

# npm install phonelookup

Usage examples

Validate phone and get info

var Phone = require('phonelookup');

// valid phone types by default:  ['generalDesc', 'fixedLine', 'mobile', 'personalNumber', 'tollFree', 'premiumRate'];;

// you can test only mobiles and home numbers for example:
// var phone = new Phone(['fixedLine', 'mobile']);

var phone = new Phone();
var testPhone = '+1 212 CALL NOW';

// remove all non digit chars from phone and replace alphas by digits
var normalizedPhone = phone.normalize(testPhone);
console.log(normalizedPhone); // 12122255669

// generate random phone for specified country code
var randomPhone = phone.random('US');
console.log(randomPhone); // 15809280360

// get phone info (or 'undefined' for invalid phone)
var info = phone.info(testPhone);
console.log(info);
/*
{ id: 'US',
  phone: '12122255669',
  code: '1',
  line: '2122255669',
  type: 'fixedLine',
  format: '+1 (212) 225-5669' }
*/

//

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-78911.html

文章标题:phonelookup

回到顶部