UNPKG

geoip_from_cities

Version:

Find the lattitude and longitude from a locally cached cities.json as opposed to google geoip which has limits of 2500 requests per day.

4 lines (3 loc) 839 B
/*! geoip_from_cities 2.2.0 (b884907) | https://gitlab.com/rioadvancement/geoip_from_cities */ var geoip_from_cities=function(){"use strict";const e=require("ramda"),t=require("cities.json"),r=(e,t)=>e+", "+t,n=e.groupBy(function(e){return(e=>e.name+", "+e.country)(e)})(t),o=e.keys(n);let i={};return class{constructor(){}locateCity(t,r){const n=t.toUpperCase(),i=r.toUpperCase();return e.compose(e.filter(e=>{const t=e.toUpperCase();let r=new RegExp(".*, "+i,"g"),o=t.match(r);return null!=o&&o.length>0&&t.indexOf(n)>=0}))(o)}fillWithGeoInfo(e,t,n=!1){let o=i[r(e,t)];return o&&!n||(o=this._searchLive(e,t),i[r(e,t)]=o),o}_searchLive(t,r){return e.compose(e.uniqWith((t,r)=>e.eqBy(e=>t.country==r.country)),e.flatten,e.map(e=>n[e]),e.take(1),e.filter(e=>e.indexOf(r)>0&&e.indexOf(t)>=0))(o)}}}(); //# sourceMappingURL=bundle.min.js.map