Socket
Socket
Sign inDemoInstall

geo-tz

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-tz - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

2

dist/find.d.ts

@@ -25,3 +25,3 @@ declare type CacheOptions = {

*/
export default function getTimezone(lat: number, lon: number): string[];
export declare function find(lat: number, lon: number): string[];
export { cacheLevel as setCache };

@@ -28,0 +28,0 @@ /**

@@ -1,2 +0,2 @@

var t=require("fs"),e=require("path"),r=require("geobuf"),i=require("@turf/boolean-point-in-polygon"),o=require("@turf/helpers"),n=require("pbf");function f(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function d(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,e}var a=/*#__PURE__*/d(t),l=/*#__PURE__*/d(e),c=/*#__PURE__*/f(i),u=/*#__PURE__*/f(n),g=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function h(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];for(var e=[],r=0;r<g.length;r++){var i=g[r];if(i.left<=t&&i.right>=t)e.push(i.tzid);else if(i.right<t)break}return e}var p,s=require("../data/index.json"),E=l.join(__dirname,"..","data","geo.dat");function m(t){if(p=t&&t.store&&"function"==typeof t.store.get&&"function"==typeof t.store.set?t.store:new Map,t&&t.preload){var e=a.openSync(E,"r");if(e<0)throw new Error("Failed to open geo.dat file");!function(t){!function e(r,i){if(r.pos>=0&&r.len){var o=z(0,r.pos,r.len,t);p.set(i,o)}else"object"==typeof r&&Object.getOwnPropertyNames(r).forEach(function(t){e(r[t],i+t)})}(s.lookup,"")}(e),a.closeSync(e)}}function z(t,e,i,o){void 0===o&&(o=-1);var n=o;if(n<0&&(n=a.openSync(E,"r"))<0)throw new Error("Failed to open geo.dat file");var f=Buffer.alloc(i),d=a.readSync(n,f,0,i,e);if(o<0&&a.closeSync(n),d<i)throw new Error("tried to read "+i+" bytes from geo.dat but only got "+d+" bytes");var l=new u.default(f);return r.decode(l)}m(),exports.default=function(t,e){var r=e;if(isNaN(t)||t>90||t<-90)throw new Error("Invalid latitude: "+t);if(isNaN(e)||e>180||e<-180)throw new Error("Invalid longitude: "+e);if(90===t)return g.map(function(t){return t.tzid});t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),e>=179.9999?e=179.9999:e<=-179.9999&&(e=-179.9999);for(var i=o.point([e,t]),n={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0},f="",d=s.lookup;;){var a=void 0;if(t>=n.midLat&&e>=n.midLon?(a="a",n.bottom=n.midLat,n.left=n.midLon):t>=n.midLat&&e<n.midLon?(a="b",n.bottom=n.midLat,n.right=n.midLon):t<n.midLat&&e<n.midLon?(a="c",n.top=n.midLat,n.right=n.midLon):(a="d",n.top=n.midLat,n.left=n.midLon),f+=a,!(d=d[a]))return h(r);if(d.pos>=0&&d.len){var l=p.get(f);l||(l=z(0,d.pos,d.len),p.set(f,l));for(var u=[],E=0;E<l.features.length;E++)c.default(i,l.features[E])&&u.push(l.features[E].properties.tzid);return u.length>0?u:h(r)}if(d.length>0)return d.map(function(t){return s.timezones[t]});if("object"!=typeof d)throw new Error("Unexpected data type");n.midLat=(n.top+n.bottom)/2,n.midLon=(n.left+n.right)/2}},exports.preCache=function(){m({preload:!0})},exports.setCache=m;
var t=require("fs"),e=require("path"),r=require("geobuf"),i=require("@turf/boolean-point-in-polygon"),o=require("@turf/helpers"),n=require("pbf");function f(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function d(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,e}var a=/*#__PURE__*/d(t),l=/*#__PURE__*/d(e),c=/*#__PURE__*/f(i),u=/*#__PURE__*/f(n),g=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function h(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];for(var e=[],r=0;r<g.length;r++){var i=g[r];if(i.left<=t&&i.right>=t)e.push(i.tzid);else if(i.right<t)break}return e}var p,s=require("../data/index.json"),E=l.join(__dirname,"..","data","geo.dat");function m(t){if(p=t&&t.store&&"function"==typeof t.store.get&&"function"==typeof t.store.set?t.store:new Map,t&&t.preload){var e=a.openSync(E,"r");if(e<0)throw new Error("Failed to open geo.dat file");!function(t){!function e(r,i){if(r.pos>=0&&r.len){var o=z(0,r.pos,r.len,t);p.set(i,o)}else"object"==typeof r&&Object.getOwnPropertyNames(r).forEach(function(t){e(r[t],i+t)})}(s.lookup,"")}(e),a.closeSync(e)}}function z(t,e,i,o){void 0===o&&(o=-1);var n=o;if(n<0&&(n=a.openSync(E,"r"))<0)throw new Error("Failed to open geo.dat file");var f=Buffer.alloc(i),d=a.readSync(n,f,0,i,e);if(o<0&&a.closeSync(n),d<i)throw new Error("tried to read "+i+" bytes from geo.dat but only got "+d+" bytes");var l=new u.default(f);return r.decode(l)}m(),exports.find=function(t,e){var r=e;if(isNaN(t)||t>90||t<-90)throw new Error("Invalid latitude: "+t);if(isNaN(e)||e>180||e<-180)throw new Error("Invalid longitude: "+e);if(90===t)return g.map(function(t){return t.tzid});t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),e>=179.9999?e=179.9999:e<=-179.9999&&(e=-179.9999);for(var i=o.point([e,t]),n={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0},f="",d=s.lookup;;){var a=void 0;if(t>=n.midLat&&e>=n.midLon?(a="a",n.bottom=n.midLat,n.left=n.midLon):t>=n.midLat&&e<n.midLon?(a="b",n.bottom=n.midLat,n.right=n.midLon):t<n.midLat&&e<n.midLon?(a="c",n.top=n.midLat,n.right=n.midLon):(a="d",n.top=n.midLat,n.left=n.midLon),f+=a,!(d=d[a]))return h(r);if(d.pos>=0&&d.len){var l=p.get(f);l||(l=z(0,d.pos,d.len),p.set(f,l));for(var u=[],E=0;E<l.features.length;E++)c.default(i,l.features[E])&&u.push(l.features[E].properties.tzid);return u.length>0?u:h(r)}if(d.length>0)return d.map(function(t){return s.timezones[t]});if("object"!=typeof d)throw new Error("Unexpected data type");n.midLat=(n.top+n.bottom)/2,n.midLon=(n.left+n.right)/2}},exports.preCache=function(){m({preload:!0})},exports.setCache=m;
//# sourceMappingURL=geo-tz.js.map

