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

Package detail

lesama-tools

lesama16ISC1.0.0

管理时间格式化、HTMLEscape功能

lesama, dateFormat, htmlEscape

readme

安装方式

npm install lesama-tools

导入方式

const lesama = require('lesama-tools')

使用方式

格式化时间方法

// 结果 2025-03-27 14:38:25+
console.log(lesama.formatDate(new Date()))

转义HTML方法

// 将html字符串转义为实体字符串
const htmlStr = '<div style="color: yellow;"><p>hello</p><span>&nbsp;</span></div>'
// 结果 &lt;div style=&quot;color: yellow;&quot;&gt;&lt;p&gt;hello&lt;/p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
console.log(lesama.htmlEscape(htmlStr))

解码HTML方法

// 将实体字符串转义为html字符串
const str = '&lt;div style=&quot;color: yellow;&quot;&gt;&lt;p&gt;hello&lt;/p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;'
// 结果 <div style="color: yellow;"><p>hello</p><span>&nbsp;</span></div>
console.log(lesama.htmlUnEscape(str))

开源协议

ISC