# custom_node_why

> ``` npm install custom_node_why ``` ## 导入方式 ``` const tools=require("custom_node_why") ``` ## 格式化时间 ``` //处理时间模块 //1.定义一个格式化时间的方法 function dateFormat(){ const date=new Date() const y=date.getFullYear() //月份从0开始 const m=date.getMonth()+1

Latest version **1.0.0** (published 2023-07-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install custom_node_why
pnpm add custom_node_why
yarn add custom_node_why
bun add custom_node_why
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-07-19 |
| First published | 2023-07-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | why123huh |

## Links

- npm: https://www.npmjs.com/package/custom_node_why
- npm.io page: https://npm.io/package/custom_node_why

## Recent versions

- 1.0.0 (latest) — 2023-07-19

## README

## 安装方式
### 使用npm进行安装
```
npm install custom_node_why
```
## 导入方式
```
const tools=require("custom_node_why")
```
## 格式化时间
```
//处理时间模块
//1.定义一个格式化时间的方法
function dateFormat(){
	const date=new Date()
	const y=date.getFullYear()
	//月份从0开始
	const m=date.getMonth()+1
	const d=date.getDate()
	const hh=date.getHours()
	const mm=date.getMinutes()
	const ss= date.getSeconds()
	//2022-8-11 19:56:40
	console.log(y+"-"+m+"-"+d+" "+hh+":"+mm+":"+ss)
}
```
## 转义HTML中的特殊字符
```
//2.把特殊符号进行转义
//  < : &lt;
//  > : &gt;
//  " : &quot;
//  & : &amp;
function htmlEscape(h){
	let result = h.replace(/<|>|"|&/g,function(d){
	    switch(d){
	    	case "<":
	    	return "&lt;"
	    	case ">":
	    	return "&gt;"
	    	case '"':
	    	return "&quot;"
	    	case "&":
	    	return "&amp;"
	    }
    })
    return result
}
```
##还原HTML中的特殊字符
```
//2.把转义后的特殊符号再还原回去
//  < : &lt;
//  > : &gt;
//  " : &quot;
//  & : &amp;
function htmlunEscape(h){
	let result = h.replace(/&lt;|&gt;|&quot;|&amp;/g,function(d){
	    switch(d){
	    	case "&lt;":
	    	return "<"
	    	case "&gt;":
	    	return ">"
	    	case "&quot;":
	    	return '"'
	    	case "&amp;":
	    	return "&"
	    }
    })
    return result
}
```
##开源协议
```
ISC
```

---
_Source: https://npm.io/package/custom_node_why · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