@@ -1,2 +0,2 @@

import*as t from"fs";import*as e from"path";import{decode as i}from"geobuf";import o from"@turf/boolean-point-in-polygon";import{point as r}from"@turf/helpers";import n from"pbf";const f=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function d(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];const e=[];for(let i=0;i<f.length;i++){const o=f[i];if(o.left<=t&&o.right>=t)e.push(o.tzid);else if(o.right<t)break}return e}const l=require("../data/index.json"),c=e.join(__dirname,"..","data","geo.dat");let a;function h(e){if(a=e&&e.store&&"function"==typeof e.store.get&&"function"==typeof e.store.set?e.store:new Map,e&&e.preload){const e=t.openSync(c,"r");if(e<0)throw new Error("Failed to open geo.dat file");!function(t){!function e(i,o){if(i.pos>=0&&i.len){const e=g(0,i.pos,i.len,t);a.set(o,e)}else"object"==typeof i&&Object.getOwnPropertyNames(i).forEach(function(t){e(i[t],o+t)})}(l.lookup,"")}(e),t.closeSync(e)}}function g(e,o,r,f=-1){let d=f;if(d<0&&(d=t.openSync(c,"r"),d<0))throw new Error("Failed to open geo.dat file");const l=Buffer.alloc(r),a=t.readSync(d,l,0,r,o);if(f<0&&t.closeSync(d),a<r)throw new Error(`tried to read ${r} bytes from geo.dat but only got ${a} bytes`);const h=new n(l);return i(h)}function s(t,e){const i=e;let n;if(isNaN(t)||t>90||t<-90)throw n=new Error("Invalid latitude: "+t),n;if(isNaN(e)||e>180||e<-180)throw n=new Error("Invalid longitude: "+e),n;if(90===t)return f.map(t=>t.tzid);t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),e>=179.9999?e=179.9999:e<=-179.9999&&(e=-179.9999);const c=r([e,t]),h={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0};let s="",p=l.lookup;for(;;){let r;if(t>=h.midLat&&e>=h.midLon?(r="a",h.bottom=h.midLat,h.left=h.midLon):t>=h.midLat&&e<h.midLon?(r="b",h.bottom=h.midLat,h.right=h.midLon):t<h.midLat&&e<h.midLon?(r="c",h.top=h.midLat,h.right=h.midLon):(r="d",h.top=h.midLat,h.left=h.midLon),p=p[r],s+=r,!p)return d(i);if(p.pos>=0&&p.len){let t=a.get(s);t||(t=g(0,p.pos,p.len),a.set(s,t));const e=[];for(let i=0;i<t.features.length;i++)o(c,t.features[i])&&e.push(t.features[i].properties.tzid);return e.length>0?e:d(i)}if(p.length>0)return p.map(t=>l.timezones[t]);if("object"!=typeof p)throw n=new Error("Unexpected data type"),n;h.midLat=(h.top+h.bottom)/2,h.midLon=(h.left+h.right)/2}}function p(){h({preload:!0})}h();export{s as default,p as preCache,h as setCache};
import*as t from"fs";import*as e from"path";import{decode as i}from"geobuf";import o from"@turf/boolean-point-in-polygon";import{point as r}from"@turf/helpers";import n from"pbf";const f=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function d(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];const e=[];for(let i=0;i<f.length;i++){const o=f[i];if(o.left<=t&&o.right>=t)e.push(o.tzid);else if(o.right<t)break}return e}const l=require("../data/index.json"),c=e.join(__dirname,"..","data","geo.dat");let a;function h(e){if(a=e&&e.store&&"function"==typeof e.store.get&&"function"==typeof e.store.set?e.store:new Map,e&&e.preload){const e=t.openSync(c,"r");if(e<0)throw new Error("Failed to open geo.dat file");!function(t){!function e(i,o){if(i.pos>=0&&i.len){const e=g(0,i.pos,i.len,t);a.set(o,e)}else"object"==typeof i&&Object.getOwnPropertyNames(i).forEach(function(t){e(i[t],o+t)})}(l.lookup,"")}(e),t.closeSync(e)}}function g(e,o,r,f=-1){let d=f;if(d<0&&(d=t.openSync(c,"r"),d<0))throw new Error("Failed to open geo.dat file");const l=Buffer.alloc(r),a=t.readSync(d,l,0,r,o);if(f<0&&t.closeSync(d),a<r)throw new Error(`tried to read ${r} bytes from geo.dat but only got ${a} bytes`);const h=new n(l);return i(h)}function s(t,e){const i=e;let n;if(isNaN(t)||t>90||t<-90)throw n=new Error("Invalid latitude: "+t),n;if(isNaN(e)||e>180||e<-180)throw n=new Error("Invalid longitude: "+e),n;if(90===t)return f.map(t=>t.tzid);t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),e>=179.9999?e=179.9999:e<=-179.9999&&(e=-179.9999);const c=r([e,t]),h={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0};let s="",p=l.lookup;for(;;){let r;if(t>=h.midLat&&e>=h.midLon?(r="a",h.bottom=h.midLat,h.left=h.midLon):t>=h.midLat&&e<h.midLon?(r="b",h.bottom=h.midLat,h.right=h.midLon):t<h.midLat&&e<h.midLon?(r="c",h.top=h.midLat,h.right=h.midLon):(r="d",h.top=h.midLat,h.left=h.midLon),p=p[r],s+=r,!p)return d(i);if(p.pos>=0&&p.len){let t=a.get(s);t||(t=g(0,p.pos,p.len),a.set(s,t));const e=[];for(let i=0;i<t.features.length;i++)o(c,t.features[i])&&e.push(t.features[i].properties.tzid);return e.length>0?e:d(i)}if(p.length>0)return p.map(t=>l.timezones[t]);if("object"!=typeof p)throw n=new Error("Unexpected data type"),n;h.midLat=(h.top+h.bottom)/2,h.midLon=(h.left+h.right)/2}}function p(){h({preload:!0})}h();export{s as find,p as preCache,h as setCache};
//# sourceMappingURL=geo-tz.modern.js.map

