1.0.71 • Published 11 months ago

tool-plugins v1.0.71

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

tool-plugins

目前共有 12 个常用工具函数,并且持续探索更新中...! 开箱即用!

Document & Online preview

Tool Plugins

Install

npm install tool-plugins
# or
pnpm add tool-plugins
# or
yarn add tool-plugins
# or
bun add tool-plugins

Use Components

Global

Use CDN

<script src="https://unpkg.com/tool-plugins@latest"></script>

Project

  • Get the project code
git clone https://github.com/zhaoyifan-admin/tool-plugins.git
  • Install dependencies
cd tool-plugins

pnpm i
  • Run project
pnpm dev

Details

My CSDN Blogs

Functions

Function nameDescriptionsArguments
dateFormat简单易用的日期格式化函数!(timestamp: number | string | Date, format = 'YYYY-MM-DD HH:mm:ss') => string
requestAnimationFrame针对不同浏览器进行兼容处理!使用方式不变
cancelAnimationFrame针对不同浏览器进行兼容处理!使用方式不变
rafTimeout使用 requestAnimationFrame 实现的定时器函数,等效替代 (setTimeout 和 setInterval)!(func: Function, delay = 0, interval = false) => object
cancelRaf用于取消 rafTimeout 函数!(raf: { id: number }) => void
throttle节流函数!(fn: Function, delay = 300) => any
debounce防抖函数!(fn: Function, delay = 300) => any
add消除js加减精度问题的加法函数!(num1: number, num2: number) => number
downloadFile下载文件并自定义文件名!(url: string, name: string) => void
formatNumber数字格式化函数!(value: number | string, precision = 2, separator = ',', decimal = '.', prefix = '', suffix = '') => string
toggleDark一键切换暗黑模式函数!() => void
useEventListener自动添加和清除 DOM 事件监听器!(target: any, event: string, callback: Function) => void