Skip to content

Wrapper for navigator.geolocation.getCurrentPosition with ensure rejected the promise when timeout

License

Notifications You must be signed in to change notification settings

ayuthmang/get-location-with-timeout

 
 

Repository files navigation

Get Location With Timeout

semantic-release JavaScript Style Guide ts code style: prettier License: MIT

Wrapper for navigator.geolocation.getCurrentPosition with ensure rejected the promise when timeout

Installation

yarn add get-location-with-timeout

Usage

import getCurrentLocationWithTimeout, { TimeoutError } from 'get-location-with-timeout'

try {
    const { coords } = await getCurrentLocationWithTimeout()

    // logic
} catch (error) {
    if (error instanceof TimeoutError) {
        // handle timeout logic
    } else {
        // handle other reject logic
    }
}

About

Wrapper for navigator.geolocation.getCurrentPosition with ensure rejected the promise when timeout

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 74.0%
  • JavaScript 26.0%