my-tools-hulisheng-123

1.0.0 • Public • Published

1.安装方式

1.1使用npm安装

npm i my-tools

2.导入方式

const my = require("my-tools")

3.格式化时间

function dateFormat(dtStr){
	const dt = new Date(dtStr)
	const y =dt.getFullYear()
	const m =dt.getMonth() +1
	const d =dt.getDate()
	const hh =dt.getHours()
	const mm =dt.getMinutes()
	const ss =dt.getSeconds()
	return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
}

module.exports={
	dateFormat
}

4.转化html特殊字符

function zhuanHtml(html){
    return html.replace(/<|>|"|&/g,(i)=>{
    	switch(i){
    		case "<":
    		  return &lt;
    		case ">":
    		  return &gt;
    		case '"':
    		  return &quot;
    		case '&':
    		  return &amp;
    	}
    })
}
function huanHtml(html){
	return str.replace(&lt;|&gt;|&quot;|&amp;/g,(i)=>{
    	switch(i){
    		case "&lt":
    		  return '<';
    		case "&gt":
    		  return '>';
    		case '&quot':
    		  return '"';
    		case '&amp':
    		  return '&';
    	}
    })
}

Readme

Keywords

none

Package Sidebar

Install

npm i my-tools-hulisheng-123

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

1.91 kB

Total Files

3

Last publish

Collaborators

  • hulisheng