itzyj-utils

1.0.1 • Public • Published

安装


npm install itzyj-tools

导入

const itzyj = require('itzyj-utils')

格式化时间

// 调用 dateFormat 对时间进行格式化

const dtStr = itzyj.dateFormat(new Data())

console.log(dtStr)

// 结果 2022-7-30 17:37:58

转义 HTML 中的特殊字符

// 待转换的 HTML 字符串

const htmlStr = '<h1 title="标题">首页<span>123&npsp;</span></h1>'

// 调用 htmlEscape 方法进行转换

const str = itzyj.htmlEscape(htmlStr)

// 转换的结果 &lt;h1 title=&quot;标题&quot;&gt;首页&lt;span&gt;123&amp;npsp;&lt;/span&gt;&lt;/h1&gt;

还原 HTML 中的特殊字符

// 待还原的HTML 字符串
 
const str2 = itzyj.htmlUnEscape(str)

console.log(str2)

// 输出的结果 <h1 title="标题">首页<span>123&npsp;</span></h1>

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i itzyj-utils

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

2.45 kB

Total Files

5

Last publish

Collaborators

  • lyunzyj