1.0.0 • Published 1 year ago

itarya-tools v1.0.0

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

安装

npm install itarya-tools

导入

const tools = require('./itarya-tools/index');

格式化时间

//调用dateFormat对时间进行格式化
const dtStr = tools.dateFormat(new Date());
console.log(dtStr);

转义HTML中特殊字符

//待转换的HTML字符串
const htmlStr = '<h1 title="abcd">这是h1标签&nbsp</h1>';
//调用HTMLEscape方法进行转换
const html=tools.HTMLEscape(htmlStr);
console.log(html);

还原HTML中特殊字符

//待转换的字符串
const str='&lt;h1 title=&quot;abcd&quot;&gt;这是h1标签&lt;/h1&gt;';
//调用HTMLUnEscape方法进行转换
const hmlStr=tools.HTMLUnEscape(str);
console.log(hmlStr);

开源协议

ISC