Skip to content

Commit

Permalink
Merge pull request #50 from meeDamian/v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
meeDamian authored Sep 4, 2024
2 parents d0cd2c9 + ea4638f commit 02fea49
Show file tree
Hide file tree
Showing 18 changed files with 6,976 additions and 18,035 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["@babel/preset-env"]
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-syntax-import-attributes"]
}
59 changes: 59 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: ['master', 'main']
pull_request:
branches: ['master', 'main']
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20, 22 ]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- name: Publish to npm
run: |
if [[ "${{ github.ref }}" == *-beta* ]]; then
npm publish --tag beta
elif [[ "${{ github.ref }}" == *-alpha* ]]; then
npm publish --tag alpha
else
npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*.log
npm-debug.log*
coverage*
.nyc_output
node_modules
dist/
.idea/
countries.csv
countries-*
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
# country-emoji

[![npm_svg]][npm_url]
[![travis_svg]][travis_url]
[![codeship_svg]][codeship_url]
[![npm_alpha_svg]][npm_url]
[![dl_url]][npm_url]
[![coveralls_svg]][coveralls_url]
[![codecov_svg]][codecov_url]
[![dl_url]][npm_url]
[![xo_svg]][xo_url]
[![license_svg]][license_url]
[![tippin_svg]][tippin_url]


[npm_svg]: https://img.shields.io/npm/v/country-emoji
[npm_alpha_svg]: https://img.shields.io/npm/v/country-emoji/alpha
[npm_url]: https://www.npmjs.com/package/country-emoji

[travis_svg]: https://travis-ci.org/meeDamian/country-emoji.svg?branch=master
[travis_url]: https://travis-ci.org/meeDamian/country-emoji

[codeship_svg]: https://app.codeship.com/projects/4c475430-6f94-0134-4dcc-3acc74581569/status?branch=master
[codeship_url]: https://app.codeship.com/projects/178069
[dl_url]: https://img.shields.io/npm/dw/country-emoji

[coveralls_svg]: https://coveralls.io/repos/github/meeDamian/country-emoji/badge.svg?branch=master
[coveralls_url]: https://coveralls.io/github/meeDamian/country-emoji?branch=master

[codecov_svg]: https://codecov.io/github/meeDamian/country-emoji/coverage.svg?branch=master
[codecov_url]: https://codecov.io/github/meeDamian/country-emoji?branch=master

[dl_url]: https://img.shields.io/npm/dw/country-emoji

[xo_svg]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo_url]: https://github.com/sindresorhus/xo

[license_svg]: https://img.shields.io/npm/l/country-emoji
[license_url]: https://github.com/meeDamian/country-emoji/blob/master/LICENSE

[tippin_svg]: https://img.shields.io/badge/donate-lightning-FDD023?logo=bitcoin&style=flat
[tippin_url]: https://tippin.me/@meeDamian

Converts between country names, ISO 3166-1 codes and flag emojis. **Has zero dependencies.**

## Install

```
$ npm install --save country-emoji
# or
$ npm install --save country-emoji@alpha
```

## Usage

