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

cheap-ruler

Package Overview
Dependencies
Maintainers
183
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.5.0 to 2.5.1

cheap-ruler.min.js

13

cheap-ruler.js

@@ -5,2 +5,3 @@ (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){

module.exports = cheapRuler;
module.exports.default = cheapRuler;

@@ -58,3 +59,3 @@ /**

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));
if (units && !factors[units]) throw new Error('Unknown unit ' + units + '. Use one of: ' + Object.keys(factors).join(', '));

@@ -105,3 +106,3 @@ var m = units ? factors[units] : 1;

if (!dx && !dy) return 0;
var bearing = Math.atan2(-dy, dx) * 180 / Math.PI + 90;
var bearing = Math.atan2(dx, dy) * 180 / Math.PI;
if (bearing > 180) bearing -= 360;

@@ -220,3 +221,5 @@ return bearing;

/**
* Returns an object of the form {point, index} where point is closest point on the line from the given point, and index is the start index of the segment with the closest point.
* Returns an object of the form {point, index, t}, where point is closest point on the line
* from the given point, index is the start index of the segment with the closest point,
* and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
*

@@ -226,3 +229,3 @@ * @pointOnLine

* @param {Array<number>} p point [longitude, latitude]
* @returns {Object} {point, index}
* @returns {Object} {point, index, t}
* @example

@@ -273,3 +276,3 @@ * var point = ruler.pointOnLine(line, [-67.04, 50.5]).point;

index: minI,
t: minT
t: Math.max(0, Math.min(1, minT))
};

@@ -276,0 +279,0 @@ },

@@ -22,2 +22,3 @@ declare function cheapRuler(lat: number, units?: string): cheapRuler.CheapRuler;

insideBBox(p: Point, bbox: BBox): boolean;
offset(p: Point, dx: number, dy: number): Point;
}

@@ -24,0 +25,0 @@ const units: {

'use strict'; /* @flow */
module.exports = cheapRuler;
module.exports.default = cheapRuler;

@@ -56,3 +57,3 @@ /**

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));
if (units && !factors[units]) throw new Error('Unknown unit ' + units + '. Use one of: ' + Object.keys(factors).join(', '));

@@ -103,3 +104,3 @@ var m = units ? factors[units] : 1;

if (!dx && !dy) return 0;
var bearing = Math.atan2(-dy, dx) * 180 / Math.PI + 90;
var bearing = Math.atan2(dx, dy) * 180 / Math.PI;
if (bearing > 180) bearing -= 360;

@@ -218,3 +219,5 @@ return bearing;

/**
* Returns an object of the form {point, index} where point is closest point on the line from the given point, and index is the start index of the segment with the closest point.
* Returns an object of the form {point, index, t}, where point is closest point on the line
* from the given point, index is the start index of the segment with the closest point,
* and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
*

@@ -224,3 +227,3 @@ * @pointOnLine

* @param {Array<number>} p point [longitude, latitude]
* @returns {Object} {point, index}
* @returns {Object} {point, index, t}
* @example

@@ -271,3 +274,3 @@ * var point = ruler.pointOnLine(line, [-67.04, 50.5]).point;

index: minI,
t: minT
t: Math.max(0, Math.min(1, minT))
};

@@ -274,0 +277,0 @@ },

{
"name": "cheap-ruler",
"version": "2.5.0",
"version": "2.5.1",
"description": "A collection of fast approximations to common geographic measurements.",
"main": "index.js",
"jsdelivr": "cheap-ruler.js",
"unpkg": "cheap-ruler.js",
"types": "index.d.ts",
"dependencies": {},
"devDependencies": {
"benchmark": "^2.1.3",
"browserify": "^14.1.0",
"eslint": "^3.17.0",
"eslint-config-mourner": "^2.0.1",
"istanbul": "^0.4.5",
"@turf/turf": "^5.0.4",
"benchmark": "^2.1.4",
"browserify": "^14.5.0",
"eslint": "^4.12.0",
"eslint-config-mourner": "^2.0.3",
"node-vincenty": "0.0.6",
"tape": "^4.6.3",
"@turf/turf": "^3.12.2",
"typescript": "^2.2.1"
"nyc": "^11.3.0",
"tape": "^4.8.0",
"typescript": "^2.6.2",
"uglify-js": "^3.2.0"
},

@@ -24,5 +27,11 @@ "scripts": {

"build": "browserify index.js -s cheapRuler > cheap-ruler.js",
"prepublish": "npm run build",
"cov": "istanbul cover tape test/test.js"
"build-min": "browserify index.js -s cheapRuler | uglifyjs -c -m > cheap-ruler.min.js",
"prepare": "npm run build && npm run build-min",
"cov": "nyc tape test/test.js"
},
"files": [
"index.d.ts",
"cheap-ruler.js",
"cheap-ruler.min.js"
],
"eslintConfig": {

@@ -29,0 +38,0 @@ "extends": "mourner"

@@ -88,2 +88,10 @@ # 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)

#### offset(p, dx, dy)
Returns a new point given easting and northing offsets from the starting point.
```js
var point = ruler.offset([30.5, 50.5], 10, 5); // 10km east and 5km north
```
#### lineDistance(line)

@@ -194,3 +202,3 @@

- NPM: `npm install cheap-ruler`
- Browser build (CDN): https://unpkg.com/cheap-ruler@2.4.1/cheap-ruler.js
- Browser build (CDN): https://unpkg.com/cheap-ruler@2.5.0/cheap-ruler.js

@@ -197,0 +205,0 @@ ## Precision

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