knowbee / rwanda

🇷🇼This is a simple npm package that returns provinces, districts, sectors, villages and cells from Rwanda
https://www.npmjs.com/package/rwanda
MIT License
47 stars 20 forks source link

ft: add typescript #27

Open shyakadavis opened 12 months ago

shyakadavis commented 12 months ago

What does this PR do?

e.g.

Before, to access districts, it was:

const { Districts } = require('rwanda');

console.log(Districts('kigali')); // [ 'Gasabo', 'Kicukiro', 'Nyarugenge' ]
console.log(Districts('Kigali', 'South')); // [ 'Gasabo', 'Kicukiro', 'Nyarugenge', 'Huye',.... ]

But now, to ensure consistency and type-safety at least, you pass a single object param, whose properties are required, in order to maintain/retain familiarity with the package.

import { Districts } from "rwanda";

const districts = Districts({ provinces: "Kigali" }); // [ 'Gasabo', 'Kicukiro', 'Nyarugenge' ]
const districts = Districts({ provinces: ["Kigali", "North"] }); // [ 'Gasabo', 'Kicukiro', 'Nyarugenge', 'Huye',.... ]

Description of Task to be completed?

How should this be manually tested?

Any background context you want to provide?