1.0.1 • Published 2 years ago

npm-tools-tests v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

npm install npm-tools-tests

引入

const npm_tools_tests = require('npm-tools-tests');

功能

格式化时间

//传入一个日期对象
let date = npm_tools_tests.dateFormat(new Date())
//结果 当前时间为:2022-08-01 18:37:38
console.log(date);

html转义

//传入一个带有html标签的字符
let str1 = npm_tools_tests.htmlEscape('<h2 class="aa">你好啊&nbsp;</h2>')
//结果 &lt;h2 class=&quot;aa&quot;&gt;你好啊&amp;nbsp;&lt;/h2&gt;
console.log(str1);

html转义后还原

//传入一个已转义后的html字符
let str2 = npm_tools_tests.returnHtml('&lt;h2 class=&quot;aa&quot;&gt;你好啊&amp;nbsp;&lt;/h2&gt;')
//结果 <h2 class="aa">你好啊&nbsp;</h2>
console.log(str2);

开源协议

ISC