@xysfe/util

``` npm i @xysfe/util -S ``` ## 使用 ##### 全量引用 ```javascript import { getParameter } from '@xysfe/util' ``` ##### 局部引用 ```javascript import getParameter from '@xysfe/util/lib/getParameter' ``` ##### 使用babel插件 安装插件 ``` npm i babel-plugin-impo

Usage no npm install needed!

<script type="module">
  import xysfeUtil from 'https://cdn.skypack.dev/@xysfe/util';
</script>

README

@xysfe/util

文档

起步

安装

npm i @xysfe/util -S

使用

全量引用
import { getParameter } from '@xysfe/util'
局部引用
import getParameter from '@xysfe/util/lib/getParameter'
使用babel插件

安装插件

npm i babel-plugin-import-muc -D

添加babel配置

// babel 配置
// babel.config.js
module.exports = {
  "plugins": [
    [
      "import-muc",
      {
        "libraryName": "@xysfe/util",
        "style": false,
        "transformToDefaultImport": false
      }
    ]
  ]
}
import { getParameter } from '@xysfe/util'

该语法会被转义为

const getParameter = require('@xysfe/util/lib/getParameter') 

如何贡献

控制台命令添加模块
npm run add [模块名称]

测试用例

使用的是 Jest

发布相关

npm源更改

  1. 设置使用淘宝cnpm
npm config set registry https://registry.npm.taobao.org
  1. 查看是否配置成功,成功后即可直接使用cnpm命令
npm config get registry
  1. 还原npm仓库
npm config set registry https://registry.npmjs.org

文档维护

  • 文档用 apidoc 自动生成,打包会在doc目录生成文档资源。

  • 资源上传到dev环境static/xysUtil/

  • xysuitl-doc.html需要单独上传到application/Home/View/Docs/

    在调用函数前面用注释,参照以下格式*

    /**
     * @api {function} cloneDeep cloneDeep
     * @apiName cloneDeep
     * @apiVersion 0.1.0
     * @apiDescription 深拷贝
     * @apiGroup cloneDeep
     * @apiParam {any} target 拷贝的对象
     * @apiSuccess (返回值) {any} val 返回值
     * @apiExample {js} 使用:
     *     cloneDeep() // 结果
     *
     */
    export default function cloneDeep(target: any, map = new WeakMap()) {
        ...
    }

参数说明:

  • @api {类型} 路径(可随意填,但必须) 名称
  • @apiName: 名称(用于url上面显示)
  • @apiVersion:版本
  • @apiGroup 组别(用于主导航显示)
  • @apiParam 入参类型 入参名称 描述 (多个参数用多行apiParam)
  • @apiSuccess 返回值类型 返回值名称 返回值描述
  • @apiExample api的使用方式,例子

具体注释规则可查看:https://apidocjs.com/#param-api-param-example