+5
-0
@@ -0,1 +1,6 @@ | ||
| ## 0.4.0 | ||
| * Added shortcut initializer with `[w, s, e, n]` coords. | ||
| * Added `.intersect()` method | ||
| ## 0.3.0 | ||
@@ -2,0 +7,0 @@ |
+18
-4
| module.exports = Extent; | ||
| function Extent() { | ||
| function Extent(bbox) { | ||
| if (!(this instanceof Extent)) { | ||
| return new Extent(); | ||
| return new Extent(bbox); | ||
| } | ||
| this._bbox = [Infinity, Infinity, -Infinity, -Infinity]; | ||
| this._valid = false; | ||
| this._bbox = bbox || [Infinity, Infinity, -Infinity, -Infinity]; | ||
| this._valid = !!bbox; | ||
| } | ||
@@ -62,2 +62,16 @@ | ||
| Extent.prototype.intersect = function(_) { | ||
| if (!this._valid) return null; | ||
| var other; | ||
| if (_ instanceof Extent) { other = _.bbox(); } else { other = _; } | ||
| return !( | ||
| this._bbox[0] > other[2] || | ||
| this._bbox[2] < other[0] || | ||
| this._bbox[3] < other[1] || | ||
| this._bbox[1] > other[3] | ||
| ); | ||
| }; | ||
| Extent.prototype._fastContains = function() { | ||
@@ -64,0 +78,0 @@ if (!this._valid) return new Function('return null;'); |
+1
-1
| { | ||
| "name": "extent", | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "description": "a geographic extent object", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+4
-0
@@ -13,2 +13,6 @@ [](https://travis-ci.org/mapbox/extent) | ||
| ### `extent([w, s, e, n])` | ||
| Create a new extent object, given bounds as an array. | ||
| ### `extent.include([lon, lat])` | ||
@@ -15,0 +19,0 @@ |
+10
-0
@@ -115,1 +115,11 @@ var test = require('tap').test, | ||
| }); | ||
| test('intersect', function(t) { | ||
| var bbox1 = [0,0,1,1]; | ||
| var bbox2 = [0.5,0.5,2,2]; | ||
| t.equals(Extent(bbox1).intersect(bbox2), true); | ||
| t.equals(Extent(bbox2).intersect(bbox1), true) | ||
| t.end() | ||
| }) |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
9872
7.84%258
7.5%54
8%