Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cheap-ruler

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheap-ruler - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

.flowconfig

4

cheap-ruler.js

@@ -11,3 +11,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.cheapRuler = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

// unit multipliers for conversion from kilometers
var factors = {
var factors = cheapRuler.units = {
kilometers: 1,
miles: 1000 / 1609.344,

@@ -30,2 +31,3 @@ nauticalmiles: 1000 / 1852,

if (lat === undefined) throw new Error('No latitude given.');
if (units && !factors[units]) throw new Error('Unknown unit ' + units + '. Use one of: ' + Object.keys(factors));

@@ -32,0 +34,0 @@ var f = lat * Math.PI / 180;

@@ -10,3 +10,4 @@ 'use strict'; /* @flow */

// unit multipliers for conversion from kilometers
var factors = {
var factors = cheapRuler.units = {
kilometers: 1,
miles: 1000 / 1609.344,

@@ -29,2 +30,3 @@ nauticalmiles: 1000 / 1852,

if (lat === undefined) throw new Error('No latitude given.');
if (units && !factors[units]) throw new Error('Unknown unit ' + units + '. Use one of: ' + Object.keys(factors));

@@ -31,0 +33,0 @@ var f = lat * Math.PI / 180;

{
"name": "cheap-ruler",
"version": "2.3.0",
"version": "2.4.0",
"description": "A collection of fast approximations to common geographic measurements.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -169,2 +169,23 @@ # cheap-ruler [![Build Status](https://travis-ci.org/mapbox/cheap-ruler.svg?branch=master)](https://travis-ci.org/mapbox/cheap-ruler) [![](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)

### Units conversion
Multipliers for converting between units are also exposed in `cheapRuler.units`:
```js
// convert 50 meters to yards
50 * cheapRuler.units.yards / cheapRuler.units.meters;
```
If you don't specify units when creating a ruler object,
you can use these constants to convert return values (using multiplication)
and input arguments (using division) to any units:
```js
// get distance between points in feet
var distanceInFeet = ruler.distance(a, b) * cheapRuler.units.feet;
// make a bbox from a point with a 200 inch buffer
var box = ruler.bufferPoint(p, 200 / cheapRuler.units.inches);
```
## Install

@@ -171,0 +192,0 @@

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