当前位置:网站首页>开发属于自己的包
开发属于自己的包
2022-06-30 21:26:00 【画不完的饼】
开发属于自己的包
//时间转义
function dateFormat(dateStr){
const dt = new Date(dateStr)
const y = dt.getFullYear()
const m = padZero(dt.getMonth()+1)
const d = padZero(dt.getDay())
const hh = padZero(dt.getHours())
const mm = padZero(dt.getMinutes())
const ss = padZero(dt.getSeconds())
return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
}
//定义一个补零函数
function padZero(n){
return n>9?n:'0'+n
}
//定义转移html字符
function htmlEscape(htmlStr){
return htmlStr.replace(/<|>|"|"&/g,(match)=>{
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
//定义还原html的函数
function htmlUnEscape(htmlStr){
return htmlStr.replace(/<|>|"|&/g,(match)=>{
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '"'
case '&':
return '&'
}
})
}
module.exports={
dateFormat,
htmlEscape,
htmlUnEscape
}
边栏推荐
- Oracle 数据库表结构 Excel 导出
- 企业保护 API 安全迫在眉睫
- SQL Server 提取字符串中的纯数字
- 给苏丹国安德森苏丹的撒过 d s g
- Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test
- Go build server Foundation
- To the Sultanate of Anderson
- 介绍一款|用于多组学整合和网络可视化分析的在线平台
- 一文读懂什么是MySQL索引下推(ICP)
- Apply for vector bus protocol color picture wallpaper hanging picture, very good!
猜你喜欢

兴奋神经递质——谷氨酸与大脑健康

Apply for vector bus protocol color picture wallpaper hanging picture, very good!

Why have the intelligent investment advisory products collectively taken off the shelves of banks become "chicken ribs"?

Reading notes of Clickhouse principle analysis and Application Practice (3)

jenkins下载插件下载不了,解决办法

时空数据挖掘:综述
Testing media cache

Adobe-Photoshop(PS)-脚本开发-去除文件臃肿脚本

Arcmap|assign values to different categories of IDS with the field calculator

Reading notes of Clickhouse principle analysis and Application Practice (1)
随机推荐
Flinksql两个kafka 流可以进行join么?
文本生成模型退化怎么办?SimCTG 告诉你答案
企业保护 API 安全迫在眉睫
文本生成模型退化怎麼辦?SimCTG 告訴你答案
ssh 默认端口不是22时的一些问题
SQL server extracts pure numbers from strings
加密与解密以及OpenSSL的应用
Flutter 嵌套地狱?不存在的,ConstraintLayout 来解救!
Testing media cache
Personal developed penetration testing tool Satania
Ten security measures against unauthorized access attacks
jenkins下载插件下载不了,解决办法
给苏丹国安德森苏丹的撒过 d s g
Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement
Why have the intelligent investment advisory products collectively taken off the shelves of banks become "chicken ribs"?
针对美国国家安全局“酸狐狸”漏洞攻击武器平台的分析与应对方案建议
What does grade evaluation mean? What is included in the workflow?
jupyter notebook/lab 切换conda环境
Apply for vector bus protocol color picture wallpaper hanging picture, very good!
《ClickHouse原理解析与应用实践》读书笔记(2)