kenya-locations
Version:
A comprehensive and intuitive TypeScript package for working with Kenyan administrative divisions (counties, sub-counties, constituencies, and wards)
2 lines (1 loc) • 1.68 kB
JavaScript
;var y=Object.defineProperty;var d=(t,e,o)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var s=(t,e,o)=>d(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./area-zfFmEagr.cjs"),g=require("./counties-D9ZfM1Ad.cjs"),f=require("./LocationErrors-B_UyK2xz.cjs"),i=require("./maps-B_hwSl98.cjs"),c=i.buildLookupMap(n.localities,t=>t.name.toLowerCase()),u=i.buildLookupMap(g.counties,t=>t.name.toLowerCase()),l=i.buildGroupMap(n.localities,t=>t.county),p=i.buildGroupMap(n.areas,t=>t.locality);class a{constructor(e){s(this,"_data");this._data=e}get name(){return this._data.name}get county(){return this._data.county}get data(){return{...this._data}}areas(){return p.get(this._data.name)??[]}area(e){const o=this.areas().find(r=>r.name.toLowerCase()===e.toLowerCase());if(o)return o;throw new f.LocationNotFoundError("Area",e)}getCounty(){return u.get(this._data.county.toLowerCase())}}function w(){return n.localities}function C(t){const e=c.get(t.toLowerCase());return e?new a(e):void 0}function m(t){return l.get(t)??[]}function M(t){const e=c.get(t.toLowerCase());if(e)return u.get(e.county.toLowerCase())}function h(t){return n.localities.filter(e=>e.name.toLowerCase()===t.toLowerCase()).map(e=>new a(e))}function _(t,e){if(e){const r=(l.get(e)??[]).find(L=>L.name.toLowerCase()===t.toLowerCase());return r?new a(r):void 0}const o=c.get(t.toLowerCase());return o?new a(o):void 0}exports.LocalityWrapper=a;exports.getCountyOfLocality=M;exports.getLocalities=w;exports.getLocalitiesByName=h;exports.getLocalitiesInCounty=m;exports.getLocalityByName=C;exports.locality=_;