custom_node_dyw

1.0.0 • Public • Published

1.安装方式

1.1使用npm方式安装

	npm i custom_node_dyw

2.导入方式

	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 "&gt;"
			case "<":
				return "&lt;"
			case '"':
				return "&quot;"
		}
	})
	console.log(s)
}

5.还原特殊字符

	function htmlunEscape(str){
	const s2 = str.replace(/&gt;|&lt;|&quot;/g,(i)=>{
		switch(i){
			case "&gt;":
				return ">"
			case "&lt;":
				return "<"
			case '&quot;':
				return '"'
		}
	})
	console.log(s2)
}
module.exports={
	htmlEscape,htmlunEscape
}

6.开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i custom_node_dyw

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

2.59 kB

Total Files

5

Last publish

Collaborators

  • yuyu2252611534