# node-fun-bywhj

> 封装了一些nodeJS方法的常用使用function的集合

Latest version **1.0.13** (published 2018-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-fun-bywhj
pnpm add node-fun-bywhj
yarn add node-fun-bywhj
bun add node-fun-bywhj
```

Provides the command `deepdir`.

## 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.13 |
| Published | 2018-07-19 |
| First published | 2018-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 王泓钧 |
| Maintainers | wudilaobaba |
| Keywords | node |

## Links

- npm: https://www.npmjs.com/package/node-fun-bywhj
- npm.io page: https://npm.io/package/node-fun-bywhj

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.13 (latest) — 2018-07-19
- 1.0.12 — 2018-07-09
- 1.0.11 — 2018-07-05
- 1.0.10 — 2018-07-04
- 1.0.9 — 2018-07-02
- 1.0.8 — 2018-06-19
- 1.0.7 — 2018-06-19
- 1.0.6 — 2018-06-19
- 1.0.5 — 2018-06-18
- 1.0.4 — 2018-06-18
- 1.0.3 — 2018-06-13
- 1.0.2 — 2018-06-13

## README

##使用: `npm i -S node-fun-bywhj`
####001. clearCache() 清理node中的缓存
```javascript
let xx = require('node-fun-bywhj')
//执行下面的方法来清除node缓存
xx.clearCache()
```
###002. format() 将时间类型格式化
```javascript
let xx = require('node-fun-bywhj')
//执行下面的方法来清除node缓存
console.log(new Date(Date.now()).format('yyyy/MM/dd HH:mm:ss.S'))
```
###003. checkDirAndFile() 深度遍历目录树
```javascript
let xx = require('node-fun-bywhj')
//执行下面的方法来深度遍历目录树
//参数说明 ：回调函数的obj是返回的所有文件或文件夹绝对路径
//PS:想打印目录树结构，请在该包根目录中执行npm link,然后全局执行deepdir,就会得到当前项目中的目录树
xx.checkDirAndFile('某个文件夹的路径', (obj) => {
  console.log(obj);
})
```
###004. mkdirs(path,callback) 创建层级文件夹
```javascript
let xx = require('node-fun-bywhj')
xx.mkdirs(path, (err) => {
  //第一个参数可以这样写：path.join(__dirname, './names/name/name/name')
  if(err){
    console.log(err)
  }else{
    //...
  }
})
```
###005. base64ToFile(data,savePart,callBack) 将去掉头部的base64字符串还原为原始文件
###### 参数说明：data--后端接收的前端传来的JSON字符串,格式必须如下：{url:'base64格式去掉前缀',extName:'文件的扩展名'} 注：该JSON字符串中必须有url和extName这两个key；可以追加其他的key
###### 参数说明：savePart--想要将前台传来的文件保存到哪个文件夹中(必须是绝对路径)，项目中必须提前建好这个目录('./xxx/xxx')
###### 参数说明：callBack(err,data) 路径错误，会触发err,err就是一个字符串 ， data:上传成功以后的文件的全路径(物理路径)
```javascript
let xx = require('node-fun-bywhj')
//用在网络请求时
if(pathname=="/postData"&&req.method=="POST"){
  let data = ''
  req.on('data',(chunk)=>{
    data+=chunk
  })
  req.on('end',()=>{
    xx.base64ToFile(data,'./upload',(err,data)=>{
      if(err){//当node写文件的时候路径错误会触发这里的err
        res.end(err)
      }else{
        res.end(JSON.stringify({
		  data,
		  msg:'上传成功'
		}))
      }
    })
  })
}
```
### mdtohtml.js 
#####进入该包根目录中，找到mdtohtml.js文件拷贝至有xxx.md文件的目录下，在该目录下命令行运行：
#####01. npm i -S marked browser-sync
#####02. node mdtohtml xxx.md，然后稍微修改一下.md文件，即可实现边编辑.md文件边预览对应的.html文件

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