1.2.1 • Published 4 years ago

insee-municipality-code v1.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

🇫🇷 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

Methodarguments returned value throws
getCodeparams: { postalCode: string? \| number?, name: string? }string: the most likely Insee code regarding your inputwill throw if both params are empty
getMunicipalitystring, params: { postalCode: string? \| number? }?{ postalCode: string, name: string }?: the corresponding city (if it exists).1will 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.

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago