itheimawen-tools

1.0.0 • Public • Published

安装

npm install itheimawen-tools

导入

const itheima = require('itheimawen-tools')

格式化时间

// 调用 dateFormat 对时间进行格式化
const dtStr = itheimawen.dateFormat(new Date())
// 结果 2022-04-05 12:04:01
console.log(dtStr)

转义 HTML 中的特殊字符

// 待转换的 HTML 字符串
const htmlStr = '<h1 "h2">这是h1 h2标签<span>加油你是最棒的程序员&<加油少年!></h1>'
// 调用 htmlEscape 转换的方法
const str = itheima.htmlEscape(htmlStr)
// 转换的结果 &lt;h1 &quot;h2&quot;&gt;这是h1 h2标签&lt;span&gt;加油你是最棒的程序员&amp;&lt;加油少年!&gt;&lt;/h1&gt;
console.log(str)

还原 HTML 中的特殊字符

// 待还原的 HTML 字符串
const str2 = itheima.htmlUnEscape(str)
// 输出的结果 <h1 "h2">这是h1 h2标签<span>加油你是最棒的程序员&<加油少年!></h1>
console.log(str2)

开源协议

ISC

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0

Package Sidebar

Install

npm i itheimawen-tools

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.86 kB

Total Files

5

Last publish

Collaborators

  • it955wen