Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "windrose", | ||
"main": "windrose.js", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"homepage": "https://github.com/rogeriopvl/windrose", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "windrose", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Convert compass degrees into points of the compass and vice versa", | ||
@@ -5,0 +5,0 @@ "main": "windrose.js", |
@@ -75,2 +75,10 @@ var expect = require('chai').expect; | ||
it('should return N when passing 359 degrees with 2 depth', function (done) { | ||
var res = Windrose.getPoint(359, { depth: 2 }); | ||
expect(res).to.be.an('object'); | ||
expect(res.symbol).to.equal('N'); | ||
done(); | ||
}); | ||
it('should return undefined when passing invalid depth', function (done) { | ||
@@ -77,0 +85,0 @@ var res = Windrose.getPoint(15, { depth: 0 }); |
@@ -89,10 +89,11 @@ /** | ||
var idx = Math.round(degrees / DEPTHS_AREA[opts.depth]); | ||
var _compass_points = COMPASS_POINTS.filter(function (pt) { | ||
return pt.depth <= opts.depth; | ||
}); | ||
// 360 === 0 aka North | ||
if (idx === COMPASS_POINTS.length) { | ||
if (idx === _compass_points.length) { | ||
idx = 0; | ||
} | ||
return COMPASS_POINTS.filter(function (pt) { | ||
return pt.depth <= opts.depth; | ||
})[idx]; | ||
return _compass_points[idx]; | ||
}, | ||
@@ -99,0 +100,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16023
276