hello-bear

1.0.0 • Public • Published

##安装

npm install hello-bear

导入

const bear = require('hello-bear')

格式化时间

// 调用dateFormate 对时间进行格式化
const dtStr = hello.dataFormate(new Date())
// 输出结果是 2023-05-29 12:12:26
console.log(dtStr);

转义html中的特殊字符

// 带转换的html 字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
// 调用htmlEscape方法进行转换
const str = hello.htmlEscape(htmlStr)
// 转换的结果为&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(str);

还原html 中的特殊字符

// 待还原的html字符串
const str2 = hello.htmlUnEscape(str)
// 输出结果是<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log(str2);

开源协议

ISC

Package Sidebar

Install

npm i hello-bear

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.9 kB

Total Files

5

Last publish

Collaborators

  • hellobear