@wuyichen/utils

1.0.2 • Public • Published

轻量级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)

Readme

Keywords

Package Sidebar

Install

npm i @wuyichen/utils

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

3.73 kB

Total Files

7

Last publish

Collaborators

  • yichenwu