1.0.2 • Published 2 years ago

@wuyichen/utils v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

轻量级Javascript 工具类

安装

npm安装

npm install @wuyichen/utils

yarn安装

yarn add @wuyichen/utils

pnpm安装

pnpm add @wuyichen/utils

示例

typeOf

/**
 * 校验数据类型
 * @param {*} obj
 * @return {string}
 */
import { typeOf } from '@wuyichen/utils';

console.log(typeOf('hello worle'));

debounce

/**
 * 防抖函数
 * @param {function} fn   函数
 * @param {number} [wait] 等待时间
 * @return {(function(...[*]): void)|*}
 */
import { debounce } from '@wuyichen/utils';

window.onresize = debounce((e) => {
  console.log('onresize', e)
}, 1000);

throttle

/**
 * 截流函数
 * @param {function} fn 函数
 * @param {number} wait 等待时间
 * @return {(function(...[*]): void)|*}
 */
import { throttle } from '@wuyichen/utils';

window.onmousemove = throttle((e) => {
  console.log('onmousemove', e)
}, 1000)