@financial-times/countries
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@financial-times/countries

This is a quick implementation of a TypeScript class for finding the correct formatting of a country name in FT style, using ISO3 or ISO2 identifiers.

## Examples

test("Available via constructor", () => {
  const canada = new Country("CA");
  expect(canada).toBeInstanceOf(Country);
  expect(canada.code).toBe("CAN");
  expect(canada.iso3).toBe("CAN");
  expect(canada.iso2).toBe("CA");
  expect(canada.name).toBe("Canada");
  expect(canada.region).toBe("North America");
  expect(canada.ftRegion).toBe("North America");
  expect(canada.worldBankRegion).toBe("North America");
});

test("Available via static methods", () => {
  const expected = {
    iso3: "CAN",
    iso2: "CA",
    name: "Canada",
    worldBankRegion: "North America",
    ftRegion: "North America"
  };
  const byName = Country.byName("Canada");
  const byIso3 = Country.byIso3("CAN");
  const byIso2 = Country.byIso2("CA");
  const byCode = Country.byCode("CAN");

  expect(expected).toEqual(byName);
  expect(expected).toEqual(byIso3);
  expect(expected).toEqual(byIso2);
  expect(expected).toEqual(byCode);
});

Readme

Keywords

Package Sidebar

Install

npm i @financial-times/countries

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

252 kB

Total Files

12

Last publish

Collaborators

  • robgodfrey
  • robertboulton
  • seraph2000
  • hamza.samih
  • notlee
  • emmalewis
  • aendra
  • the-ft
  • rowanmanning
  • chee
  • alexwilson