1.0.0 • Published 3 years ago
custom_node_dyw v1.0.0
1.安装方式
1.1使用npm方式安装
	npm i custom_node_dyw2.导入方式
	const c = require("custom_node_dyw")3.格式化时间
	function dataFormat(){
	const date = new Date()
	//月份从0开始
	const y = date.getFullYear()
	const m = date.getMonth()+1
	const d = date.getDate()
	const hh = date.getHours()
	const mm = date.getMinutes()
	const ss = date.getSeconds()
	console.log(y+"年"+m+"月"+d+"日"+hh+"时"+mm+"分"+ss+"秒")
}
module.exports={
	dataFormat
}4.转义特殊字符
	function htmlEscape(str){
	const s = str.replace(/>|<|"/g,(i)=>{   //  '/'开头   '/'结尾   g全局
		switch(i){
			case ">":
				return ">"
			case "<":
				return "<"
			case '"':
				return """
		}
	})
	console.log(s)
}5.还原特殊字符
	function htmlunEscape(str){
	const s2 = str.replace(/>|<|"/g,(i)=>{
		switch(i){
			case ">":
				return ">"
			case "<":
				return "<"
			case '"':
				return '"'
		}
	})
	console.log(s2)
}
module.exports={
	htmlEscape,htmlunEscape
}6.开源协议
ISC
1.0.0
3 years ago