Phone Parser
Parse the phone input into an output format of your choice. Good for formatting a user input.
Installation
Through component:
$ component install chenglou/phone-parser
Through npm:
$ npm install phone-parser
Or directly download the script for browsers. Rename it however you want.
API
'x'
represents a digit placeholder.
// This is the component/npm format. Browser format below.var phoneParser = ; ; // Returns '(234) 123-4447'.; // Returns '864556988'.; // Returns '+1 123 4567'.; // Error: phone format cannot be parsed.
Remember, only 'x'
is a placeholder. The rest is treated as part of the formatting.
For browsers (real-life example of formatting an input field):
Testing
Using npm:
If you haven't installed jasmine-node and CoffeeScript:
$ npm install
Then:
$ npm test
License
MIT.