mydemo_kdl

1.0.0 • Public • Published

1.安装方式

npm install MyDemo_kdl

2.导入方式

const myDemo=require('MyDemo')

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,(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;|&quot;|&amp;/g,(match)=>{
        switch(match){
            case "&lt;":
                return "<";
            case "&gt;":
                return ">";
            case "&quot;":
                return '"';
            case "&amp;":
                return "&";
        }
    })

6.开源协议

ISC

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i mydemo_kdl

      Weekly Downloads

      0

      Version

      1.0.0

      License

      ISC

      Unpacked Size

      1.79 kB

      Total Files

      3

      Last publish

      Collaborators

      • kkkdl