1.0.2 • Published 2 years ago

itcode-tools v1.0.2

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

npm install itcode-tools

导入

const code = require('itcode-tools')

格式化时间

const time = code.dateFormat(new Date())
console.log(time);//2022-04-27 14:37:14

转义 HTML 中的特殊字符

// 定义了待转换的 HTML 字符
const htmlStr = '<h1 title="abc">这是h1标签</h1>'
// 调用 htmlEscape 方法进行转换
const str = code.htmlEscape(htmlStr)
console.log(str);//&lt;h1 title=&quot;abc&quot;&qt;这是h1标签&lt;/h1&qt;

还原 HTML 中的特殊字符

// 定义了待还原的 HTML 字符
// 调用 htmlEscape 方法进行转换
const str1 = code.htmlunEscape(str)
console.log(str1);//<h1 title="abc">这是h1标签</h1>

开源协议

ISC

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago