get-location-with-timeout
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    1
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i get-location-with-timeout

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

131 kB

Total Files

22

Last publish

Collaborators

  • reiiyuki