get-location-with-timeout
v1.0.2
Published
[![semantic-release](https://img.shields.io/badge/semantic-release-e10079.svg?logo=semantic-release)](https://github.com/semantic-release/semantic-release) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https
Downloads
6
Readme
Get Location With Timeout
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
}
}