rwanda
Version:
This package provides you access to provinces, districts, sectors, villages and cells found in Rwanda
183 lines (129 loc) • 5.39 kB
Markdown
[](https://www.npmjs.com/package/rwanda)
[](https://www.npmjs.com/package/rwanda)
[](https://opensource.org/licenses/MIT)
[](http://www.typescriptlang.org/)
A comprehensive TypeScript/JavaScript library for accessing administrative divisions of Rwanda. This package provides type-safe access to provinces, districts, sectors, cells, and villages in Rwanda.
Rwanda is administratively organized into:
- 5 Provinces (including Kigali City)
- 30 Districts
- 416 Sectors
- 2,148 Cells
- 14,837 Villages
```bash
npm install rwanda
yarn add rwanda
pnpm add rwanda
```
```javascript
const { Provinces, Districts } = require('rwanda');
console.log(Provinces());
// Output: ['East', 'Kigali', 'North', 'South', 'West']
console.log(Districts('kigali'));
// Output: ['Gasabo', 'Kicukiro', 'Nyarugenge']
```
```typescript
import { Provinces, Districts, Sectors } from 'rwanda';
// Get all provinces
const provinces: string[] = Provinces();
// Get districts in Kigali
const kigaliDistricts: string[] = Districts('kigali');
// Get sectors in Gasabo district
const gasaboSectors: string[] = Sectors('kigali', 'gasabo');
```
Returns an array of all provinces in Rwanda.
```typescript
import { Provinces } from 'rwanda';
const provinces = Provinces();
// Returns: ['East', 'Kigali', 'North', 'South', 'West']
```
- `province` (optional): Name of the province to filter districts
Returns an array of districts. If a province is provided, returns only districts in that province.
```typescript
import { Districts } from 'rwanda';
// Get all districts in Rwanda
const allDistricts = Districts();
// Get districts in Kigali
const kigaliDistricts = Districts('kigali');
// Returns: ['Gasabo', 'Kicukiro', 'Nyarugenge']
```
- `province` (optional): Name of the province
- `district` (optional): Name of the district to filter sectors
Returns sectors based on the provided filters.
```typescript
import { Sectors } from 'rwanda';
// Get all sectors in Rwanda
const allSectors = Sectors();
// Get sectors in Gasabo district, Kigali
const gasaboSectors = Sectors('kigali', 'gasabo');
```
- `province` (optional): Name of the province
- `district` (optional): Name of the district
- `sector` (optional): Name of the sector to filter cells
Returns cells based on the provided filters.
- `province` (optional): Name of the province
- `district` (optional): Name of the district
- `sector` (optional): Name of the sector
- `cell` (optional): Name of the cell to filter villages
Returns villages based on the provided filters.
The package includes TypeScript type definitions out of the box. All functions are properly typed:
```typescript
// TypeScript will infer the return type as string[]
const districts: string[] = Districts('kigali');
// TypeScript will show an error for invalid province names
const invalid = Districts('invalid'); // TypeScript error
```
All input parameters are case-insensitive:
```typescript
// All these are equivalent
Districts('kigali');
Districts('Kigali');
Districts('KIGALI');
```
When invalid parameters are provided, the functions return `undefined`:
```typescript
const result = Districts('Nonexistent Province');
console.log(result); // undefined
```
```cli
yarn add rwanda
```
<table>
<tr>
<td align="center"><a href="https://github.com/shyakadavis"><img
style="border-radius:50%"
src="https://github.com/shyakadavis.png" width="100px;" alt="Shyaka Davis"/><br /><sub><b>
Shyaka Davis</b></sub></td>
<td align="center"><a href="https://github.com/Karlmusingo"><img
style="border-radius:50%"
src="https://github.com/Karlmusingo.png" width="100px;" alt="Karl MUSINGO"/><br /><sub><b>
Karl MUSINGO</b></sub></td>
<td align="center"><a href="https://github.com/YvesIraguha"><img
style="border-radius:50%" src="https://github.com/YvesIraguha.png" width="100px;" alt="Yves Iraguha<"/><br /><sub><b>Yves Iraguha</b></sub></td>
<td align="center"><a href="https://github.com/abayo-luc"><img
style="border-radius:50%" src="https://github.com/abayo-luc.png" width="100px;" alt="Abayo Luc"/><br /><sub><b>Abayo Luc</b></sub></td>
<td align="center"><a href="https://github.com/oesukam"><img
style="border-radius:50%" src="https://github.com/oesukam.png" width="100px;" alt="Olivier Esuka"/><br /><sub><b>Olivier Esuka</b></sub></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/knowbee"><img
style="border-radius:50%" src="https://github.com/knowbee.png" width="100px;" alt="Igwaneza Bruce"/><br /><sub><b>Igwaneza Bruce</b></sub></td>
</tr>
</table>