Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

zztfirst-tools

zzt_2ISC1.0.0

提供了格式化时间,HTMLEspace的功能

zzt, dataFormat, format

readme

安装

npm install zztfirst

导入

const ztfirst = require('zztfirst');

格式化时间

//调用dateFormat对时间格式化
//输出格式化后的时间2023-04-20 17:05:46
console.log(zztfirst.dateFormat(new Date()));

转义HTML中的特殊字符

//待转义的html字符
const str = "<h1>这是一个h1标签<span>123&nbsp;</span></h1>"
//调用htmlEscape方法对html字符串进行转义
const newStr = zztfirst.htmlEscape(str)
//输出结果 &lt;h1&gt;这是一个h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(newStr)

还原HTML中的特殊字符

//调用htmlUnescape方法还原html中的特殊字符
const newStr1 = zztfirst.htmlUnescape(newStr)
//输出结果<h1>这是一个h1标签<span>123&nbsp;</span></h1>
console.log(newStr1)

开源协议

ISC