New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

windrose

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

windrose - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0

2

bower.json
{
"name": "windrose",
"main": "windrose.js",
"version": "1.3.0",
"version": "2.0.0",
"homepage": "https://github.com/rogeriopvl/windrose",

@@ -6,0 +6,0 @@ "authors": [

{
"name": "windrose",
"version": "1.3.0",
"version": "2.0.0",
"description": "Convert compass degrees into points of the compass and vice versa",

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

@@ -23,8 +23,12 @@ # Windrose [![Build Status](https://secure.travis-ci.org/rogeriopvl/windrose.png?branch=master)](http://travis-ci.org/rogeriopvl/windrose)

Windrose.getPoint(225); /* returns { symbol: 'SW', name: 'South West' } */
Windrose.getPoint(236.25); /* returns { symbol: SWbW, name: 'South West by West' } */
Windrose.getPoint(225); /* returns { symbol: 'SW', name: 'South West', depth: 1 } */
Windrose.getPoint(236.25); /* returns { symbol: SWbW, name: 'South West by West', depth: 3 } */
Windrose.getDegrees('S'); /* returns 90 */
Windrose.getDegrees('South'); /* returns 90 */
Windrose.getPoint(236.25, { depth: 0 }); /* returns { symbol: 'W', name: 'West', depth: 0 } */
Windrose.getDegrees('S'); /* returns { min: 174.375, value: 180, max: 185.625 } */
Windrose.getDegrees('South'); /* returns { min: 174.375, value: 180, max: 185.625 } */
Windrose.getDegrees('S', { depth: 0 }); /* returns { min: 135, value: 180, max: 225 } */
### Browser

@@ -61,4 +65,6 @@

* `name` (string) the name or symbol of the compass point to convert to degrees
* `opts` (object) options hash [optional]
* `depth` (integer) the depth of search it can be a value between 0 and 3.
## License
Copyright (c) 2015 Rogério Vicente. Licensed under the MIT license.

@@ -87,8 +87,10 @@ var expect = require('chai').expect;

var res = Windrose.getDegrees('North');
expect(res).to.be.a('number');
expect(res).to.equal(0);
expect(res).to.be.an('object');
expect(res.value).to.equal(0);
var res2 = Windrose.getDegrees('N');
expect(res2).to.be.a('number');
expect(res2).to.equal(0);
expect(res2).to.be.an('object');
expect(res2.value).to.equal(0);
expect(res2.min).to.equal(354.375);
expect(res2.max).to.equal(5.625);

@@ -105,6 +107,8 @@ done();

xit('should return 270 when passing W point with 0 depth', function (done) {
it('should return 270 when passing W point with 0 depth', function (done) {
var res = Windrose.getDegrees('W', { depth: 0 });
expect(res).to.be.a('number');
expect(res).to.equal(270);
expect(res).to.be.an('object');
expect(res.value).to.equal(270);
expect(res.min).to.equal(225)
expect(res.max).to.equal(315)

@@ -114,6 +118,8 @@ done();

xit('should return 225 when passing SW point with 1 depth', function (done) {
it('should return 225 when passing SW point with 1 depth', function (done) {
var res = Windrose.getDegrees('SW', { depth: 1 });
expect(res).to.be.a('number');
expect(res).to.equal(225);
expect(res).to.be.an('object');
expect(res.value).to.equal(225);
expect(res.min).to.equal(202.5)
expect(res.max).to.equal(247.5)

@@ -123,6 +129,8 @@ done();

xit('should return 292.5 when passing WNW point with 2 depth', function (done) {
it('should return 292.5 when passing WNW point with 2 depth', function (done) {
var res = Windrose.getDegrees('WNW', { depth: 2 });
expect(res).to.be.a('number');
expect(res).to.equal(292.5);
expect(res).to.be.an('object');
expect(res.value).to.equal(292.5);
expect(res.min).to.equal(281.25)
expect(res.max).to.equal(303.75)

@@ -132,3 +140,3 @@ done();

xit('should return undefined when passing invalid depth', function (done) {
it('should return undefined when passing invalid depth', function (done) {
var res = Windrose.getDegrees('WNW', { depth: 9 });

@@ -135,0 +143,0 @@ expect(res).to.be.an('undefined');

@@ -7,3 +7,3 @@ /**

*
* You can pass an { depth: ... } hash to the getPoint.
* You can pass an { depth: ... } hash to the methods.
*

@@ -103,6 +103,14 @@ * Passing a depth: 0 will limit the search to the 4

* @param {string} name - the name or symbol of a compass point (case sensitive)
* @return {number} the degrees of the given compass point
* @param {object} opts - (optional) hash containing options
* opts.depth - valid from 0 to 3
* @return {object} the degrees and range of the given compass point
* (according to the given depth)
*/
getDegrees: function (name) {
var found;
getDegrees: function (name, opts) {
var found, min, max;
opts = opts || {};
opts.depth = opts.hasOwnProperty('depth') ? opts.depth : 3;
if (opts.depth < 0 || opts.depth > 3) { return; }
COMPASS_POINTS.forEach(function (item, idx) {

@@ -114,3 +122,13 @@ if (name === item.name || name === item.symbol) {

});
return found;
min = found - (DEPTHS_AREA[opts.depth] / 2);
max = found + (DEPTHS_AREA[opts.depth] / 2);
if (typeof found === 'undefined') { return; }
return {
min: min >= 0 ? min : (360 + min),
value: found,
max: max <= 360 ? max : (max - 360)
};
}

@@ -117,0 +135,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