@@ -24,27 +24,27 @@ export function init(
2424 const geoData =
2525 typeof geoDataSource === "string"
2626 ? async ( start : number , end : number ) => {
27- const response = await fetch ( geoDataSource , {
28- headers : { Range : `bytes=${ start } -${ end } ` } ,
29- } ) ;
30- return await response . arrayBuffer ( ) ;
31- }
27+ const response = await fetch ( geoDataSource , {
28+ headers : { Range : `bytes=${ start } -${ end } ` } ,
29+ } ) ;
30+ return await response . arrayBuffer ( ) ;
31+ }
3232 : geoDataSource ;
3333
3434 let tzDataPromise : Promise < any > | null = null ;
3535
3636 const tzData =
3737 typeof tzDataSource === "string"
3838 ? async ( ) => {
39- if ( tzDataPromise ) {
40- return await tzDataPromise ;
41- }
42- const promise = fetch ( tzDataSource ) . then ( ( response ) =>
43- response . json ( ) ,
44- ) ;
45- tzDataPromise = promise ;
46- return await promise ;
39+ if ( tzDataPromise ) {
40+ return await tzDataPromise ;
4741 }
42+ const promise = fetch ( tzDataSource ) . then ( ( response ) =>
43+ response . json ( ) ,
44+ ) ;
45+ tzDataPromise = promise ;
46+ return await promise ;
47+ }
4848 : tzDataSource ;
4949
5050 return {
@@ -173,11 +173,14 @@ async function findImpl(
173173 if ( geoJson . type === "FeatureCollection" ) {
174174 for ( let i = 0 ; i < geoJson . features . length ; i ++ ) {
175175 if ( inside ( pt , geoJson . features [ i ] as any ) ) {
176- timezonesContainingPoint . push ( geoJson . features [ i ] . properties . tzid ) ;
176+ const properties = geoJson . features [ i ] . properties ;
177+ if ( properties ) {
178+ timezonesContainingPoint . push ( properties . tzid ) ;
179+ }
177180 }
178181 }
179182 } else if ( geoJson . type === "Feature" ) {
180- if ( inside ( pt , geoJson as any ) ) {
183+ if ( inside ( pt , geoJson as any ) && geoJson . properties ) {
181184 timezonesContainingPoint . push ( geoJson . properties . tzid ) ;
182185 }
183186 }
@@ -190,7 +193,7 @@ async function findImpl(
190193 } else if ( curTzData . length > 0 ) {
191194 // exact match found
192195 const timezones = tzDataResponse . timezones ;
193- return curTzData . map ( ( idx ) => timezones [ idx ] ) ;
196+ return curTzData . map ( ( idx : number ) => timezones [ idx ] ) ;
194197 } else if ( typeof curTzData !== "object" ) {
195198 // not another nested quad index, throw error
196199 err = new Error ( "Unexpected data type" ) ;
0 commit comments