1.0.9 • Published 5 years ago

phoneformat.js v1.0.9

Weekly downloads
2,158
License
-
Repository
-
Last release
5 years ago

PhoneFormat.js

A javascript phone formatter

Install

via Bower

bower install phoneformat.js

via NPM

npm install phoneformat.js

All files for usage are in the /dist directory.

  • Amd:
    • phone-format-amd.js or phone-format-amd.min.js
  • Exports:
    • phone-format-exports.js or phone-format-amd.min.js
  • Global:
    • phone-format-global.js or phone-format-global.min.js
  • Original Blend:
    • phone-format.js or phone-format.min.js

API

FunctionParametersExample
countryForE164NumberphoneNumber : stringphoneFormat.countryForE164Number(validInternationalPhoneNumber);
formatNumberForMobileDialingcountryCode : string, phoneNumber : stringphoneFormat.formatNumberForMobileDialing(countryCode, validPhoneNumber);
isValidNumberphoneNumber : string, countryCode : stringphoneFormat.isValidNumber(validPhoneNumber, countryCode);
formatE164countryCode: string, phoneNumber : stringphoneFormat.formatE164(countryCode, validPhoneNumber);
formatInternationalcountryCode : string, phoneNumber : stringphoneFormat.formatInternational(countryCode, validPhoneNumber);
formatLocalcountryCode : string, phoneNumber : stringphoneFormat.formatLocal(countryCode, validPhoneNumber);
exampleLandlineNumbercountryCode : stringphoneFormat.exampleLandlineNumber(countryCode);
exampleMobileNumbercountryCode : stringphoneFormat.exampleMobileNumber(countryCode);
cleanPhonephoneNumber : stringphoneFormat.cleanPhone(validPhoneNumber);
countryCodeToNamecountryCode : stringphoneFormat.countryCodeToName(countryCode);

FAQ

Is PhoneFormat.js in sync with the latest libphonenumber?

More often then not PhoneFormat.js will NOT be using the latest version of libphonenumber.

It was last synced v8.10.6

If this is causing you any headaches, please follow the instructions below to update the source files in /lib.

  • Step 1

    • Copy to your clipboard, the contents of closure.txt at the top of this page
  • Step 2

  • Step 3

    • Paste the contents of closure.txt into the big textarea on the left side of the screen under the Compile button.
    • Make sure you delete whatever text is already the textarea!
    • After you've pasted it press the Compile button
    • If everything works correctly, on the right side of the screen will be a freshly compiled google-libraries.js
  • Step 4

    • Update lib/google-libraries.js with the compiled libraries from the compiler service.
    • Run npm run build
    • Commit your change, push it up and submit a pull request.
    • Thank you!

Questions?

This project was created by @albeebe.