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

@mapbox/point-geometry

Package Overview
Dependencies
Maintainers
28
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/point-geometry - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

44

index.d.ts

@@ -5,21 +5,21 @@ /**

*
* @class
* @param {number} x the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.
* @param {number} y the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.
*
* @example
* const point = new Point(-77, 38);
*/
export default class Point {
declare function Point(x: number, y: number): void;
declare class Point {
/**
* Construct a point from an array if necessary, otherwise if the input
* is already a Point, or an unknown type, return it unchanged
* @param {[number, number] | Point} a any kind of input value
* @return {Point} constructed point, or passed-through value.
* @example
* // this
* var point = Point.convert([0, 1]);
* // is equivalent to
* var point = new Point(0, 1);
*/
static convert(a: [number, number] | Point): Point;
/**
* A standalone point geometry with useful accessor, comparison, and
* modification methods.
*
* @class
* @param {number} x the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.
* @param {number} y the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.
*
* @example
* const point = new Point(-77, 38);
*/

@@ -198,1 +198,19 @@ constructor(x: number, y: number);

}
declare namespace Point {
/**
* Construct a point from an array if necessary, otherwise if the input
* is already a Point, return it unchanged.
* @param {Point | [number, number] | {x: number, y: number}} p input value
* @return {Point} constructed point.
* @example
* // this
* var point = Point.convert([0, 1]);
* // is equivalent to
* var point = new Point(0, 1);
*/
function convert(p: Point | [number, number] | {
x: number;
y: number;
}): Point;
}
export default Point;

@@ -5,15 +5,15 @@ /**

*
* @class
* @param {number} x the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.
* @param {number} y the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.
*
* @example
* const point = new Point(-77, 38);
*/
export default class Point {
/**
* @param {number} x the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.
* @param {number} y the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.
*/
constructor(x, y) {
this.x = x;
this.y = y;
}
export default function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype = {
/**

@@ -24,3 +24,3 @@ * Clone this point, returning a new point that can be modified

*/
clone() { return new Point(this.x, this.y); }
clone() { return new Point(this.x, this.y); },

@@ -33,3 +33,3 @@ /**

*/
add(p) { return this.clone()._add(p); }
add(p) { return this.clone()._add(p); },

@@ -42,3 +42,3 @@ /**

*/
sub(p) { return this.clone()._sub(p); }
sub(p) { return this.clone()._sub(p); },

@@ -51,3 +51,3 @@ /**

*/
multByPoint(p) { return this.clone()._multByPoint(p); }
multByPoint(p) { return this.clone()._multByPoint(p); },

@@ -60,3 +60,3 @@ /**

*/
divByPoint(p) { return this.clone()._divByPoint(p); }
divByPoint(p) { return this.clone()._divByPoint(p); },

@@ -69,3 +69,3 @@ /**

*/
mult(k) { return this.clone()._mult(k); }
mult(k) { return this.clone()._mult(k); },

@@ -78,3 +78,3 @@ /**

*/
div(k) { return this.clone()._div(k); }
div(k) { return this.clone()._div(k); },

@@ -87,3 +87,3 @@ /**

*/
rotate(a) { return this.clone()._rotate(a); }
rotate(a) { return this.clone()._rotate(a); },

@@ -97,3 +97,3 @@ /**

*/
rotateAround(a, p) { return this.clone()._rotateAround(a, p); }
rotateAround(a, p) { return this.clone()._rotateAround(a, p); },

@@ -105,3 +105,3 @@ /**

*/
matMult(m) { return this.clone()._matMult(m); }
matMult(m) { return this.clone()._matMult(m); },

@@ -115,3 +115,3 @@ /**

*/
unit() { return this.clone()._unit(); }
unit() { return this.clone()._unit(); },

@@ -124,3 +124,3 @@ /**

*/
perp() { return this.clone()._perp(); }
perp() { return this.clone()._perp(); },

@@ -132,3 +132,3 @@ /**

*/
round() { return this.clone()._round(); }
round() { return this.clone()._round(); },

@@ -143,3 +143,3 @@ /**

return Math.sqrt(this.x * this.x + this.y * this.y);
}
},

@@ -155,3 +155,3 @@ /**

this.y === other.y;
}
},

@@ -165,3 +165,3 @@ /**

return Math.sqrt(this.distSqr(p));
}
},

@@ -179,3 +179,3 @@ /**

return dx * dx + dy * dy;
}
},

@@ -189,3 +189,3 @@ /**

return Math.atan2(this.y, this.x);
}
},

@@ -199,3 +199,3 @@ /**

return Math.atan2(this.y - b.y, this.x - b.x);
}
},

@@ -209,3 +209,3 @@ /**

return this.angleWithSep(b.x, b.y);
}
},

@@ -223,3 +223,3 @@ /**

this.x * x + this.y * y);
}
},

@@ -233,3 +233,3 @@ /** @param {[number, number, number, number]} m */

return this;
}
},

@@ -241,3 +241,3 @@ /** @param {Point} p */

return this;
}
},

@@ -249,3 +249,3 @@ /** @param {Point} p */

return this;
}
},

@@ -257,3 +257,3 @@ /** @param {number} k */

return this;
}
},

@@ -265,3 +265,3 @@ /** @param {number} k */

return this;
}
},

@@ -273,3 +273,3 @@ /** @param {Point} p */

return this;
}
},

@@ -281,3 +281,3 @@ /** @param {Point} p */

return this;
}
},

@@ -287,3 +287,3 @@ _unit() {

return this;
}
},

@@ -295,3 +295,3 @@ _perp() {

return this;
}
},

@@ -307,3 +307,3 @@ /** @param {number} angle */

return this;
}
},

@@ -322,3 +322,3 @@ /**

return this;
}
},

@@ -329,24 +329,29 @@ _round() {

return this;
}
},
/**
* Construct a point from an array if necessary, otherwise if the input
* is already a Point, or an unknown type, return it unchanged
* @param {[number, number] | Point} a any kind of input value
* @return {Point} constructed point, or passed-through value.
* @example
* // this
* var point = Point.convert([0, 1]);
* // is equivalent to
* var point = new Point(0, 1);
*/
static convert(a) {
if (a instanceof Point) {
return a;
}
if (Array.isArray(a)) {
return new Point(a[0], a[1]);
}
return a;
constructor: Point
};
/**
* Construct a point from an array if necessary, otherwise if the input
* is already a Point, return it unchanged.
* @param {Point | [number, number] | {x: number, y: number}} p input value
* @return {Point} constructed point.
* @example
* // this
* var point = Point.convert([0, 1]);
* // is equivalent to
* var point = new Point(0, 1);
*/
Point.convert = function (p) {
if (p instanceof Point) {
return /** @type {Point} */ (p);
}
}
if (Array.isArray(p)) {
return new Point(+p[0], +p[1]);
}
if (p.x !== undefined && p.y !== undefined) {
return new Point(+p.x, +p.y);
}
throw new Error('Expected [x, y] or {x, y} point format');
};
{
"name": "@mapbox/point-geometry",
"version": "1.0.0",
"version": "1.1.0",
"description": "a point geometry with transforms",

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

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