# @types/haversine

> TypeScript definitions for haversine

Latest version **1.1.8** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/haversine
pnpm add @types/haversine
yarn add @types/haversine
bun add @types/haversine
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2023-11-07 |
| First published | 2017-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51437 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/haversine
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/haversine
- npm.io page: https://npm.io/package/@types/haversine

## Recent versions

- 1.1.8 (latest) — 2023-11-07
- 1.1.5 (ts3.6) — 2021-07-08
- 1.1.4 (ts2.8) — 2019-07-17
- 1.1.2 (ts2.0) — 2019-03-15
- 1.1.7 — 2023-10-18
- 1.1.6 — 2023-09-16
- 1.1.3 — 2019-07-16
- 1.1.1 — 2019-02-13
- 1.1.0 — 2017-11-17
- 1.0.1 — 2017-10-25
- 1.0.0 — 2017-08-16

## README

# Installation
> `npm install --save @types/haversine`

# Summary
This package contains type definitions for haversine (https://github.com/njj/haversine).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/haversine.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/haversine/index.d.ts)
````ts
declare namespace haversine {
    interface CoordinateLongitudeLatitude {
        longitude: number;
        latitude: number;
    }

    interface CoordinateLonLat {
        lon: number;
        lat: number;
    }

    interface CoordinateLatLng {
        lat: number;
        lng: number;
    }

    type LatLonTuple = [number, number];

    interface GeoJSON {
        geometry: {
            coordinates: number[]; // matches Point type in types/geojson.
        };
    }

    type Coordinate = CoordinateLongitudeLatitude | CoordinateLonLat | CoordinateLatLng | LatLonTuple | GeoJSON;

    interface Options {
        /** Unit of measurement applied to result. Default: "km". */
        unit?: "km" | "mile" | "meter" | "nmi" | undefined;
        /**
         * If passed, will result in library returning boolean value of whether or not the start and end points are within that supplied threshold.
         */
        threshold?: number | null | undefined;
        /** Format of coordinate arguments. */
        format?: "[lat,lon]" | "[lon,lat]" | "{lon,lat}" | "{lat,lng}" | "geojson" | undefined;
    }

    // The input & output types of haversine() both depend on the Options object.
    type ParamType<T extends Options | undefined> = T extends undefined ? CoordinateLongitudeLatitude
        : T extends { format: "[lat,lon]" | "[lon,lat]" } ? [number, number]
        : T extends { format: "{lat,lon}" } ? CoordinateLonLat
        : T extends { format: "{lat,lng}" } ? CoordinateLatLng
        : T extends { format: "geojson" } ? GeoJSON
        : Coordinate;

    type Return<T extends Options | undefined> = T extends { threshold: number } ? boolean : number;
}

/**
 * Determines the great-circle distance between two points on a sphere given their longitudes and latitudes
 */
declare function haversine<OptionsT extends haversine.Options | undefined = undefined>(
    start: haversine.ParamType<OptionsT>,
    end: haversine.ParamType<OptionsT>,
    options?: OptionsT,
): haversine.Return<OptionsT>;

export = haversine;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
 * Dependencies: none

# Credits
These definitions were written by [Christian Rackerseder](https://github.com/screendriver), and [Dan Vanderkam](https://github.com/danvk).

---
_Source: https://npm.io/package/@types/haversine · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
