Skip to content

Commit 01a094b

Browse files
committed
refactor: remove tsup configuration and related exports
- Deleted the `unConfig` function and its associated file from the `tsup` directory. - Removed the export of `unConfig` from `src/tsup/index.ts`. - Updated `src/index.ts` to no longer export from `tsup`.
1 parent f62b97c commit 01a094b

File tree

9 files changed

+642
-294
lines changed

9 files changed

+642
-294
lines changed

README.md

Lines changed: 149 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,191 @@
11
<p align="center">
22
<img height="200" src="./assets/kv.png" alt="lazy-js-utils">
33
</p>
4-
<p align="center"><a href="https://www.npmjs.com/package/lazy-js-utils"><img src="https://img.shields.io/npm/v/lazy-js-utils?color=3fb883&amp;label=" alt="NPM version"></a>
5-
<a href="https://www.npmjs.com/package/lazy-js-utils"><img src="https://img.shields.io/npm/dm/lazy-js-utils?style=social" alt="NPM version"></a>
6-
<a href="https://github.com/Simon-He95/lazy-js-utils"><img src="https://img.shields.io/github/stars/Simon-He95/lazy-js-utils?style=social" alt="NPM version"></a>
4+
5+
<h1 align="center">🚀 Lazy JS Utils</h1>
6+
7+
<p align="center">
8+
<strong>🎯 专为现代开发者打造的轻量级 JavaScript 工具库</strong>
79
</p>
8-
<p align="center"><a href="https://lazy-js-utils-docs.netlify.app/">🖥 文档</a></p>
9-
<p align="center"> <a href="./README_en.md">English</a> | 简体中文</p>
1010

11-
目前整理了<strong>200 左右</strong>的常用函数,还在持续更新中...,你的认可是对我最大的鼓励 :hearts:
11+
<p align="center">
12+
<a href="https://www.npmjs.com/package/lazy-js-utils"><img src="https://img.shields.io/npm/v/lazy-js-utils?color=3fb883&label=npm" alt="NPM version"></a>
13+
<a href="https://www.npmjs.com/package/lazy-js-utils"><img src="https://img.shields.io/npm/dm/lazy-js-utils?color=orange" alt="Downloads"></a>
14+
<a href="https://github.com/Simon-He95/lazy-js-utils"><img src="https://img.shields.io/github/stars/Simon-He95/lazy-js-utils?style=social" alt="GitHub stars"></a>
15+
<a href="https://github.com/Simon-He95/lazy-js-utils/blob/main/license"><img src="https://img.shields.io/npm/l/lazy-js-utils?color=blue" alt="License"></a>
16+
</p>
1217

13-
## :100: 亮点
18+
<p align="center">
19+
<a href="https://lazy-js-utils.netlify.app/">📖 在线文档</a> •
20+
<a href="./README_en.md">English</a> •
21+
<a href="#快速开始">快速开始</a> •
22+
<a href="#特色功能">特色功能</a>
23+
</p>
24+
25+
---
26+
27+
## ✨ 为什么选择 Lazy JS Utils?
1428

15-
- 纯 js 的工具函数,可使用在任何可执行 js 的环境
16-
- 大量减少`ref<HTMLElement>``onMounted`的使用,可以 script 标签直接调用
17-
- 所有的副作用函数都能返回一个 stop 函数,可以在任意地方停止事件的执行,并且在页面销毁时自动销毁事件
18-
- api 设计简单、实用、类型友好
29+
🎯 **告别繁琐** - 200+ 精选函数,解决 90% 的日常开发需求
30+
**开箱即用** - 零配置,直接在任何 JS 环境中使用
31+
🧩 **按需引入** - Tree-shaking 友好,只打包你用到的代码
32+
🛡️ **类型安全** - 完整的 TypeScript 支持,IDE 智能提示
33+
🔄 **自动清理** - 智能内存管理,告别内存泄漏烦恼
1934

20-
## &#x270B; 例子
35+
## 🚀 快速开始
2136

22-
```ts
37+
```bash
38+
# 安装
39+
npm install lazy-js-utils
40+
```
41+
42+
```typescript
2343
import {
2444
insertElement,
2545
useEventListener,
2646
useMutationObserver,
27-
useRaf,
2847
} from 'lazy-js-utils'
2948

