<commit_before>/**
 * Windrose
 *
 * This is a simple module that converts compass degress into compass points
 * and points to degrees.
 *
 * You can pass an { depth: ... } hash to the methods.
 *
 * Passing a depth: 0 will limit the search to the 4
 * main compass points: N, E, S, W.
 *
 * Passing a depth: 1 will limit the search to the 8
 * main compass points: N, NE, E, SE, S, SW, W, NW
 *
 * Passing a depth: 2 will limit the search to the 16
 * main compass points: N, NNE, NE, ENE, E, ESE, SE, SSE,
 * S, SSW, SW, WSW, W, WNW, NW, NNW.
 *
 * Passing a depth: 3 (default) will do the search for the
 * 32 points of the compass.
 *
 * @author rogeriopvl <http://github.com/rogeriopvl>
 * @license MIT
 */

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        define([], factory);
    } else if (typeof exports === 'object') {
        module.exports = factory();
    } else {
        root.Windrose = factory();
    }
} (this, function () {
    var DEPTHS_AREA = [ 90, 45, 22.5, 11.25 ];
    var COMPASS_POINTS = [
        { symbol: 'N', name: 'North', depth: 0 },
        { symbol: 'NbE', name: 'North by East', depth: 3 },
        { symbol: 'NNE', name: 'North North East', depth: 2 },
        { symbol: 'NEbN', name: 'North East by North', depth: 3 },
        { symbol: 'NE', name: 'North East', depth: 1 },
        { symbol: 'NEbE', name: 'North East by East', depth: 3 },
        { symbol: 'ENE', name: 'East North East', depth: 2 },
        { symbol: 'EbN', name: 'East by North', depth: 3 },
        { symbol: 'E', name: 'East', depth: 0 },
        { symbol: 'EbS', name: 'East by South', depth: 3 },
        { symbol: 'ESE', name: 'East South East', depth: 2 },
        { symbol: 'SEbE', name: 'South East by East', depth: 3 },
        { symbol: 'SE', name: 'South East', depth: 1 },
        { symbol: 'SEbS', name: 'South East by South', depth: 3 },
        { symbol: 'SSE', name: 'South South East', depth: 2 },
        { symbol: 'SbE', name: 'South by East', depth: 3 },
        { symbol: 'S', name: 'South', depth: 0 },
        { symbol: 'SbW', name: 'South by West', depth: 3 },
        { symbol: 'SSW', name: 'South South West', depth: 2 },
        { symbol: 'SWbS', name: 'South West by South', depth: 3 },
        { symbol: 'SW', name: 'South West', depth: 1 },
        { symbol: 'SWbW', name: 'South West by West', depth: 3 },
        { symbol: 'WSW', name: 'West South West', depth: 2 },
        { symbol: 'WbS', name: 'West by South', depth: 3 },
        { symbol: 'W', name: 'West', depth: 0 },
        { symbol: 'WbN', name: 'West by North', depth: 3 },
        { symbol: 'WNW', name: 'West North West', depth: 2 },
        { symbol: 'NWbW', name: 'North West by West', depth: 3 },
        { symbol: 'NW', name: 'North West', depth: 1 },
        { symbol: 'NWbN', name: 'North West by North', depth: 3 },
        { symbol: 'NNW', name: 'North North West', depth: 2 },
        { symbol: 'NbW', name: 'North by West', depth: 3 }
    ];

    var Windrose = {
        /**
         * Returns a point of the compass, given the degrees
         * When the degrees do not match directly with a point,
         * the number is rounded first
         * @param {number} degrees - the degrees in the compass to convert
         * @param {object} opts - (optional) hash containing options
         *                 opts.depth - valid from 0 to 3
         * @return {object} the compass point of the given degrees. If degrees are
         *                  invalid (< 0 || > 360), then undefined is returned.
         */
        getPoint: function (degrees, opts) {
            if (degrees < 0 || degrees > 360) { return; }

            opts = opts || {};
            opts.depth = opts.hasOwnProperty('depth') ? opts.depth : 3;

            var idx = Math.round(degrees / DEPTHS_AREA[opts.depth]),
                _compass_points = COMPASS_POINTS.filter(function(pt)
                {
                    return pt.depth <= opts.depth;
                });

            // 360 === 0 aka North
            if (idx === _compass_points.length) {
                idx = 0;
            }<commit_msg>Adapt last PR to project's code style<commit_after>/**
 * Windrose
 *
 * This is a simple module that converts compass degress into compass points
 * and points to degrees.
 *
 * You can pass an { depth: ... } hash to the methods.
 *
 * Passing a depth: 0 will limit the search to the 4
 * main compass points: N, E, S, W.
 *
 * Passing a depth: 1 will limit the search to the 8
 * main compass points: N, NE, E, SE, S, SW, W, NW
 *
 * Passing a depth: 2 will limit the search to the 16
 * main compass points: N, NNE, NE, ENE, E, ESE, SE, SSE,
 * S, SSW, SW, WSW, W, WNW, NW, NNW.
 *
 * Passing a depth: 3 (default) will do the search for the
 * 32 points of the compass.
 *
 * @author rogeriopvl <http://github.com/rogeriopvl>
 * @license MIT
 */

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        define([], factory);
    } else if (typeof exports === 'object') {
        module.exports = factory();
    } else {
        root.Windrose = factory();
    }
} (this, function () {
    var DEPTHS_AREA = [ 90, 45, 22.5, 11.25 ];
    var COMPASS_POINTS = [
        { symbol: 'N', name: 'North', depth: 0 },
        { symbol: 'NbE', name: 'North by East', depth: 3 },
        { symbol: 'NNE', name: 'North North East', depth: 2 },
        { symbol: 'NEbN', name: 'North East by North', depth: 3 },
        { symbol: 'NE', name: 'North East', depth: 1 },
        { symbol: 'NEbE', name: 'North East by East', depth: 3 },
        { symbol: 'ENE', name: 'East North East', depth: 2 },
        { symbol: 'EbN', name: 'East by North', depth: 3 },
        { symbol: 'E', name: 'East', depth: 0 },
        { symbol: 'EbS', name: 'East by South', depth: 3 },
        { symbol: 'ESE', name: 'East South East', depth: 2 },
        { symbol: 'SEbE', name: 'South East by East', depth: 3 },
        { symbol: 'SE', name: 'South East', depth: 1 },
        { symbol: 'SEbS', name: 'South East by South', depth: 3 },
        { symbol: 'SSE', name: 'South South East', depth: 2 },
        { symbol: 'SbE', name: 'South by East', depth: 3 },
        { symbol: 'S', name: 'South', depth: 0 },
        { symbol: 'SbW', name: 'South by West', depth: 3 },
        { symbol: 'SSW', name: 'South South West', depth: 2 },
        { symbol: 'SWbS', name: 'South West by South', depth: 3 },
        { symbol: 'SW', name: 'South West', depth: 1 },
        { symbol: 'SWbW', name: 'South West by West', depth: 3 },
        { symbol: 'WSW', name: 'West South West', depth: 2 },
        { symbol: 'WbS', name: 'West by South', depth: 3 },
        { symbol: 'W', name: 'West', depth: 0 },
        { symbol: 'WbN', name: 'West by North', depth: 3 },
        { symbol: 'WNW', name: 'West North West', depth: 2 },
        { symbol: 'NWbW', name: 'North West by West', depth: 3 },
        { symbol: 'NW', name: 'North West', depth: 1 },
        { symbol: 'NWbN', name: 'North West by North', depth: 3 },
        { symbol: 'NNW', name: 'North North West', depth: 2 },
        { symbol: 'NbW', name: 'North by West', depth: 3 }
    ];

    var Windrose = {
        /**
         * Returns a point of the compass, given the degrees
         * When the degrees do not match directly with a point,
         * the number is rounded first
         * @param {number} degrees - the degrees in the compass to convert
         * @param {object} opts - (optional) hash containing options
         *                 opts.depth - valid from 0 to 3
         * @return {object} the compass point of the given degrees. If degrees are
         *                  invalid (< 0 || > 360), then undefined is returned.
         */
        getPoint: function (degrees, opts) {
            if (degrees < 0 || degrees > 360) { return; }

            opts = opts || {};
            opts.depth = opts.hasOwnProperty('depth') ? opts.depth : 3;

            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) {
                idx = 0;
            }
{'fraction_non_alphanumeric': 0.1545421643141513, 'fraction_numerical': 0.016648570394498734, 'mean_word_length': 2.1365872115020808, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3541931', 'n_tokens_mistral': 2778, 'n_tokens_neox': 2568, 'n_words': 1012}