insee-municipality-code

1.2.1Ā ā€¢Ā PublicĀ ā€¢Ā Published

šŸ‡«šŸ‡· Get INSEE municipality code

tested with jest npm version CircleCI Build Status codecov

Simply provide the postal code and / or name of a French municipality and get the most likely INSEE municipality code

Installation

yarnĀ addĀ insee-municipality-code

or

npmĀ iĀ --saveĀ insee-municipality-code

Usage

importĀ InseeCodeĀ fromĀ "insee-municipality-code"
Ā 
InseeCode.getCode({Ā postalCode:Ā "14710",Ā name:Ā "ColombiĆØres"Ā })Ā //Ā "14168"
InseeCode.getCode({Ā name:Ā "Collonbier",Ā postalCode:Ā "15710"Ā })Ā //Ā "14168"
InseeCode.getCode({Ā name:Ā "Lyon"Ā })Ā //Ā "69381"
InseeCode.getMunicipality("14168")Ā //Ā {Ā postalCode:Ā "14710",Ā name:Ā "COLOMBIERES"Ā }
InseeCode.getMunicipality("96501")Ā //Ā null

Api

Method arguments returned value throws
getCode params: { postalCode: string? \| number?, name: string? } string: the most likely Insee code regarding your input will throw if both params are empty
getMunicipality string, params: { postalCode: string? \| number? }? { postalCode: string, name: string }?: the corresponding city (if it exists).1 will throw if insee code is not well formated (/(\d{2}|2[AB])\d{3}/i)

1The second argument is optional and used to help decide which postalCode to return when the city corresponding to the Insee code has many options. e.g. : Saint-Maur-des-FossƩs has Insee code 94068 and postal codes 94100 and 94210.

Dependencies

Limitations

This package loads in memory the name and postal code of 39k+ French towns. You should probably not try to send this package client side.

Contributing

Please fork this package, and run

yarnĀ install
yarnĀ test

Issues

Something is not working as expected? Some result is wrong? Documentation is missing? You need a different feature / API? Please file an issue, we'll be in touch.

References

(in French)

Financial Support

Gofer šŸ¤ (the human-centric work-on-demand solution) is the main support of this package.

Package Sidebar

Install

npm i insee-municipality-code

Weekly Downloads

2

Version

1.2.1

License

MIT

Unpacked Size

2.44 MB

Total Files

13

Last publish

Collaborators

  • aybbyk