codes-postaux
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "codes-postaux", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "French postal codes API for Node.js", | ||
@@ -12,3 +12,5 @@ "repository": { | ||
"codes postaux", | ||
"open data" | ||
"open data", | ||
"postal code", | ||
"French" | ||
], | ||
@@ -23,11 +25,12 @@ "author": "Jérôme Desboeufs <jerome.desboeufs@gmail.com>", | ||
"prepublish": "node prepublish.js", | ||
"test": "node test.js", | ||
"postinstall": "node postinstall.js" | ||
}, | ||
"dependencies": { | ||
"lodash": ">= 2.0 <4.0" | ||
"lodash": "^4.13.1" | ||
}, | ||
"devDependencies": { | ||
"JSONStream": "^0.9.0", | ||
"csv-parse": "0.0.6" | ||
"JSONStream": "^1.1.2", | ||
"csv-parse": "^1.1.1" | ||
} | ||
} |
@@ -9,8 +9,17 @@ var fs = require('fs'); | ||
// Just inflate json file | ||
fs.createReadStream(sourceFile) | ||
.pipe(gzip) | ||
.pipe(fs.createWriteStream(destFile)) | ||
.on('finish', function () { | ||
console.log('Dataset has been successfully inflated'); | ||
}); | ||
if (fs.existsSync(sourceFile)) { | ||
inflateDataset(); | ||
} else { // we're added as a dependency | ||
require('./prepublish.js').on('finish', inflateDataset); | ||
} | ||
function inflateDataset() { | ||
fs.createReadStream(sourceFile) | ||
.pipe(gzip) | ||
.pipe(fs.createWriteStream(destFile)) | ||
.on('finish', function () { | ||
console.log('Dataset has been successfully inflated'); | ||
}); | ||
} |
French postal codes API for Node.js | ||
------ | ||
> Recherche de nom de commune et code INSEE à partir d'un code postal. | ||
Based on the [official postal codes database](https://www.data.gouv.fr/fr/datasets/base-officielle-des-codes-postaux/) from [La Poste](http://www.laposte.fr/) and fixed by [Christian Quest](https://github.com/cquest). | ||
@@ -20,2 +22,15 @@ | ||
libelleAcheminement: 'PARIS' } ] | ||
``` | ||
``` | ||
## Architecture | ||
A source CSV file is converted to JSON and compressed on `prepublish` for faster distribution. | ||
On `postinstall`, it is unzipped. | ||
On `require`, it is indexed and loaded into memory. Finding postal codes is just an object lookup. | ||
## Alternatives in other languages | ||
These community-maintained libraries are based on the same dataset and offer equivalent features in other languages: | ||
- [Dart](https://pub.dartlang.org/packages/code_postaux) |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance 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
529003
24
36
2
+ Addedlodash@4.17.21(transitive)
- Removedlodash@3.10.1(transitive)
Updatedlodash@^4.13.1