![jBD](jBD-logo.png)

[![NPM version][npm-image]][npm-url]


## jBD是什么?

针对ES6的JS工具库，部分功能兼容ES5
  
  
## jBD有哪些功能？

* 工具库
	* `核心` —— 常用的is类型判断
	* `check` —— 文本内容校验
	* `conver` —— 数据转换
	* `date` —— 时间计算
	* `security` —— 安全性算法（MD5、CRC、SHA）
	* `regexp` —— 正则辅助工具
	* `string` —— 字符串工具
  
* Web端
	* `CMD模块加载`，参考了seajs代码，并进行了模块参数的优化
	* `cookie`、`history`、`storage`、`request`对象简化操作
	* `dom操作`，参考了jQuery代码，并进行了一定的优化和事件扩展（未完成）
	* 针对Mobile端的`手势识别`，进行了一定的扩展
   
* Node端
	* `fs` —— 针对json、log、file文本类文件进行读写操作封装
	* `db` —— mongodb、mysql、redis数据库操作封装（目前此功能合并至jsvr中，后期会在jBD项目中取消引用）
	* `log` —— log文件生成、记录、检索操作封装
	* `net` —— 网络操作封装
	* `zip` —— zip、tar压缩文件封装
	* `protocol` —— 数据包协议解析
  
  
## 安装与使用

- 安装

```bash
npm install jbd
```
  
- Node.js使用

jBD模块拥有自动过载性质，在首次执行后会在global对象中建立jBD对象映射，以方便在后续任意模块中使用，所以建议在启动文件的顶部进行申明引用

```node.js
const jBD = require("jbd");
console.log(jBD.version());
```
  
  
- Web使用

jBD模块基于CMD方式，进行懒加载。需要使用入口函数进行调用。
以下两种加载方式，效果略有不同
  
  
* 全模块加载

```html
<script type="text/javascript" src="/inc/jBD/jBD.js"></script>
<script type="text/javascript">
jBD.use(function(){
    //此时jBD所有模块会被全部载入，相对加载时间较长
});
</script>
```
  
  
* 按需加载

```javascript
// /usr/test.js
jBD.define(function (module, exports, require) {
// 此时模块只引入jBD.Check、jBD.Conver模块，jBD中其他模块无法使用
}, {module: this, exports: this}, ["Check", "Conver"], "test");
```

```html
// index.html
<script type="text/javascript">
jBD.use("test.js"); //模块默认加载/usr目录下对应文件
</script>
```

## 问题反馈

在使用中有任何问题，欢迎在[issues](https://github.com/buddydeus/jBD/issues)中进行反馈。


## 感激

感谢以下的项目,排名不分先后。

* [jQuery](http://jquery.com)

* [seajs](https://github.com/seajs/seajs)
  
  
## License

  MIT

[npm-image]: https://img.shields.io/npm/v/jbd.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/jbd
