Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

Reference · French country module

getDepartmentFromFrenchPostcodefunction

The department a postcode's number belongs to, by its code: 75 for 75008, 2B for 20200, 971 for 97100.

Import it

import { getDepartmentFromFrenchPostcode } from "@johnmorrisdotca/address-plus/fr";

Definition

function getDepartmentFromFrenchPostcode(postcode: string): string | undefined

Parameters

NameTypeDescription
postcodestring

The postcode.

Returns

string | undefined

The department's code; undefined for a postcode in a collectivity or Monaco, one that no department has, or text that is not a postcode.

Examples

import { getDepartmentFromFrenchPostcode } from "@johnmorrisdotca/address-plus/fr";

console.log(["75008", "20190", "20200", "97400", "98714", "98000"].map(getDepartmentFromFrenchPostcode));
// → ["75","2A","2B","974",null,null]
[ '75', '2A', '2B', '974', undefined, undefined ]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.7.0.