Socket
Socket
Sign inDemoInstall

@ericgio/distance-utils

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ericgio/distance-utils

A set of utilities for converting and formatting distances.


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

distance-utils

A set of utilities for converting and formatting distances.

npm version npm downloads build status Coveralls github MIT License

Installation

npm install --save @ericgio/distance-utils

or

yarn add @ericgio/distance-utils

Functions

formatDistance

Formats distance measurements, by stripping trailing zeroes and restricting floats to at most 2 decimal places.

formatDistance(1.3333) // => '1.33'
formatDistance(1.00)   // => '1'
round

Rounds a number to a specified level of precision. Similar to Lodash's round function.

round(4.006)    // => 4
round(4.006, 2) // => 4.01
round(4060, -2) // => 4100
milesToKm

Converts miles to kilometers.

milesToKm(6.21)     // => 10
milesToKm(6.21, 1)  // => 10.0
metersToMiles

Converts meters to miles.

metersToMiles(10000)    // => 6.21
metersToMiles(10000, 1) // => 6.2
metersToFeet

Converts meters to feet.

metersToFeet(1582)  // => 5190
metersToFeet(1, 2)  // => 3.28

License

MIT

FAQs

Last updated on 09 Oct 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc