wenhao-utils-package

文君-自定义工具函数库

Usage no npm install needed!

<script type="module">
  import wenhaoUtilsPackage from 'https://cdn.skypack.dev/wenhao-utils-package';
</script>

README

文少前端工具包 wenhao-utils-package

文少提供的功能函数库,欢迎补充!

函数列表(完善中……)

函数名 作用 使用方式
debounce 防抖 newFunc=debounce(oldFunc)
throttle 节流 newFunc=throttle(oldFunc)
axios 请求方法 axios.get('https://apiurl.com')
removeProperty 对象中移除单个key newObj=removeProperty(oldObj,'name')
removeProperties 对象中移除多个key newObj=removeProperties(oldObj,['name1','name2'])
isEqual 深度对比对象是否相等 const isEqual = isEqual(obj1,obj2)

使用方式:

step1 下载工具包

# 名称是你前面指定的库的名称
npm install wenhao-utils-package

step2-1 在网页中引用工具包

<script src="./node_modules/wenhao-utils-package/dist/index.js"></script>
<script>
  whutils.testUtils();
</script>

step2-2 模块化项目中引用并使用

// 使用ESM引入
import { testUtils } from "wenhao-utils-package";
testUtils(); //控制台打印内容:wenhao-utils-package成功引入!

// 使用commonjs引入
const { testUtils } = require("wenhao-utils-package");
testUtils(); //控制台打印内容:wenhao-utils-package成功引入!