1.0.0 • Published 1 year ago

7xia-utils v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装

npm install 7xia-utils or npm i 7xia-utils

导入

const 7xiaUtils = require('7xia-utils')

日期格式化

// 调用 dateFormat 传入一个日期 对时间格式进行处理
const date = 7xiaUtils.dateFormat(new Date())
console.log('北京时间:' + date)
// 2023-03-28 11:11:59

escape HTML字符转译

// 调用 htmlEscape 对HTML字符进行转译
const str = '<h1 title="a" >这是<span>h1</span>标签</h1>'
const scape = 7xiaUtils.htmlEscape(str)
console.log(8, scape)
// &lt;h1 title=&quot;a&quot; &gt;这是h1标签&lt;/h1&gt

还原HTML特殊字符转译

// 调用 htmlUnEscape 还原已转译的HTML特殊字符
const unScape = time.htmlUnEscape(scape)
console.log(11, unScape)
// <h1 title="a" >这是<span>h1</span>标签</h1>

开源协议

ISC