@@ -1,2 +0,2 @@

import*as t from"fs";import*as i from"path";import{decode as r}from"geobuf";import e from"@turf/boolean-point-in-polygon";import{point as o}from"@turf/helpers";import f from"pbf";var n=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function d(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];for(var i=[],r=0;r<n.length;r++){var e=n[r];if(e.left<=t&&e.right>=t)i.push(e.tzid);else if(e.right<t)break}return i}var a,l=require("../data/index.json"),c=i.join(__dirname,"..","data","geo.dat");function h(i){if(a=i&&i.store&&"function"==typeof i.store.get&&"function"==typeof i.store.set?i.store:new Map,i&&i.preload){var r=t.openSync(c,"r");if(r<0)throw new Error("Failed to open geo.dat file");!function(t){!function i(r,e){if(r.pos>=0&&r.len){var o=g(0,r.pos,r.len,t);a.set(e,o)}else"object"==typeof r&&Object.getOwnPropertyNames(r).forEach(function(t){i(r[t],e+t)})}(l.lookup,"")}(r),t.closeSync(r)}}function g(i,e,o,n){void 0===n&&(n=-1);var d=n;if(d<0&&(d=t.openSync(c,"r"))<0)throw new Error("Failed to open geo.dat file");var a=Buffer.alloc(o),l=t.readSync(d,a,0,o,e);if(n<0&&t.closeSync(d),l<o)throw new Error("tried to read "+o+" bytes from geo.dat but only got "+l+" bytes");var h=new f(a);return r(h)}function p(t,i){var r=i;if(isNaN(t)||t>90||t<-90)throw new Error("Invalid latitude: "+t);if(isNaN(i)||i>180||i<-180)throw new Error("Invalid longitude: "+i);if(90===t)return n.map(function(t){return t.tzid});t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),i>=179.9999?i=179.9999:i<=-179.9999&&(i=-179.9999);for(var f=o([i,t]),c={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0},h="",p=l.lookup;;){var m=void 0;if(t>=c.midLat&&i>=c.midLon?(m="a",c.bottom=c.midLat,c.left=c.midLon):t>=c.midLat&&i<c.midLon?(m="b",c.bottom=c.midLat,c.right=c.midLon):t<c.midLat&&i<c.midLon?(m="c",c.top=c.midLat,c.right=c.midLon):(m="d",c.top=c.midLat,c.left=c.midLon),h+=m,!(p=p[m]))return d(r);if(p.pos>=0&&p.len){var u=a.get(h);u||(u=g(0,p.pos,p.len),a.set(h,u));for(var s=[],E=0;E<u.features.length;E++)e(f,u.features[E])&&s.push(u.features[E].properties.tzid);return s.length>0?s:d(r)}if(p.length>0)return p.map(function(t){return l.timezones[t]});if("object"!=typeof p)throw new Error("Unexpected data type");c.midLat=(c.top+c.bottom)/2,c.midLon=(c.left+c.right)/2}}function m(){h({preload:!0})}h();export{p as default,m as preCache,h as setCache};
import*as t from"fs";import*as i from"path";import{decode as r}from"geobuf";import e from"@turf/boolean-point-in-polygon";import{point as o}from"@turf/helpers";import f from"pbf";var n=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function d(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];for(var i=[],r=0;r<n.length;r++){var e=n[r];if(e.left<=t&&e.right>=t)i.push(e.tzid);else if(e.right<t)break}return i}var a,l=require("../data/index.json"),c=i.join(__dirname,"..","data","geo.dat");function h(i){if(a=i&&i.store&&"function"==typeof i.store.get&&"function"==typeof i.store.set?i.store:new Map,i&&i.preload){var r=t.openSync(c,"r");if(r<0)throw new Error("Failed to open geo.dat file");!function(t){!function i(r,e){if(r.pos>=0&&r.len){var o=g(0,r.pos,r.len,t);a.set(e,o)}else"object"==typeof r&&Object.getOwnPropertyNames(r).forEach(function(t){i(r[t],e+t)})}(l.lookup,"")}(r),t.closeSync(r)}}function g(i,e,o,n){void 0===n&&(n=-1);var d=n;if(d<0&&(d=t.openSync(c,"r"))<0)throw new Error("Failed to open geo.dat file");var a=Buffer.alloc(o),l=t.readSync(d,a,0,o,e);if(n<0&&t.closeSync(d),l<o)throw new Error("tried to read "+o+" bytes from geo.dat but only got "+l+" bytes");var h=new f(a);return r(h)}function p(t,i){var r=i;if(isNaN(t)||t>90||t<-90)throw new Error("Invalid latitude: "+t);if(isNaN(i)||i>180||i<-180)throw new Error("Invalid longitude: "+i);if(90===t)return n.map(function(t){return t.tzid});t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),i>=179.9999?i=179.9999:i<=-179.9999&&(i=-179.9999);for(var f=o([i,t]),c={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0},h="",p=l.lookup;;){var m=void 0;if(t>=c.midLat&&i>=c.midLon?(m="a",c.bottom=c.midLat,c.left=c.midLon):t>=c.midLat&&i<c.midLon?(m="b",c.bottom=c.midLat,c.right=c.midLon):t<c.midLat&&i<c.midLon?(m="c",c.top=c.midLat,c.right=c.midLon):(m="d",c.top=c.midLat,c.left=c.midLon),h+=m,!(p=p[m]))return d(r);if(p.pos>=0&&p.len){var u=a.get(h);u||(u=g(0,p.pos,p.len),a.set(h,u));for(var s=[],E=0;E<u.features.length;E++)e(f,u.features[E])&&s.push(u.features[E].properties.tzid);return s.length>0?s:d(r)}if(p.length>0)return p.map(function(t){return l.timezones[t]});if("object"!=typeof p)throw new Error("Unexpected data type");c.midLat=(c.top+c.bottom)/2,c.midLon=(c.left+c.right)/2}}function m(){h({preload:!0})}h();export{p as find,m as preCache,h as setCache};
//# sourceMappingURL=geo-tz.module.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("fs"),require("path"),require("geobuf"),require("@turf/boolean-point-in-polygon"),require("@turf/helpers"),require("pbf")):"function"==typeof define&&define.amd?define(["exports","fs","path","geobuf","@turf/boolean-point-in-polygon","@turf/helpers","pbf"],e):e((t||self).geoTz={},t.fs,t.path,t.geobuf,t.inside,t.helpers,t.pbf)}(this,function(t,e,r,i,o,n,f){function d(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function l(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,e}var a=/*#__PURE__*/l(e),c=/*#__PURE__*/l(r),u=/*#__PURE__*/d(o),h=/*#__PURE__*/d(f),p=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function g(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];for(var e=[],r=0;r<p.length;r++){var i=p[r];if(i.left<=t&&i.right>=t)e.push(i.tzid);else if(i.right<t)break}return e}var s,E=require("../data/index.json"),m=c.join(__dirname,"..","data","geo.dat");function z(t){if(s=t&&t.store&&"function"==typeof t.store.get&&"function"==typeof t.store.set?t.store:new Map,t&&t.preload){var e=a.openSync(m,"r");if(e<0)throw new Error("Failed to open geo.dat file");!function(t){!function e(r,i){if(r.pos>=0&&r.len){var o=T(0,r.pos,r.len,t);s.set(i,o)}else"object"==typeof r&&Object.getOwnPropertyNames(r).forEach(function(t){e(r[t],i+t)})}(E.lookup,"")}(e),a.closeSync(e)}}function T(t,e,r,o){void 0===o&&(o=-1);var n=o;if(n<0&&(n=a.openSync(m,"r"))<0)throw new Error("Failed to open geo.dat file");var f=Buffer.alloc(r),d=a.readSync(n,f,0,r,e);if(o<0&&a.closeSync(n),d<r)throw new Error("tried to read "+r+" bytes from geo.dat but only got "+d+" bytes");var l=new h.default(f);return i.decode(l)}z(),t.default=function(t,e){var r=e;if(isNaN(t)||t>90||t<-90)throw new Error("Invalid latitude: "+t);if(isNaN(e)||e>180||e<-180)throw new Error("Invalid longitude: "+e);if(90===t)return p.map(function(t){return t.tzid});t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),e>=179.9999?e=179.9999:e<=-179.9999&&(e=-179.9999);for(var i=n.point([e,t]),o={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0},f="",d=E.lookup;;){var l=void 0;if(t>=o.midLat&&e>=o.midLon?(l="a",o.bottom=o.midLat,o.left=o.midLon):t>=o.midLat&&e<o.midLon?(l="b",o.bottom=o.midLat,o.right=o.midLon):t<o.midLat&&e<o.midLon?(l="c",o.top=o.midLat,o.right=o.midLon):(l="d",o.top=o.midLat,o.left=o.midLon),f+=l,!(d=d[l]))return g(r);if(d.pos>=0&&d.len){var a=s.get(f);a||(a=T(0,d.pos,d.len),s.set(f,a));for(var c=[],h=0;h<a.features.length;h++)u.default(i,a.features[h])&&c.push(a.features[h].properties.tzid);return c.length>0?c:g(r)}if(d.length>0)return d.map(function(t){return E.timezones[t]});if("object"!=typeof d)throw new Error("Unexpected data type");o.midLat=(o.top+o.bottom)/2,o.midLon=(o.left+o.right)/2}},t.preCache=function(){z({preload:!0})},t.setCache=z});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("fs"),require("path"),require("geobuf"),require("@turf/boolean-point-in-polygon"),require("@turf/helpers"),require("pbf")):"function"==typeof define&&define.amd?define(["exports","fs","path","geobuf","@turf/boolean-point-in-polygon","@turf/helpers","pbf"],e):e((t||self).geoTz={},t.fs,t.path,t.geobuf,t.inside,t.helpers,t.pbf)}(this,function(t,e,i,r,o,n,f){function d(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function l(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if("default"!==i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,e}var a=/*#__PURE__*/l(e),c=/*#__PURE__*/l(i),u=/*#__PURE__*/d(o),h=/*#__PURE__*/d(f),p=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function g(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];for(var e=[],i=0;i<p.length;i++){var r=p[i];if(r.left<=t&&r.right>=t)e.push(r.tzid);else if(r.right<t)break}return e}var s,E=require("../data/index.json"),m=c.join(__dirname,"..","data","geo.dat");function z(t){if(s=t&&t.store&&"function"==typeof t.store.get&&"function"==typeof t.store.set?t.store:new Map,t&&t.preload){var e=a.openSync(m,"r");if(e<0)throw new Error("Failed to open geo.dat file");!function(t){!function e(i,r){if(i.pos>=0&&i.len){var o=T(0,i.pos,i.len,t);s.set(r,o)}else"object"==typeof i&&Object.getOwnPropertyNames(i).forEach(function(t){e(i[t],r+t)})}(E.lookup,"")}(e),a.closeSync(e)}}function T(t,e,i,o){void 0===o&&(o=-1);var n=o;if(n<0&&(n=a.openSync(m,"r"))<0)throw new Error("Failed to open geo.dat file");var f=Buffer.alloc(i),d=a.readSync(n,f,0,i,e);if(o<0&&a.closeSync(n),d<i)throw new Error("tried to read "+i+" bytes from geo.dat but only got "+d+" bytes");var l=new h.default(f);return r.decode(l)}z(),t.find=function(t,e){var i=e;if(isNaN(t)||t>90||t<-90)throw new Error("Invalid latitude: "+t);if(isNaN(e)||e>180||e<-180)throw new Error("Invalid longitude: "+e);if(90===t)return p.map(function(t){return t.tzid});t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),e>=179.9999?e=179.9999:e<=-179.9999&&(e=-179.9999);for(var r=n.point([e,t]),o={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0},f="",d=E.lookup;;){var l=void 0;if(t>=o.midLat&&e>=o.midLon?(l="a",o.bottom=o.midLat,o.left=o.midLon):t>=o.midLat&&e<o.midLon?(l="b",o.bottom=o.midLat,o.right=o.midLon):t<o.midLat&&e<o.midLon?(l="c",o.top=o.midLat,o.right=o.midLon):(l="d",o.top=o.midLat,o.left=o.midLon),f+=l,!(d=d[l]))return g(i);if(d.pos>=0&&d.len){var a=s.get(f);a||(a=T(0,d.pos,d.len),s.set(f,a));for(var c=[],h=0;h<a.features.length;h++)u.default(r,a.features[h])&&c.push(a.features[h].properties.tzid);return c.length>0?c:g(i)}if(d.length>0)return d.map(function(t){return E.timezones[t]});if("object"!=typeof d)throw new Error("Unexpected data type");o.midLat=(o.top+o.bottom)/2,o.midLon=(o.left+o.right)/2}},t.preCache=function(){z({preload:!0})},t.setCache=z});
//# sourceMappingURL=geo-tz.umd.js.map
{
"name": "geo-tz",
"version": "7.0.0",
"version": "7.0.1",
"description": "A node.js module to find the timezone at specific gps coordinates",

@@ -22,6 +22,2 @@ "keywords": [

"source": "src/find.ts",
"exports": {
"require": "./dist/geo-tz.js",
"default": "./dist/geo-tz.modern.js"
},
"main": "./dist/geo-tz.js",

@@ -28,0 +24,0 @@ "module": "./dist/geo-tz.module.js",

@@ -13,6 +13,6 @@ # node-geo-tz

```js
const geoTz = require('geo-tz')
const { find } = require('geo-tz')
geoTz(47.650499, -122.350070) // ['America/Los_Angeles']
geoTz(43.839319, 87.526148) // ['Asia/Shanghai', 'Asia/Urumqi']
find(47.650499, -122.350070) // ['America/Los_Angeles']
find(43.839319, 87.526148) // ['Asia/Shanghai', 'Asia/Urumqi']
```

@@ -22,5 +22,7 @@

As of Version 7, there is no longer a default import. The `find` function should be used instead.
As of Version 5, the API now returns a list of possible timezones. There are certain coordinates where the timekeeping method will depend on the person you ask. Also, another case where 2 or more timezones could be returned is when a request is made with a coordinate that happens to be exactly on the border between two or more timezones.
### geoTz(lat, lon)
### find(lat, lon)

@@ -33,3 +35,3 @@ Returns the timezone names found at `lat`, `lon`. The timezone names will be the timezone identifiers as defined in the [timezone database](https://www.iana.org/time-zones). The underlying geographic data is obtained from the [timezone-boudary-builder](https://github.com/evansiroky/timezone-boundary-builder) project.

### geoTz.setCache(options)
### setCache(options)

@@ -44,6 +46,6 @@ By default, geoTz lazy-loads exact lookup data into an unexpiring cache. The `setCache` method can be used to change the caching behavior using the following options:

```js
geoTz.setCache({ preload: true }) // preloads all files
setCache({ preload: true }) // preloads all files
let map = new Map();
geoTz.setCache({ store: map }) // pass a Map-like storage object
setCache({ store: map }) // pass a Map-like storage object
```

@@ -50,0 +52,0 @@

@@ -137,3 +137,3 @@ import * as fs from 'fs'

*/
export default function getTimezone(lat: number, lon: number): string[] {
export function find(lat: number, lon: number): string[] {
const originalLon = lon

@@ -140,0 +140,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc