1.0.0 • Published 1 year ago

dc_my_first_package v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

##安装

npm install my_first_package

##导入

const my_first = require('my_first_package')

##格式化时间

//调用dateFormat对时间进行格式化
const date = my_first.dateFormat(new Date())
//结果 2023-03-26 21:33:13
console.log(date);

##转义HTML中的特殊字符

//待转换HTML字符串
const htmlStr = '<h1 title="">这是h1标签</h1>'
//调用HTMLEscape方法进行转换
const str = my_first.htmlEscape(htmlStr)
//转换后的结果
&lt;h1 title=&quot;&quot;&gt;这是h1标签&lt;/h1&gt;

##还原HTML中的特殊字符

//待还原HTML字符串str
&lt;h1 title=&quot;&quot;&gt;这是h1标签&lt;/h1&gt;
//调用HTMLUnescape方法进行转换
const str2 = my_first.htmlUnescape(str)
//还原后的结果
<h1 title="">这是h1标签</h1>

##开源协议 ISC