Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

codes-postaux

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codes-postaux - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

LICENSE.MIT.txt

13

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc