ly-node-utils

1.0.1 • Public • Published

1.安装

npm install ly-node-utils

2.导入

const utils=require("ly-node-utils")

3.API

3.1 日期格式化

const dd =  utils.dataFormater(new Date())     
//打印 yyyy-MM-dd HH:mm:ss
console.log(dd)

3.2 html字符转换为转义字符

let str =  '<h1 style="color:red;">你好!&copy<span>小黄</span></h1>'
let str2 = utils.htmlEscape(str)  
//打印:&lt;h1 style=&quot;color:red;&quot;&gt;你好!&amp;copy&lt;span&gt;小黄&lt;/span&gt;&lt;/h1&gt;
console.log(str2)

3.3 转义字符转换为html字符

let str = '&lt;h1 style=&quot;color:red;&quot;&gt;你好!&amp;copy&lt;span&gt;小黄&lt;/span&gt;&lt;/h1&gt;'
let str2 = utils.htmlUnEscape(str)
//打印:<h1 style="color:red;">你好!&copy<span>小黄</span></h1>
console.log(str2)

4.开源协议

ISC

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i ly-node-utils

      Weekly Downloads

      2

      Version

      1.0.1

      License

      ISC

      Unpacked Size

      4.24 kB

      Total Files

      10

      Last publish

      Collaborators

      • lxx2003