shut-tools
v1.0.1
Published
可以格式化时间,修改和还原html的特殊字符
Downloads
3
Readme
安装
npm install its-tools
导入
const itsTools = require('shut-tools')
格式化时间
// 调用dateFormat 对时间进行格式化
const dtStr = itsTools.dateFormat(new Date())
//结果 2023-05-08 16:28:26
console.log(dtStr)
转译 HTML 中的特殊字符
// 待转译的html字符串
const htmlstr = '<h1 style="color: red;">这是h1&是红色的</h1>'
// 对html字符串进行转换
const str = itsTools.htmlEscape(htmlstr)
// 结果 <h1 style="color: red;">这是h1&是红色的</h1>
console.log(str)
还原 HTML 代码的特殊字符
// 待还原的HTML字符
const str2 = itsTools.htmlUnEscape(str)
// 结果 <h1 style="color: red;">这是h1&是红色的</h1>
console.log(str2)
开源协议
ISC
package.json 字段说明
{
"name": "its-tools", // 包名
"version": "1.0.0", // 版本号
"main": "index.js", // 入口
"description": "测试", // 描述信息
"keywords": [
"tools",
"its"
], // 关键字
"license": "ISC" // 遵守的开源许可协议
}