Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'is_landlocked' property #56

Merged
merged 7 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 71 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ This section contains nt to _contribute_ to open source? Try solving our issues
"currency": "afghani",
"native_language": ["dari persian", "pashto"],
"famous_for": "rugs, taliban",
"phone_code": "+93",
"flag": "https://flagpedia.net/data/flags/h80/af.png"
"phone_code": "+93",
"flag": "https://flagpedia.net/data/flags/h80/af.png"
},
{
"country": "albania",
"capital": "tirane",
"currency": "lek",
"native_language": ["albanian"],
"famous_for" : "mother teresa",
"phone_code": "+355",
"flag": "https://flagpedia.net/data/flags/h80/al.png"
"phone_code": "+355",
"flag": "https://flagpedia.net/data/flags/h80/al.png"
},
...
]
Expand Down Expand Up @@ -120,8 +120,8 @@ This section contains nt to _contribute_ to open source? Try solving our issues
currency: "indian rupee",
native_language: ["hindi", "english"],
famous_for: "bollywood, yoga, hinduism, food and diversity",
phone_code: "+91",
flag: "https://flagpedia.net/data/flags/h80/in.png"
phone_code: "+91",
flag: "https://flagpedia.net/data/flags/h80/in.png"
},
];
```
Expand All @@ -140,8 +140,8 @@ This section contains nt to _contribute_ to open source? Try solving our issues
currency: "indian rupee",
native_language: ["hindi", "english"],
famous_for: "bollywood, yoga, hinduism, food and diversity",
phone_code: "+91",
flag: "https://flagpedia.net/data/flags/h80/in.png"
phone_code: "+91",
flag: "https://flagpedia.net/data/flags/h80/in.png"
},
];
```
Expand Down Expand Up @@ -178,34 +178,34 @@ This section contains nt to _contribute_ to open source? Try solving our issues
currency: "burundi franc",
native_language: ["kirundi", "french"],
famous_for: "wildlife and greenery",
phone_code: "+257",
flag: "https://flagpedia.net/data/flags/h80/bi.png"
phone_code: "+257",
flag: "https://flagpedia.net/data/flags/h80/bi.png"
},
{
country: "palau",
capital: "melekeok",
currency: "united states dollar",
native_language: ["english", "palauan"],
famous_for: "jellyfish lake",
phone_code: "+680",
flag: "https://flagpedia.net/data/flags/h80/pw.png"
phone_code: "+680",
flag: "https://flagpedia.net/data/flags/h80/pw.png"
},
{
country: "dominican republic",
capital: "santo domingo",
currency: "dominican peso",
native_language: ["spanish"],
famous_for: "blue ocean water, white-sand beaches and beautiful resorts",
phone_code: "+1-809, +1-829, +1-849",
flag: "https://flagpedia.net/data/flags/h80/do.png"
phone_code: "+1-809, +1-829, +1-849",
flag: "https://flagpedia.net/data/flags/h80/do.png"
},
];
```

---

- `getCountriesByFamousFor(famousThing)` <br>
This method returns an array of objects, each object containing **country**, **capital**, **currency**, **native_language**, **famouse_for**, **phone_code**, and **flag** sorted by the _famousThing_ passed as the parameter.<br>
This method returns an array of objects, each object containing **country**, **capital**, **currency**, **native_language**, **famous_for**, **phone_code**, and **flag** sorted by the _famousThing_ passed as the parameter.<br>
Response for getCountriesByFamousFor('oil')

```javascript
Expand All @@ -216,56 +216,88 @@ This section contains nt to _contribute_ to open source? Try solving our issues
currency: 'algerian dinar',
native_language: ['arabic', 'tamazight', 'french'],
famous_for: 'oil and gas reserves',
phone_code: '+213',
flag: "https://flagpedia.net/data/flags/h80/dz.png"
phone_code: '+213',
flag: "https://flagpedia.net/data/flags/h80/dz.png"
},
{
country: 'angola',
capital: 'luanda',
currency: 'kwanza',
native_language: ['portuguese'],
famous_for: 'oil',
phone_code: '+244',
flag: "https://flagpedia.net/data/flags/h80/ao.png"
phone_code: '+244',
flag: "https://flagpedia.net/data/flags/h80/ao.png"
},
{
country: 'bahrain',
capital: 'manama',
currency: 'bahraini dinar',
native_language: ['arabic'],
famous_for: 'oil, pearls and world heritage sites',
phone_code: '+973',
flag: "https://flagpedia.net/data/flags/h80/bh.png"
phone_code: '+973',
flag: "https://flagpedia.net/data/flags/h80/bh.png"
},
{
country: 'bulgaria',
capital: 'sofia',
currency: 'lev',
native_language: ['bulgarian'],
famous_for: 'lavender oil and the rose valley',
phone_code: '+359',
flag: "https://flagpedia.net/data/flags/h80/bg.png"
phone_code: '+359',
flag: "https://flagpedia.net/data/flags/h80/bg.png"
},
{
country: 'central african republic',
capital: 'bangui',
currency: 'central african cfa franc',
native_language: ['sango', 'french'],
famous_for: 'diamonds, gold, oil and uranium',
phone_code: '+236',
flag: "https://flagpedia.net/data/flags/h80/cf.png"
phone_code: '+236',
flag: "https://flagpedia.net/data/flags/h80/cf.png"
},
{
country: 'norway',
capital: 'oslo',
currency: 'norwegian krone',
native_language: ['norwegian'],
famous_for: 'oil, fjords, mountains and midnight sun',
phone_code: '+47',
flag: "https://flagpedia.net/data/flags/h80/no.png"
phone_code: '+47',
flag: "https://flagpedia.net/data/flags/h80/no.png"
},
];
```
---

- `getCountriesByLandLock(isLandLocked: boolean)` <br>
This method returns an array of objects, each object containing **country**, **capital**, **currency**, **native_language**, **famous_for**, **phone_code**, **flag**, **drive_direction** and **is_landlocked** sorted by the _isLandlocked property which is boolean_ passed as the parameter.<br>
Response for getCountriesByLandLock(true)

```javascript
[
{
country: 'afghanistan',
capital: 'kabul',
currency: 'afghani',
native_language: ['dari persian', 'pashto'],
famous_for: 'rugs, taliban',
phone_code: '+93',
flag: 'https://flagpedia.net/data/flags/h80/af.png',
drive_direction: 'right',
is_landlocked: true
},
{
country: 'andorra',
capital: 'andorra la vella',
currency: 'euro',
native_language: ['catalan'],
famous_for: 'tourism and tobacco',
phone_code: '+244',
flag: 'https://flagpedia.net/data/flags/h80/ad.png',
drive_direction: 'right',
is_landlocked: true
}
];
```

# Example Use Cases

Expand Down Expand Up @@ -371,6 +403,18 @@ console.log(wcc.getCountriesByFamousFor("oil"));

---

### Example #9

> Get the details of all `countries` that are '_landlocked_'.

```javascript
const wcc = require("world-countries-capitals");

console.log(wcc.getCountriesByLandLock(true));
```

---

## Demo

In this [Vue.js demo](https://codesandbox.io/s/wcc-demo-tux1b), the package methods are used to search countries by a selected field (name, capital, language, famous for)
Expand Down