google-libphonenumber
Advanced tools
Comparing version 0.2.2 to 1.0.0
@@ -1,17 +0,55 @@ | ||
## Changelog | ||
# Change Log | ||
### 0.2.2 / 2015-04-30 | ||
- [#11](https://github.com/seegno/google-libphonenumber/pull/11) Add basic update script (@ruimarinho) | ||
- [#10](https://github.com/seegno/google-libphonenumber/pull/10) Update libphonenumber@7.0.5 (@ruimarinho) | ||
## [1.0.0](https://github.com/seegno/google-libphonenumber/tree/1.0.0) (2015-07-13) | ||
### 0.2.1 / 2015-03-25 | ||
- [#7](https://github.com/seegno/google-libphonenumber/pull/7) Update libphonenumber@7.0.4 (@ruimarinho) | ||
[Full Changelog](https://github.com/seegno/google-libphonenumber/compare/0.2.2...1.0.0) | ||
### 0.2.0 / 2015-03-06 | ||
- [#5](https://github.com/seegno/google-libphonenumber/pull/5) Update libphonenumber@7.0.3 (@ruimarinho) | ||
**Merged pull requests:** | ||
### 0.1.2 / 2015-01-31 | ||
- [#3](https://github.com/seegno/google-libphonenumber/pull/3) Update libphonenumber@7.0.2 (@ruimarinho) | ||
- Rewrite with support for browserify [\#14](https://github.com/seegno/google-libphonenumber/pull/14) ([ruimarinho](https://github.com/ruimarinho)) | ||
### 0.1.1 / 2014-12-19 | ||
- [#1](https://github.com/seegno/google-libphonenumber/pull/1) Update libphonenumber@7.0.1 (@ruimarinho) | ||
- Add support for the as you type formatter [\#12](https://github.com/seegno/google-libphonenumber/pull/12) ([ruimarinho](https://github.com/ruimarinho)) | ||
## [0.2.2](https://github.com/seegno/google-libphonenumber/tree/0.2.2) (2015-04-30) | ||
[Full Changelog](https://github.com/seegno/google-libphonenumber/compare/0.2.1...0.2.2) | ||
**Merged pull requests:** | ||
- Add basic update script [\#11](https://github.com/seegno/google-libphonenumber/pull/11) ([ruimarinho](https://github.com/ruimarinho)) | ||
- Update libphonenumber@7.0.5 [\#10](https://github.com/seegno/google-libphonenumber/pull/10) ([ruimarinho](https://github.com/ruimarinho)) | ||
## [0.2.1](https://github.com/seegno/google-libphonenumber/tree/0.2.1) (2015-03-25) | ||
[Full Changelog](https://github.com/seegno/google-libphonenumber/compare/0.2.0...0.2.1) | ||
**Merged pull requests:** | ||
- Update libphonenumber@7.0.4 [\#7](https://github.com/seegno/google-libphonenumber/pull/7) ([ruimarinho](https://github.com/ruimarinho)) | ||
## [0.2.0](https://github.com/seegno/google-libphonenumber/tree/0.2.0) (2015-03-06) | ||
[Full Changelog](https://github.com/seegno/google-libphonenumber/compare/0.1.2...0.2.0) | ||
**Merged pull requests:** | ||
- Update libphonenumber@7.0.3 [\#5](https://github.com/seegno/google-libphonenumber/pull/5) ([ruimarinho](https://github.com/ruimarinho)) | ||
## [0.1.2](https://github.com/seegno/google-libphonenumber/tree/0.1.2) (2015-01-31) | ||
[Full Changelog](https://github.com/seegno/google-libphonenumber/compare/0.1.1...0.1.2) | ||
**Merged pull requests:** | ||
- Update libphonenumber@7.0.2 [\#3](https://github.com/seegno/google-libphonenumber/pull/3) ([ruimarinho](https://github.com/ruimarinho)) | ||
## [0.1.1](https://github.com/seegno/google-libphonenumber/tree/0.1.1) (2014-12-19) | ||
[Full Changelog](https://github.com/seegno/google-libphonenumber/compare/0.1.0...0.1.1) | ||
**Merged pull requests:** | ||
- Update libphonenumber@7.0.1 [\#1](https://github.com/seegno/google-libphonenumber/pull/1) ([ruimarinho](https://github.com/ruimarinho)) | ||
## [0.1.0](https://github.com/seegno/google-libphonenumber/tree/0.1.0) (2014-11-12) |
{ | ||
"name": "google-libphonenumber", | ||
"version": "0.2.2", | ||
"description": "A lightweight wrapper for Google's libphonenumber.", | ||
"version": "1.0.0", | ||
"description": "A browserify-compatible wrapper for Google's libphonenumber.", | ||
"author": { | ||
"name": "Rui Marinho", | ||
"email": "rui.marinho@seegno.com", | ||
"url": "http://seegno.com" | ||
}, | ||
"license": "MIT", | ||
"homepage": "http://seegno.github.io/google-libphonenumber/", | ||
"bugs": "https://github.com/seegno/google-libphonenumber/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/seegno/google-libphonenumber.git" | ||
}, | ||
"main": "./dist/libphonenumber.js", | ||
"browser": "./dist/browser/libphonenumber.js", | ||
"keywords": [ | ||
"browserify", | ||
"e164", | ||
@@ -18,34 +33,24 @@ "format", | ||
], | ||
"author": { | ||
"name": "Rui Marinho", | ||
"email": "rui.marinho@seegno.com", | ||
"url": "http://seegno.com" | ||
"options": { | ||
"mocha": "--compilers js:babel/register --require should test" | ||
}, | ||
"homepage": "http://seegno.github.io/google-libphonenumber/", | ||
"bugs": "https://github.com/seegno/google-libphonenumber/issues", | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/seegno/google-libphonenumber/raw/master/LICENSE" | ||
}, | ||
{ | ||
"type": "Apache 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/seegno/google-libphonenumber.git" | ||
}, | ||
"scripts": { | ||
"changelog": "./node_modules/.bin/github-changes --owner seegno --repository google-libphonenumber --auth --only-pulls --use-commit-body --title 'Changelog' --date-format '/ YYYY-MM-DD'", | ||
"test": "NODE_ENV=test ./node_modules/.bin/mocha test/*_test.js" | ||
"update": "./bin/update.sh", | ||
"build": "./bin/build.sh", | ||
"changelog": "github_changelog_generator --no-issues", | ||
"lint": "eslint src/index.js test", | ||
"prepublish": "npm run lint && npm test && npm run build", | ||
"testonly": "./node_modules/.bin/mocha $npm_package_options_mocha", | ||
"test": "npm run build && npm run testonly" | ||
}, | ||
"dependencies": { | ||
"seegno-closure-library": "20150306.0.1" | ||
}, | ||
"devDependencies": { | ||
"github-changes": "0.0.16", | ||
"mocha": "^2.0.1", | ||
"should": "^4.0.4" | ||
"babel": "^5.6.14", | ||
"babel-eslint": "^3.1.23", | ||
"browserify": "^10.2.0", | ||
"eslint": "^0.24.1", | ||
"eslint-plugin-babel": "^1.1.0", | ||
"minifyify": "^7.0.0", | ||
"mocha": "^2.2.5", | ||
"seegno-closure-library": "^20150306.0.1", | ||
"should": "^7.0.1" | ||
}, | ||
@@ -52,0 +57,0 @@ "engines": { |
# google-libphonenumber | ||
A lightweight wrapper for Google's [libphonenumber](https://code.google.com/p/libphonenumber/) - a library to parse, format, store and validate international phone numbers. | ||
A browserify-compatible wrapper for Google's [libphonenumber](https://code.google.com/p/libphonenumber/), a library to parse, format, store and validate international phone numbers. | ||
Zero dependencies, always up-to-date. | ||
@@ -15,3 +16,3 @@ ## Status | ||
```sh | ||
npm install --save google-libphonenumber | ||
npm install google-libphonenumber --save | ||
``` | ||
@@ -24,34 +25,48 @@ | ||
```js | ||
// Require `PhoneNumberFormat`. | ||
var PNF = require('google-libphonenumber').PhoneNumberFormat; | ||
// Grab the `phoneUtil` instance. | ||
var phoneUtil = require('google-libphonenumber').phoneUtil; | ||
// Get an instance of `PhoneNumberUtil`. | ||
var phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance(); | ||
// Or call it yourself, just like in the original examples. | ||
// var phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance(); | ||
// Parse number with country code. | ||
var phoneNumber = phoneUtil.parse('202-456-1414', 'US'); | ||
phoneUtil.format(phoneNumber, PNF.INTERNATIONAL); | ||
// Print number in the international format. | ||
console.log(phoneUtil.format(phoneNumber, PNF.INTERNATIONAL)); | ||
// => +1 202-456-1414 | ||
``` | ||
## Notes | ||
#### Using the "As You Type" Formatter | ||
### Differencies from other forks | ||
```js | ||
// Require `AsYouTypeFormatter`. | ||
var AsYouTypeFormatter = require('google-libphonenumber').AsYouTypeFormatter; | ||
var formatter = new AsYouTypeFormatter('US'); | ||
* Uses a super modern version of `google-closure` repackaged for npm which does not pollute the global namespace (it runs in a sandbox instead). | ||
* Relies on a simplified update process to keep the underlying `libphonenumber` library always up-to-date. | ||
* All classes available from `libphonenumber` are exported (and that's it). | ||
* Leverages own Google's Closure Library dependency management system to load dependencies. | ||
* Dependencies are generated automatically through Google's Closure Library binary tools (no guessing!). | ||
console.log(formatter.inputDigit('6')); // => 6 | ||
console.log(formatter.inputDigit('5')); // => 65 | ||
console.log(formatter.inputDigit('0')); // => 650 | ||
console.log(formatter.inputDigit('2')); // => 650-2 | ||
console.log(formatter.inputDigit('5')); // => 650-25 | ||
console.log(formatter.inputDigit('3')); // => 650-253 | ||
console.log(formatter.inputDigit('2')); // => 650-2532 | ||
console.log(formatter.inputDigit('2')); // => (650) 253-22 | ||
### Updating package dependencies | ||
formatter.clear(); | ||
``` | ||
Learn more about [updating package dependencies](https://github.com/seegno/google-libphonenumber/wiki/Updating-Package-Dependencies). | ||
## Notes | ||
### Errors | ||
### Differences from other forks | ||
The javascript port of `libphonenumber` throws errors as string, e.g. `throw "Invalid country code"`. As Guillermo Rauch puts it, [a string is not an error](http://www.devthought.com/2011/12/22/a-string-is-not-an-error/) so, in an attempt to avoid future issues when developing an application, this module converts all string-based errors that occur on the `PhoneNumberUtil` class to instances of `Error`. | ||
* All classes available from `libphonenumber` are exported as-is. No magic methods. | ||
* Always based on the latest `google-closure` library version available from Google with performance and bug fixes. | ||
* Relies on a simplified and [well documented update process](https://github.com/seegno/google-libphonenumber/blob/master/bin/update) to keep the underlying `libphonenumber` library always up-to-date. | ||
* Throws errors instead of strings. | ||
#### Errors | ||
The javascript port of the original `libphonenumber` library throws errors as string, e.g. `throw "Invalid country code"` and, as Guillermo Rauch puts it, [a string is not an error](http://www.devthought.com/2011/12/22/a-string-is-not-an-error/). However, the `libphonenumber` team has refused change this behaviour due to breaking changes, so a patch is applied on top of the source files to make sure that stacktraces are available and useful. | ||
## Tests | ||
@@ -65,6 +80,4 @@ | ||
## Acknowledgements | ||
## Acknowledgments | ||
The original library wrapper was created by [Socialcam](https://github.com/Socialcam/node-libphonenumber) who first got it working on node.js and then improved by [mattbornski](https://github.com/mattbornski/libphonenumber). This package would not exist without the work of these previous contributions. | ||
The exceptional work on `libphonenumber` was made possible by these [committers and contributors](https://github.com/googlei18n/libphonenumber/graphs/contributors). | ||
@@ -71,0 +84,0 @@ |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
@@ -6,3 +7,3 @@ /** | ||
var libphonenumber = require('..'); | ||
const libphonenumber = require('..'); | ||
@@ -13,22 +14,22 @@ /** | ||
describe('Exports', function () { | ||
it('should export all provided classes', function() { | ||
Object.keys(libphonenumber).should.eql([ | ||
describe('Exports', () => { | ||
it('should export all known objects', () => { | ||
Object.keys(libphonenumber).sort().should.eql([ | ||
'AsYouTypeFormatter', | ||
'Error', | ||
'NumberFormat', | ||
'PhoneMetadata', | ||
'PhoneMetadataCollection', | ||
'PhoneNumber', | ||
'PhoneNumberDesc', | ||
'PhoneNumber', | ||
'metadata', | ||
'Error', | ||
'PhoneNumberFormat', | ||
'PhoneNumberType', | ||
'PhoneNumberUtil', | ||
'phoneUtil' | ||
'metadata' | ||
]); | ||
}); | ||
it('should export an instance of `PhoneNumberUtil`', function() { | ||
(libphonenumber.phoneUtil instanceof libphonenumber.PhoneNumberUtil).should.be.true; | ||
it('should export an instance of `PhoneNumberUtil`', () => { | ||
(libphonenumber.PhoneNumberUtil.getInstance() instanceof libphonenumber.PhoneNumberUtil).should.be.true(); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1541010
0
31
29101
90
9
3
6
1
- Removedseegno-closure-library@20150306.0.1
- Removedseegno-closure-library@20150306.0.1(transitive)