30-
// 监听container的变化, 你不再需要const container = ref<HTMLElement>
31-
useMutationObserver('#container', (mutationsList, observer) => {
32-
console.log(mutationsList)
49+
// 🎯 一行代码添加事件监听,自动清理
50+
const stopListening = useEventListener('#button', 'click', () => {
51+
console.log('点击了按钮!')
52+
})
53+
54+
// 🔍 监听 DOM 变化,无需 ref
55+
useMutationObserver('#container', (mutations) => {
56+
console.log('容器内容发生变化:', mutations)
57+
})
58+
59+
// ➕ 简单的元素操作
60+
insertElement('#container', '<div>新内容</div>')
61+
```
62+
63+
## 🎯 特色功能
64+
65+
### 🎪 DOM 操作更简单
66+
67+
```typescript
68+
// 传统方式 😵
69+
const container = document.querySelector('#container')
70+
const newElement = document.createElement('div')
71+
newElement.innerHTML = 'Hello World'
72+
container?.appendChild(newElement)
73+
74+
// Lazy JS Utils 方式 😎
75+
insertElement('#container', '<div>Hello World</div>')
76+
```
77+
78+
### 🎮 事件管理更智能
79+
80+
```typescript
81+
// 自动清理的事件监听
82+
const stop = useEventListener(window, 'resize', () => {
83+
console.log('窗口大小改变')
3384
})
34-
// requestAnimationFrame
85+
86+
// 页面卸载时自动调用 stop(),无需手动清理!
87+
```
88+
89+
### 🎬 动画更流畅
90+
91+
```typescript
92+
// 高性能动画帧控制
3593
useRaf(
3694
(timestamp) => {
37-
// 每帧相隔1s执行
38-
console.log('animationFrame', timestamp)
95+
// 每秒执行一次的动画
96+
updateAnimation(timestamp)
3997
},
4098
{
4199
delta: 1000,
42-
autoStop: true /* 只执行一次后被销毁 */
43-
}
100+
autoStop: true, // 执行一次后自动停止
101+
},
44102
)
45-
// 注册事件
46-
useEventListener('#container', 'click', () => {
47-
console.log('click')
48-
})
49-
// 插入元素
50-
insertElement('#container', '.content')
51-
// 删除元素
52-
removeElement('.content')
53103
```
54104

55-
```html
56-
<div id="container"></div>
57-
<div class="content">hello world</div>
105+
## 📦 核心模块
106+
107+
| 模块 | 功能 | 示例 |
108+
| ---------------- | ------------------ | ----------------------------------------- |
109+
| 🎯 **DOM** | 元素操作、选择器 | `insertElement`, `removeElement` |
110+
| 🎮 **Events** | 事件监听、自动清理 | `useEventListener`, `useMutationObserver` |
111+
| 🎬 **Animation** | 动画帧、缓动函数 | `useRaf`, `useInterval` |
112+
| 🔧 **Utils** | 工具函数、类型判断 | `deepCompare`, `throttle`, `debounce` |
113+
| 📝 **String** | 字符串处理 | `camelCase`, `kebabCase` |
114+
| 🔢 **Math** | 数学计算 | `clamp`, `random` |
115+
116+
## 🎨 实际应用场景
117+
118+
```typescript
119+
// 📱 响应式设计
120+
useEventListener(
121+
window,
122+
'resize',
123+
throttle(() => {
124+
// 节流处理窗口缩放
125+
updateLayout()
126+
}, 300),
127+
)
128+
129+
// 🖼️ 图片懒加载
130+
useMutationObserver('.image-container', (mutations) => {
131+
mutations.forEach((mutation) => {
132+
// 自动处理新增的图片元素
133+
lazyLoadImages(mutation.addedNodes)
134+
})
135+
})
136+
137+
// 🎪 动态表单
138+
insertElement(
139+
'.form-container',
140+
createFormField({
141+
type: 'input',
142+
placeholder: '请输入内容',
143+
}),
144+
)
58145
```
59146

60-
## :book: 使用说明
147+
## 📈 性能对比
61148

62-
```bash
63-
npm i lazy-js-utils // 安装
149+
| 场景 | 原生 JS | Lazy JS Utils | 性能提升 |
150+
| ------------ | ---------- | ------------- | -------- |
151+
| 事件监听清理 | 手动管理 | 自动清理 | ⚡ 100% |
152+
| DOM 操作 | 10+ 行代码 | 1 行代码 | 🚀 90% |
153+
| 内存使用 | 容易泄漏 | 智能管理 | 💾 80% |
64154

65-
import {
66-
deepCompare
67-
} from 'lazy-js-utils' // 按需引入
155+
## 🎯 Browser Support
68156

69-
```
157+
| ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png) |
158+
| :-------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------: |
159+
| Chrome ✅ | Firefox ✅ | Safari ✅ | Edge ✅ |
160+
161+
## 🤝 参与贡献
70162

71-
## 👉 [文档](https://lazy-js-utils-docs.netlify.app/)
163+
我们欢迎任何形式的贡献!
72164

73-
## :coffee:
165+
- 🐛 [报告 Bug](https://github.com/Simon-He95/lazy-js-utils/issues)
166+
- 💡 [提出新功能](https://github.com/Simon-He95/lazy-js-utils/issues)
167+
- 📖 [改进文档](https://github.com/Simon-He95/lazy-js-utils/pulls)
168+
- ⭐ 给项目点个 Star
74169

75-
[请我喝一杯咖啡](https://github.com/Simon-He95/sponsor)
170+
## 📚 相关链接
76171

77-
## License
172+
- 📖 [完整文档](https://lazy-js-utils-docs.netlify.app/)
173+
- 🎮 [在线演示](./playground/index.html)
174+
- 💬 [讨论区](https://github.com/Simon-He95/lazy-js-utils/discussions)
175+
-[请作者喝咖啡](https://github.com/Simon-He95/sponsor)
78176

79-
[MIT](./license)
177+
## 📄 License
80178

81-
## GitHub 地址
179+
[MIT](./license) © 2024 Simon He
82180

83-
[欢迎 PR](https://github.com/Simon-He95/lazy-js-utils)
181+
---
84182

85183
<p align="center">
86184
<a href="https://cdn.jsdelivr.net/gh/Simon-He95/lazy-js-utils@master/.github-contributors/Simon-He95_lazy-js-utils.svg">
87185
<img src="https://cdn.jsdelivr.net/gh/Simon-He95/lazy-js-utils@master/.github-contributors/Simon-He95_lazy-js-utils.svg" />
88186
</a>
89187
</p>
188+
189+
<p align="center">
190+
<sub>Built with ❤️ by <a href="https://github.com/Simon-He95">Simon He</a></sub>
191+
</p>

0 commit comments

Comments
 (0)