wave_tools

格式化时间,HTMLEscape

Usage no npm install needed!

<script type="module">
  import waveTools from 'https://cdn.skypack.dev/wave_tools';
</script>

README

安装

npm install wave-tools

导入

const wave = require('wave-tools')

格式化时间

//调用 dateFormat 对时间格式化
const dtStr = wave.dateFormat(new Date())
//结果 2022-01-10 12:03:47
console.log(dtStr)

转义 HTML 中特殊字符

//待转换的 HTML 字符串
const htmlStr = '<h1>h1标签</h1>'
//调用 htmlEscape 方法进行转换
const str = wave.htmlEscape(htmlStr)
//转换结果 &lt;h1&gt;h1标签&lt;/h1&gt;
console.log(str)

还原 HTML 中特殊字符

//待还原的 HTML 字符串
const str2 = wave.htmlUnEscape(str)
//还原结果 <h1>h1标签</h1>
console.log(str2)

开源协议

ISC