1.0.0 • Published 2 years ago

custom_node_kzm v1.0.0

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

安装方式

使用npm方式安装

npm i custo_node_kzm

导入方式

const c = require("custom_node")

格式化时间

function dateFormat(){ const data = new Date() const y = data.getFullYear() const m = data.getMonth()+1 const d = data.getDate() const hh = data.getHours() const mm = data.getMinutes() const ss = data.getSeconds() console.log(y+"-"+m+"-"+d+" "+hh+":"+mm+":"+ss) }

转移HTML中的特殊的特殊字符

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

还原HTML中的特殊的特殊字符

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

开源协议

ISC