New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dzz-tools

提供了时间格式化,HTML Escape功能

  • 1.0.0
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

安装

npm install dzz-tools

导入

const tools = require("../dzz-tools");

格式化时间

// 调用格式化函数 dateFormat
const dateStr = tools.dateFormat();
// 输出结果 2022-03-04 09:41:18
console.log(dateStr);

转义 HTML 中的特殊字符

// 定义待转移的 HTML 字符串
let htmlString = `<span title="abc">这是span标签123&nbsp;</span>`;
// 调用 htmlEscape 方法进行转换
const str = tools.htmlEscape(htmlString);
// 结果 &lt;span title=&quot;abc&quot;&gt;这是span标签123&amp;nbsp;&lt;/span&gt;
console.log(str);

还原 HTML 中的特殊字符

// 调用 htmlUnEscape 方法进行还原
const str2 = tools.htmlUnEscape(htmlString);
// 结果 <span title="abc">这是span标签123&nbsp;</span>
console.log(str2);

FAQs

Package last updated on 04 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts