Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simon-he95/lazy-js-utils
lazy-js-utils js工具函数库
https://github.com/simon-he95/lazy-js-utils
lazy-js-utils tools-function
Last synced: 10 days ago
JSON representation
lazy-js-utils js工具函数库
- Host: GitHub
- URL: https://github.com/simon-he95/lazy-js-utils
- Owner: Simon-He95
- License: mit
- Created: 2022-06-10T04:19:21.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-24T03:27:22.000Z (7 months ago)
- Last Synced: 2024-04-24T15:13:03.192Z (7 months ago)
- Topics: lazy-js-utils, tools-function
- Language: Vue
- Homepage: https://lazy-js-utils-docs.netlify.app/
- Size: 3.28 MB
- Stars: 67
- Watchers: 1
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: license
Awesome Lists containing this project
README
English | 简体中文
目前整理了200 左右的常用函数,还在持续更新中...,你的认可是对我最大的鼓励 :hearts:
## :100: 亮点
- 纯 js 的工具函数,可使用在任何可执行 js 的环境
- 大量减少`ref` 和 `onMounted`的使用,可以 script 标签直接调用
- 所有的副作用函数都能返回一个 stop 函数,可以在任意地方停止事件的执行,并且在页面销毁时自动销毁事件
- api 设计简单、实用、类型友好## ✋ 例子
```ts
import {
insertElement,
useEventListener,
useMutationObserver,
useRaf,
} from 'lazy-js-utils'// 监听container的变化, 你不在需要const container = ref
useMutationObserver('#container', (mutationsList, observer) => {
console.log(mutationsList)
})
// requestAnimationFrame
useRaf(
(timestamp) => {
// 每针相隔1s执行
console.log('animationFrame', timestamp)
},
1000,
true /* 只执行一次后被销毁 */,
)
// 注册事件
useEventListener('#container', 'click', () => {
console.log('click')
})
// 插入元素
insertElement('#container', '.content')
// 删除元素
removeElement('.content')
``````html
hello world
```## :book: 使用说明
```bash
npm i lazy-js-utils // 安装import {
deepCompare
} from 'lazy-js-utils' // 按需引入```
## 👉 [文档](https://lazy-js-utils-docs.netlify.app/)
## :coffee:
[请我喝一杯咖啡](https://github.com/Simon-He95/sponsor)
## License
[MIT](./license)
## GitHub 地址
[欢迎 PR](https://github.com/Simon-He95/lazy-js-utils)