itzerotwo-tools

1.0.0 • Public • Published

安装

npm install itzerotwo-tools

导入

const itzerotwo = require('itzerotwo-tools')

格式化时间

//调用dateFormat,对时间进行格式化
const dt = itzerotwo.dateFormat(new Date())
//结果为当前的时间 如 2022-08-13 23:52:20
console.log(dt)

转义HTML中的特殊字符

//带转换的HTML字符串
const htmlStr = '<h1 title = "abc">这是h1标签<span>123&nbsp;</span></h1>'
//调用htmlEscape方法进行转换
const str = itzerotwo.htmlEscape(htmlStr)
//转换的结果为 ------------------------
console.log(str)

还原HTML中的特殊字符

//待还原的HTML的字符串
const str2 = itzerotwo.htmlUnEscape(str)
//输出结果为---------------------------
console.log(str2)

开源协议

ISC

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i itzerotwo-tools

      Weekly Downloads

      1

      Version

      1.0.0

      License

      ISC

      Unpacked Size

      2.44 kB

      Total Files

      5

      Last publish

      Collaborators

      • youyima