<commit_before>var moment = require('moment');
var gravatar = require('gravatar');
var lodash = require('lodash');

'use strict';

moment.locale('zh-cn');

module.exports = {
    /**
     * 自动接取文章摘要
     * @param content
     */
    articleDesc: function(content){
        var re = /<[^>]+>/gi;
        str = content.replace(re, '');
        return str.substr(0, 100);
    },
    /**
     * 时间格式化显示
     */
    timeFromNow: function (date) {
        return moment(date).fromNow();
    },
    /**
     * +1
     * @param index
     * @returns {*}
     */
    addOne: function (index) {
        return index + 1;
    },
    add: function (value1, value2) {
        return Number(value1) + Number(value2);
    },
    reduce: function (value1, value2) {
        return Number(value1) - Number(value2);
    },
    /**
     * 格式化日期
     * @param date<commit_msg>seo 优化<commit_after>var moment = require('moment');
var gravatar = require('gravatar');
var lodash = require('lodash');

'use strict';

moment.locale('zh-cn');

module.exports = {
    /**
     * 自动接取文章摘要
     * @param content
     */
    articleDesc: function(content){
        if(!content)
            content = '';
        var re = /<[^>]+>/gi;
        str = content.replace(re, '');
        return str.substr(0, 100);
    },
    /**
     * 时间格式化显示
     */
    timeFromNow: function (date) {
        return moment(date).fromNow();
    },
    /**
     * +1
     * @param index
     * @returns {*}
     */
    addOne: function (index) {
        return index + 1;
    },
    add: function (value1, value2) {
        return Number(value1) + Number(value2);
    },
    reduce: function (value1, value2) {
        return Number(value1) - Number(value2);
    },
    /**
     * 格式化日期
     * @param date
{'fraction_non_alphanumeric': 0.16837899543378995, 'fraction_numerical': 0.01598173515981735, 'mean_word_length': 1.9914675767918089, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2527651', 'n_tokens_mistral': 618, 'n_tokens_neox': 610, 'n_words': 120}