1.0.0 • Published 4 years ago

fy-util v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

安装

npm install fy-util

导入

const fyUtil = require('fy-util')

方法

  • dateFormat 格式化时间
  • htmlEscape 转义 html 特殊字符
  • htmlUnescape 将转义后的字符串,反转成 html

dateFormat

const dt = new Date()
console.log(dateFormat(dt)) // 2021-12-12 02:24:03

htmlEscape

const htmlStr = '<div><span>"a" & "b"</span></div>'
console.log(htmlEscape(html)) // &lt;div&gt;&lt;span&gt;&quot;a&quot; &amp; &quot;b&quot;&lt;/span&gt;&lt;/div&gt;

htmlUnEscape

const str =
  '&lt;div&gt;&lt;span&gt;&quot;a&quot; &amp; &quot;b&quot;&lt;/span&gt;&lt;/div&gt;'
console.log(htmlUnEscape(str)) // <div><span>"a" & "b"</span></div>

开源协议

ISC