1.0.2 • Published 1 year ago

get-location-with-timeout v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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
    }
}
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago