1.0.0 • Published 1 year ago

chaiun-klee v1.0.0

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

安装

npm install item-klee 

导入

const item-klee = require('item-klee');

格式化时间

// 调用 dataFormat 对时间进行格式化
const a = tooy.dataFormat(new Date());

console.log(a);
// 结果
// 2022-12-01      15:05:42

转义HTML特殊字符

// 调用 htmlEscape 对特殊进行转义
const b = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>';

const c = tooy.htmlEscape(b);

console.log(c);
// 结果
// &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

还原HTML中特殊字符

// 调用 htmlUnEscape 对特殊字符进行还原
const b = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>';

const c = tooy.htmlEscape(b);

const d = tooy.htmlUnEscape(c);

console.log(d);
// 结果
// <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>

开源协议

ISC

1.0.0

1 year ago