<commit_before>/**
 * @file singleton.js
 * @author <NAME>
 * @date 07.07.2017
 */

'use strict';

const ONE_SECOND_LENGTH = 1000;
const ONE_MINUTE_LENGTH = 60 * ONE_SECOND_LENGTH;
const ONE_HOUR_LENGTH = 60 * ONE_MINUTE_LENGTH;
const ONE_DAY_LENGTH = 24 * ONE_HOUR_LENGTH;

function getWeekDay(date) {
    const daysOfWeek = [
        'вс',
        'пн',
        'вт',
        'ср',
        'чт',
        'пт',
        'сб'
    ];

    return daysOfWeek[date.getDay()];
}

function getLocalDay(date) {
    return date.getUTCDay() + 1;
}

function getDateAgo(date, days) {
    return new Date(date - days * ONE_DAY_LENGTH).getDate();
}

function getLastDayOfMonth(year, month) {
    return new Date(new Date(year, month + 1, 1) - ONE_DAY_LENGTH).getDate();
}

function formatDate(date) {
    const options = {
        year: '2-digit',
        month: 'numeric',
        day: 'numeric'
    };

    return date.toLocaleString("ru", options);
}

function formatRelativeDate(date) {
    const options = {
        year: '2-digit',
        month: 'numeric',
        day: 'numeric',
        hour: 'numeric',
        minute: 'numeric'
    };

    const relativeDate = new Date() - date;

    let result;

    if (relativeDate < ONE_SECOND_LENGTH) {
        result = 'только что';
    } else if (relativeDate < ONE_MINUTE_LENGTH) {
        result = `${Math.floor(relativeDate / ONE_SECOND_LENGTH)} сек. назад`;
    } else if (relativeDate < ONE_HOUR_LENGTH) {
        result = `${Math.floor(relativeDate / ONE_MINUTE_LENGTH)} мин. назад`;
    } else {
        result = date
            .toLocaleString("ru", options)
            .replace(',', '');
    }

    return result;
}

function closureSum(b) {
    return function (a) {
        return +a + +b;
    }
}

function makeBuffer() {
    let buffer = [];

    let cleanedBuffer = function (value) {
        if (arguments.length === 0) {
            return buffer.join('');
        }

        buffer.push(`${value}`);
    };

    cleanedBuffer.clear = function () {
        buffer.length = 0;
    };

    return cleanedBuffer;<commit_msg>homework-03<commit_after>/**
 * @file singleton.js
 * @author <NAME>
 * @date 07.07.2017
 */

'use strict';

const ONE_SECOND_LENGTH = 1000;
const ONE_MINUTE_LENGTH = 60 * ONE_SECOND_LENGTH;
const ONE_HOUR_LENGTH = 60 * ONE_MINUTE_LENGTH;
const ONE_DAY_LENGTH = 24 * ONE_HOUR_LENGTH;

function getWeekDay(date) {
    const daysOfWeek = [
        'вс',
        'пн',
        'вт',
        'ср',
        'чт',
        'пт',
        'сб'
    ];

    return daysOfWeek[date.getDay()];
}

function getLocalDay(date) {
    return date.getUTCDay() + 1;
}

function getDateAgo(date, days) {
    return new Date(date - days * ONE_DAY_LENGTH).getDate();
}

function getLastDayOfMonth(year, month) {
    return new Date(new Date(year, month + 1, 1) - ONE_DAY_LENGTH).getDate();
}

function formatDate(date) {
    const options = {
        year: '2-digit',
        month: 'numeric',
        day: 'numeric'
    };

    return date.toLocaleString("ru", options);
}

function formatRelativeDate(date) {
    const options = {
        year: '2-digit',
        month: 'numeric',
        day: 'numeric',
        hour: 'numeric',
        minute: 'numeric'
    };

    const relativeDate = new Date() - date;

    if (relativeDate < ONE_SECOND_LENGTH) {
        return 'только что';
    }

    if (relativeDate < ONE_MINUTE_LENGTH) {
        return `${Math.floor(relativeDate / ONE_SECOND_LENGTH)} сек. назад`;
    }

    if (relativeDate < ONE_HOUR_LENGTH) {
        return `${Math.floor(relativeDate / ONE_MINUTE_LENGTH)} мин. назад`;
    }

    return date.toLocaleString("ru", options).replace(',', '');
}

function closureSum(b) {
    return function (a) {
        return +a + +b;
    }
}

function makeBuffer() {
    let buffer = [];

    let cleanedBuffer = function (value) {
        if (arguments.length === 0) {
            return buffer.join('');
        }

        buffer.push(`${value}`);
    };

    cleanedBuffer.clear = function () {
        buffer.length = 0;
    };

    return cleanedBuffer;
{'fraction_non_alphanumeric': 0.14039832800590116, 'fraction_numerical': 0.012785837226456848, 'mean_word_length': 2.412751677852349, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '1323075', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1362, 'n_words': 300}