Skip to content

Commit

Permalink
docs: Update README.md and add TypeScript sample
Browse files Browse the repository at this point in the history
- Update README.md to include a note about compiling TypeScript files before running the code.
- Add a new TypeScript sample file to the Sample directory.

Refactor: Update package.json repository URL

- Update the repository URL in package.json to point to the correct GitHub repository.
  • Loading branch information
Clifftech123 committed Sep 27, 2024
1 parent 47916f4 commit b17a732
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

CountryData.js is a comprehensive Node.js package designed to provide easy access to detailed country information. It supports both JavaScript and TypeScript, making it versatile for various project needs. Whether you're building a web application, API, or any other project that requires country data, this package offers a simple and efficient solution.

Make sure to compile TypeScript files to JavaScript before running the code.


## Features

- **Comprehensive Country Data**: Access detailed information including `country names`, `short codes`, `phone codes`, `regions`, and `flags`.
Expand Down
47 changes: 47 additions & 0 deletions Sample/TypeScript/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const countrydata_js_1 = require("countrydata.js");
(() => __awaiter(void 0, void 0, void 0, function* () {
const countryHelper = new countrydata_js_1.CountryHelper();
const allCountries = yield countryHelper.getCountries();
console.log(JSON.stringify(allCountries, null, 2));
}))();
// Get country by short code
(() => __awaiter(void 0, void 0, void 0, function* () {
const countryHelper = new countrydata_js_1.CountryHelper();
const countryData = yield countryHelper.getCountryByShortCode('US');
console.log(countryData);
}))();
// Get regions in a particular country
(() => __awaiter(void 0, void 0, void 0, function* () {
const countryHelper = new countrydata_js_1.CountryHelper();
const regionsData = yield countryHelper.getRegionsByCountryShortCode('GH');
console.log(regionsData);
}))();
// Get country Country Flag
(() => __awaiter(void 0, void 0, void 0, function* () {
const countryHelper = new countrydata_js_1.CountryHelper();
const countryData = yield countryHelper.getCountryByShortCode('US');
console.log(countryData === null || countryData === void 0 ? void 0 : countryData.countryFlag);
}))();
// Get country by phone code
(() => __awaiter(void 0, void 0, void 0, function* () {
const countryHelper = new countrydata_js_1.CountryHelper();
const countryData = yield countryHelper.getCountryByPhoneCode('+233');
console.log(countryData);
}))();
// Get country phone code by short code
(() => __awaiter(void 0, void 0, void 0, function* () {
const countryHelper = new countrydata_js_1.CountryHelper();
const phoneCode = yield countryHelper.getCountryPhoneCodeByShortCode('US');
console.log(phoneCode);
}))();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"author": "Isaiah Clifford Opoku <[email protected]>",
"repository": {
"type": "git",
"url": "https://github.com/frankodoom/CountryData.Net"
"url": "https://github.com/Clifftech123/CountryData.js"
},
"files": [
"dist",
Expand Down

0 comments on commit b17a732

Please sign in to comment.