New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@types/haversine

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/haversine

TypeScript definitions for haversine

  • 1.1.8
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • ts5.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-2.7%
Maintainers
1
Weekly downloads
 
Created
Source

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

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, and Dan Vanderkam.

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc