Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 59dfa92
Showing
201 changed files
with
41,607 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
Copyright (c) 2013 Steve Kinney | |||
|
|||
Permission is hereby granted, free of charge, to any person | |||
obtaining a copy of this software and associated documentation | |||
files (the "Software"), to deal in the Software without | |||
restriction, including without limitation the rights to use, | |||
copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
copies of the Software, and to permit persons to whom the | |||
Software is furnished to do so, subject to the following | |||
conditions: | |||
|
|||
The above copyright notice and this permission notice shall be | |||
included in all copies or substantial portions of the Software. | |||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,63 @@ | |||
# Phone Number Formatter | |||
|
|||
Parsing and formatting phone numbers so you don't have to. | |||
|
|||
## Getting Started | |||
Install the module with: `npm install phone-formatter` | |||
|
|||
Phone-formatter is pretty straight-forward. First, it can normalize pretty much any format you can throw at it. If it can't, then send a pull request with a failing test and it will (shortly thereafter). | |||
|
|||
```javascript | |||
var phoneFormatter = require('phone-formatter'); | |||
|
|||
phoneFormatter.normalize('212.555.1212'); | |||
// returns "2125551212" | |||
|
|||
phoneFormatter.normalize('+1 (212) 555-1212'); | |||
// returns "2125551212" | |||
``` | |||
|
|||
You get the idea. It can also format a series of ten digits into almost any format your heart desires. Use the letter "N" as a place holder. | |||
|
|||
```javascript | |||
phoneFormatter.format("2125551212", "(NNN) NNN-NNNN"); | |||
// returns "(212) 555-1212" | |||
``` | |||
|
|||
## Documentation | |||
|
|||
As it stands, there are only two methods, `normalize` and `format`. They are pretty much fleshed out above. That said, I'm reserving this second for future greatness. | |||
|
|||
I can confirm that Phone Formatter can normalize the following formats. | |||
|
|||
* (212) 555 1212 | |||
* (212) 555.1212 | |||
* (212) 555-1212 | |||
* (212) 5551212 | |||
* (212)5551212 | |||
* 212 555 1212 | |||
* 212.555.1212 | |||
* 212-555-1212 | |||
* 1-212-555-1212 | |||
* +1 (212) 555-1212 | |||
* 12125551212 | |||
* +45 (212) 555-1212 | |||
* 212555121 | |||
|
|||
It may handle ever more, but I haven't tested it. | |||
|
|||
## Contributing | |||
|
|||
Pull requests are welcome as long as they are accompanied by tests. | |||
|
|||
Right now, this library is incredibly American-centric and that kind of stinks, but my use case consisted exclusively of American phone numbers. If you'd like to tweak Phone Formatter to better suit your situation, please do! | |||
|
|||
**Brief Style Guide**: Two spaces, no space before function parentheses, semi-colons everywhere. | |||
|
|||
## Release History | |||
|
|||
* 0.0.1: Just two methods and some tests. | |||
|
|||
## License | |||
Copyright (c) 2013 Steve Kinney | |||
Licensed under the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,26 @@ | |||
module.exports = { | |||
|
|||
normalize: function extract(phoneNumber) { | |||
|
|||
return phoneNumber.replace( | |||
/^[\+\d{1,3}\-\s]*\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/, | |||
"$1$2$3" | |||
); | |||
|
|||
}, | |||
|
|||
format: function format(phoneNumber, formatString, options) { | |||
|
|||
if (options && options.normalize === true) { | |||
phoneNumber = this.normalize(phoneNumber) | |||
}; | |||
|
|||
for ( var i = 0, l = phoneNumber.length; i < l; i++ ) { | |||
formatString = formatString.replace("N", phoneNumber[i]); | |||
} | |||
|
|||
return formatString; | |||
|
|||
}, | |||
|
|||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.