{"size": 1314, "ext": "js", "max_stars_repo_path": "static/javascripts/models/files.js", "max_stars_repo_name": "henvic/vehikel", "max_stars_repo_stars_event_min_datetime": "2015-02-07T21:48:38.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-01T12:49:24.000Z", "max_issues_repo_path": "static/javascripts/models/files.js", "max_issues_repo_name": "henvic/vehikel", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "static/javascripts/models/files.js", "max_forks_repo_name": "henvic/vehikel", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.375, "max_line_length": 101, "alphanum_fraction": 0.5365296804}
/*global define */
/*jslint browser: true */

define([], function () {
    'use strict';

    var exports = {};

    /**
     * Convert number of bytes into human readable format
     * from http://codeaid.net/javascript/convert-size-in-bytes-to-human-readable-format-(javascript)
     *
     * @param bytes Number of bytes to convert
     * @param precision Number of digits after the decimal separator
     * @return string
     */
    exports.convertBytesToSize = function (bytes, precision) {
        var kilobyte = 1024,
            megabyte = kilobyte * 1024,
            gigabyte = megabyte * 1024,
            terabyte = gigabyte * 1024;

        if ((bytes >= 0) && (bytes < kilobyte)) {
            return bytes + ' B';
        }

        if ((bytes >= kilobyte) && (bytes < megabyte)) {
            return (bytes / kilobyte).toFixed(precision) + ' KB';
        }

        if ((bytes >= megabyte) && (bytes < gigabyte)) {
            return (bytes / megabyte).toFixed(precision) + ' MB';
        }

        if ((bytes >= gigabyte) && (bytes < terabyte)) {
            return (bytes / gigabyte).toFixed(precision) + ' GB';
        }

        if (bytes >= terabyte) {
            return (bytes / terabyte).toFixed(precision) + ' TB';
        }

        return bytes + ' B';
    };

    return exports;
});
