mydemo_xxy

1.0.0 • Public • Published

1.安装方式

npm install MyDemo_xxy

2.导入方式

const myDemo = require('MyDemo_xxy')

3.格式化时间方法

function formatDate(){
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth()+1;
    var day = date.getDate();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    return year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;
}

4.html转义方法

function htmlEscape(htmlStr){
    return htmlStr.replace(/<|>|&|"/g,function(match){
        switch(match){
            case '<':
                return '&lt;';
            case '>':
                return '&gt;';
            case '&':
                return '&amp;';
            case '"':
                return '&quot;';
        }
    })
}

5.html转义还原方法

function htmlUnEscape(str){
    return str.replace(/&lt;|&gt;|&amp;|&quot;/g,function(match){
        switch(match){
            case '&lt;':
                return '<';
            case '&gt;':
                return '>';
            case '&amp;':
                return '&';
            case '&quot;':
                return '"';
        }
    })
}

6开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i mydemo_xxy

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

3.01 kB

Total Files

5

Last publish

Collaborators

  • a82481689