```js
const {flag, code, name, countries} = require('country-emoji');
// or
import {flag, code, name, countries} from 'country-emoji';

flag('CL')
// ~> 🇨🇱
Expand Down Expand Up @@ -101,8 +95,10 @@ Check out the following:

* **Swift:** [SwiftFlags](https://github.com/BubiDevs/SwiftFlags) (ref: [#16](https://github.com/meeDamian/country-emoji/issues/16))
* **Rust:** [country-emoji](https://github.com/leodutra/country-emoji) [[crates.io]] (ref: [#20](https://github.com/meeDamian/country-emoji/issues/20))
* **Python:** [country-emoji](https://github.com/Nnonexistent/country-emoji) [[PyPI]] (ref: [#40](https://github.com/meeDamian/country-emoji/issues/40))

[crates.io]: https://crates.io/crates/country-emoji
[PyPI]: https://pypi.org/project/country-emoji/

PS. Happy to add more here :).

Expand Down
32 changes: 16 additions & 16 deletions countries.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"AI": ["Anguilla", "Anguillian"],
"AL": ["Albania", "Albanian"],
"AM": ["Armenia", "Armenian"],
"AN": "Netherlands Antilles",
"AN": ["Netherlands Antilles"],
"AO": ["Angola", "Angolan"],
"AQ": ["Antarctica", "Antarctican"],
"AR": ["Argentina", "Argentine"],
Expand All @@ -28,12 +28,12 @@
"BL": ["Saint Barthélemy", "Barthélemois", "Saint Barth"],
"BM": ["Bermuda", "Bermudian"],
"BN": ["Brunei Darussalam", "Bruneian"],
"BO": ["Bolivia", "Bolivian"],
"BO": ["Bolivia, Plurinational State of", "Bolivian"],
"BR": ["Brazil", "Brazilian"],
"BS": ["Bahamas", "Bahamian"],
"BT": ["Bhutan", "Bhutanese"],
"BQ": "Caribbean Netherlands",
"BV": "Bouvet Island",
"BQ": ["Caribbean Netherlands"],
"BV": ["Bouvet Island"],
"BW": ["Botswana", "Motswana"],
"BY": ["Belarus", "Belarusian"],
"BZ": ["Belize", "Belizean"],
Expand All @@ -43,7 +43,7 @@
"CF": ["Central African Republic", "Central African"],
"CG": ["Congo"],
"CH": ["Switzerland", "Swiss"],
"CI": ["Cote D'Ivoire", "Ivorian"],
"CI": ["Cote D'Ivoire", "Côte d'Ivoire", "Ivorian"],
"CK": ["Cook Islands", "Cook Islander"],
"CL": ["Chile", "Chilean"],
"CM": ["Cameroon", "Cameroonian"],
Expand All @@ -69,7 +69,7 @@
"ER": ["Eritrea", "Eritrean"],
"ES": ["Spain", "Spanish"],
"ET": ["Ethiopia", "Ethiopian"],
"EU": "European Union",
"EU": ["European Union"],
"FI": ["Finland", "Finnish"],
"FJ": ["Fiji", "Fijian"],
"FK": ["Falkland Islands (Malvinas)", "Falkland Islander"],
Expand Down Expand Up @@ -126,7 +126,7 @@
"KW": ["Kuwait", "Kuwaiti"],
"KY": ["Cayman Islands", "Caymanian"],
"KZ": ["Kazakhstan", "Kazakhstani"],
"LA": ["Lao People's Democratic Republic", "Laotian"],
"LA": ["Lao People's Democratic Republic", "Laos", "Laotian"],
"LB": ["Lebanon", "Lebanese"],
"LC": ["Saint Lucia", "Saint Lucian"],
"LI": ["Liechtenstein", "Liechtensteiner"],
Expand All @@ -136,7 +136,7 @@
"LT": ["Lithuania", "Lithuanian"],
"LU": ["Luxembourg", "Luxembourger"],
"LV": ["Latvia", "Latvian"],
"LY": ["Libyan Arab Jamahiriya", "Libyan"],
"LY": ["Libyan Arab Jamahiriya", "Libya", "Libyan"],
"MA": ["Morocco", "Moroccan"],
"MC": ["Monaco", "Monegasque"],
"MD": ["Moldova, Republic of", "Moldovan"],
Expand Down Expand Up @@ -181,17 +181,17 @@
"PK": ["Pakistan", "Pakistani"],
"PL": ["Poland", "Polish"],
"PM": ["Saint Pierre and Miquelon"],
"PN": ["Pitcairn", "Pitcairn Islander"],
"PN": ["Pitcairn", "Pitcairn Islands", "Pitcairn Islander"],
"PR": ["Puerto Rico", "Puerto Rican"],
"PS": ["Palestinian Territory, Occupied", "Palestine", "Palestinian"],
"PT": ["Portugal", "Portuguese"],
"PW": ["Palau", "Palauan"],
"PY": ["Paraguay", "Paraguayan"],
"QA": ["Qatar", "Qatari"],
"RE": ["Reunion"],
"RE": ["Reunion", "Réunion"],
"RO": ["Romania", "Romanian"],
"RS": ["Serbia", "Serbian"],
"RU": ["Russian Federation", "Russian"],
"RU": ["Russian Federation", "Russia", "Russian"],
"RW": ["Rwanda", "Rwandan"],
"SA": ["Saudi Arabia", "Saudi Arabian"],
"SB": ["Solomon Islands", "Solomon Islander"],
Expand All @@ -209,11 +209,11 @@
"SO": ["Somalia", "Somali"],
"SR": ["Suriname", "Surinamer"],
"SS": ["Republic of South Sudan", "South Sudan", "South Sudanese"],
"ST": ["Sao Tome and Principe", "Sao Tomean"],
"ST": ["Sao Tome and Principe", "São Tomé and Príncipe", "Sao Tomean"],
"SV": ["El Salvador", "Salvadoran"],
"SX": ["Sint Maarten", "Sint Maartener"],
"SY": ["Syrian Arab Republic", "Syrian"],
"SZ": ["Swaziland", "Swazi"],
"SY": ["Syrian Arab Republic", "Syria", "Syrian"],
"SZ": ["Eswatini", "Swaziland", "Swazi"],
"TC": ["Turks and Caicos Islands", "Turks and Caicos Islander"],
"TD": ["Chad", "Chadian"],
"TF": ["French Southern Territories"],
Expand All @@ -225,15 +225,15 @@
"TM": ["Turkmenistan", "Turkmen"],
"TN": ["Tunisia", "Tunisian"],
"TO": ["Tonga", "Tongan"],
"TR": ["Turkey", "Turkish"],
"TR": ["Türkiye","Turkey", "Turkish"],
"TT": ["Trinidad and Tobago", "Trinidadian"],
"TV": ["Tuvalu", "Tuvaluan"],
"TW": ["Taiwan", "Taiwanese"],
"TZ": ["Tanzania, United Republic of", "Tanzanian"],
"UA": ["Ukraine", "Ukrainian"],
"UG": ["Uganda", "Ugandan"],
"UM": ["United States Minor Outlying Islands"],
"US": ["United States", "USA", "American"],
"US": ["United States", "USA", "US", "American"],
"UY": ["Uruguay", "Uruguayan"],
"UZ": ["Uzbekistan", "Uzbekistani"],
"VA": ["Holy See (Vatican City State)", "Vatican"],
Expand Down
15 changes: 7 additions & 8 deletions examples.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env node
'use strict';

function print(fnCall, out, comment = '') {
if (comment) {
comment = `// ${comment}\n`;
}
import {
flag, code, name, countries,
} from './src/main.js';

console.log(`${comment}${fnCall}\n // ~> ${out}\n`);
}
function print(functionCall, out, comment = '') {
comment &&= `// ${comment}\n`;

const {flag, code, name, countries} = require('./src/main.js');
console.log(`${comment}${functionCall}\n // ~> ${out}\n`);
}

print('flag(\'CL\')', flag('CL'));
print('code(\'🇨🇦\')', code('🇨🇦'));
Expand Down
7 changes: 3 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ declare module 'country-emoji' {
export function name(input: string): string | undefined;

/**
* Object that contains every single countries' name and language name.
* Object that contains every single country's name and language name.
* The value is an array of at least one string.
*
* @example {"BG": ["Bulgaria", "Bulgarian"]}; countries["BG"] would be ["Bulgaria", "Bulgarian"]
*
*/
export const countries: {
[key: string]: [string, string];
};
export const countries: Record<string, [string, ...string[]]>;
}
Loading

0 comments on commit 02fea49

Please sign in to comment.