1.0.0 • Published 3 years ago

xiaowu-tools v1.0.0

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

##安装

npm install xiaowu.tools

##导入

const xiaowu = require('./');

##格式化时间

//调用 timeFormat 函数格式化时间
const time = xiaowu.timeFormat(new Date());
// 结果: 2022-06-04-16 16:01:59
console.log(time);

##转义 HTML 字符串

/**
 * 调用 HTMLEscape 函数转义html字符串 
 * @type {string} 需传入html字符串
 */
const htmlStr = '<h1>爱你</h1>';
const str = xiao.HTMLEscape(htmlStr);
// 结果: &lt;h1&gt;爱你&lt;/h1&gt;
console.log(str);

##还原 HTML 字符串

/**
 * 调用 HTMLUnEscape 函数还原html字符串
 * @type {string} 需传入转义后的字符串
 */
const htmlStr = '<h1>爱你</h1>';
const str = xiao.HTMLEscape(htmlStr);
const unStr = xiaowu.HTMLUnEscape(xiaowu.HTMLEscape(str));
// 结果: <h1>爱你</h1>
console.log(unStr);

##开源协议 ISC