1.0.0 • Published 9 months ago

chow-utils v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

安装

    npm install chow-utils

导入

    const chow = require('chow-utils')

格式化时间

    // 调用dateFormat对事件进行格式化
    let dt = chow.dateFormat(new Date())
    console.log(dt);

转义HTML中的特殊字符

    // 待转换的html字符串
    let htmlStr = '<h1>aaa</h1>';
    // 调用htmlEscpape方法进行转换
    console.log(chow.htmlEscpape(htmlStr));
    // 输出结果:&lt;h1&gt;aaa&lt;/h1&gt;

还原HTML中的特殊字符

    // 待还原的html字符串
    let str = '&lt;h1&gt;aaa&lt;/h1&gt;';
    // 调用htmlUnEscape方法进行转换,并输出结果
    console.log(chow.htmlUnEscape(str))
    // <h1>aaa</h1>

开源协议

ISC

1.0.0

9 months ago