
World-Countries-Capitals 는 전 세계 모든 국가의 정적 데이터에 액세스 할 수있는 JavaScript 라이브러리입니다.
현재 각 국가에 사용 가능한 데이터는 다음과 같습니다.
Github 또는 Changelog의 릴리스 페이지에서 프로젝트의 모든 변경 사항을 확인할 수 있습니다.
도움이된다면이 프로젝트를 자유롭게주십시오! ?
↑ 메뉴로 돌아갑니다
다음은 Community가 만든 데모/예입니다
↑ 메뉴로 돌아갑니다
NPM으로 설치 :
npm install world-countries-capitals
원사로 설치하십시오 :
yarn add world-countries-capitals
↑ 메뉴로 돌아갑니다
이 패키지를 설치하는 방법에 따라 다르면 사용하는 다른 방법이있을 수 있습니다.
// 1. Load _wcc_ Package
const wcc = require ( 'world-countries-capitals' )
// 2. Use any _wcc_ Method
const randomCountryName = wcc . getRandomCountry ( )
// 3. Play with returned data
console . log ( randomCountryName ) // Possible output: 'poland'↑ 메뉴로 돌아갑니다
각 Country {Object} :
/**
* @typedef {Object} Country
* @property {String} country - Country name
* @property {String} capital - Capital city name
* @property {String} currency - Currency name
* @property {String[]} native_language - Array or native languages
* @property {String} famous_for - Comma separated favourites
* @property {String} phone_code - Phone prefix
* @property {String} flag - Flag image
* @property {String} drive_direction - Drive direction
* @property {String} alcohol_prohibition - Alcohol prohibition status
* @property {Object} area - Country size
* @property {Number} area.km2 - Country size in square kilometers
* @property {Number} area.mi2 - Country size in square miles
* @property {String} continent - Continent that country belong to
* @property {Object} iso - ISO 3166-1 standard codes
* @property {String} iso.numeric - 3-digit code
* @property {String} iso.alpha_2 - 2-letter code
* @property {String} iso.alpha_3 - 3-letter code
* @property {String} tld - Country code top-level domain
* @property {String} constitutional_form - Name of official political system
* @property {String[]} language_codes - Array of language codes
* @property {Boolean} is_landlocked - Is country surrounded by one or more countries
* @property {String[]} neighbors - Array of neighbor countries
*/ 샘플 Country {Object} :
{
country : 'poland' ,
capital : 'warsaw' ,
currency : 'zloty' ,
native_language : [ 'polish' ] ,
famous_for : 'pierogi and potatoes' ,
phone_code : '+48' ,
flag : 'https://flagpedia.net/data/flags/h80/pl.png' ,
drive_direction : 'right' ,
alcohol_prohibition : 'none' ,
area : {
km2 : 312696 ,
mi2 : 120733 ,
} ,
continent : 'eu' ,
iso : {
numeric : '616' ,
alpha_2 : 'pl' ,
alpha_3 : 'pol' ,
} ,
tld : '.pl' ,
constitutional_form : 'republic' ,
language_codes : [ 'pl-PL' ] ,
is_landlocked : false ,
neighbors : [ 'by' , 'cz' , 'de' , 'lt' , 'ru' , 'sk' , 'ua' ] ,
}↑ 메뉴로 돌아갑니다
World-Countries-Capitals 패키지를 가져 오면 아래 나열된 방법에 액세스 할 수 있습니다.
/*
* Get list of all country names
* @returns {String[]}
*/
wcc . getAllCountries ( ) /*
* Get all countries with details
* @returns {Country[]}
*/
wcc . getAllCountryDetails ( ) /*
* Get random country name
* @returns {String}
*/
wcc . getRandomCountry ( ) /*
* Get specific amount of random countries
* @param {Number} amount - amount of countries to get
* @returns {Country[]}
*/
wcc . getNRandomCountriesData ( amount )
// Example: wcc.getNRandomCountriesData(3) /*
* Get country details by its name
* @param {String} name - country name
* @returns {Country}
*/
wcc . getCountryDetailsByName ( name )
// Example: wcc.getCountryDetailsByName('poland') /*
* Get country details by its capital city
* @param {String} capital - name of capital city
* @returns {Country}
*/
wcc . getCountryDetailsByCapital ( capital )
// Example: wcc.getCountryDetailsByCapital('warsaw') /*
* Get all countries by specific language
* @param {String} language - language name
* @returns {Country[]}
*/
wcc . getCountriesByLanguage ( language )
// Example: wcc.getCountriesByLanguage('polish') /*
* Get all countries that are famous for specific thing
* @param {String} famousThing - thing that makes country famous for
* @returns {Country[]}
*/
wcc . getCountriesByFamousFor ( famousThing )
// Example: wcc.getCountriesByFamousFor('pierogi') /*
* Get all countries by specific drive direction
* @param {String} direction - drive direction (one of: 'left', 'right')
* @returns {Country[]}
*/
wcc . getCountriesByDriveDirection ( direction )
// Example: wcc.getCountriesByDriveDirection('left') /*
* Get all countries by alcohol prohibition type
* @param {String} type - prohibition type (one of: 'none', 'limited', 'regional', 'nationwide')
* @returns {Country[]}
*/
wcc . getCountriesByAlcoholProhibition ( type )
// Example: wcc.getCountriesByAlcoholProhibition('nationwide') /*
* Get all countries that are located on specific continent
* @param {String} code - 2-letter continent code (one of: 'AF', 'AN', 'AS', 'EU', 'NA', 'OC', 'SA')
* @returns {Country[]}
*/
wcc . getCountriesByContinent ( code )
// Example: wcc.getCountriesByContinent('eu') /*
* Get country found by one of _ISO 3166-1_ code type
* @param {String} isoType - ISO type (one of: 'numeric', 'alpha-2', 'alpha-3')
* @param {String} isoValue - ISO code of specific country that match to `isoType`
* @returns {Country}
*/
wcc . getCountryDetailsByISO ( isoType , isoValue )
// Example: wcc.getCountryDetailsByISO('numeric', '616') /*
* Get all countries by specific _ccTLD_
* @param {String} tld - name of the _country code top-level domain_ (including `.` character)
* @returns {Country[]}
*/
wcc . getCountriesByTLD ( tld )
// Example: wcc.getCountriesByTLD('.pl') /*
* Get all countries by specific constitutional form
* @param {String} form - name of country constitutional form
* @returns {Country[]}
*/
wcc . getCountriesByConstitutionalForm ( form )
// Example: wcc.getCountriesByConstitutionalForm('republic') /*
* Get all countries that are surrounded by one or more countries
* @param {Boolean} isLandLocked - is country landlocked
* @returns {Country[]}
*/
wcc . getCountriesByLandLock ( isLandLocked )
// Example: wcc.getCountriesByLandLock(true) /**
* Get list of neighbor countries
* @param {String} country - name (or one of ISO 3166-1 code) of country
* @returns {Country[]}
*/
wcc . getCountryNeighbors ( country )
// Example: wcc.getCountryNeighbors('poland')❗️ 모든 매개 변수는 사례에 민감 하지 않으므로 인수가 어떻게 보이든 응답은 동일하게 유지됩니다.
↑ 메뉴로 돌아갑니다
기부금, 문제 및 기능 요청은 항상 환영합니다!
모든 열린 문제를 확인하려면 문제 페이지를 확인하십시오. 오픈 소스 프로젝트에 처음으로 기여한 경우 먼저 기고 가이드 라인을 확인하십시오.
문제를 만들어 새로운 기능을 제안 할 수도 있습니다. 작업하기 전에 확인을 기다리십시오.
↑ 메뉴로 돌아갑니다
이 프로젝트에 기여한 모든 사람을보고 싶다면 기부금 페이지를보십시오!
기여하는 모든 분들께 감사드립니다! ?
↑ 메뉴로 돌아갑니다
저작권 © 2020 Vikrant Bhat.
이 프로젝트는 MIT 라이센스가 부여되었습니다.
↑ 메뉴로 돌아갑니다