Skip to content

fernandobritto/central-cities

Repository files navigation

Central Cities

NPM package to get the capital of the countries

npm npm NPM

Getting Started

Prerequisites

node -v
node: >= v8.3

Installing

Using npm

npm install --save central-cities
npm i central-cities

Using Yarn

yarn add central-cities

How to use

Importing with Commonjs style

const Countries = require('central-cities')
const countries = new Countries()

Importing with ES6 modules style

import Countries from 'central-cities'
const countries = new Countries()

Filter by name

const portugal = countries.byName('portugal')

/**
 * Get all country data
 [{
    "country": "Portugal",
    "city": "Lisboa",
    "independence": "1143",
    "location": "Southern Europe"
 }]
*/
portugal.toJson()

// get capital
portugal.capital // Lisboa

TypeScript is supported

import Countries from 'central-cities'
const countries = new Countries()

countries.locations() // return type: array of strings
const portugal = countries.byName('portugal') // return type: Countries class
portugal.capital // return type: string ("Lisboa")

About

NPM package to get the capital of the countries

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published