{"_id":"@buzuosheng/hooks","_rev":"3-19147984dc006b8a4473f0fee5da6826","name":"@buzuosheng/hooks","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@buzuosheng/hooks","version":"1.0.0","keywords":["react","hooks","debounce","immer","Worker"],"author":{"name":"buzuosheng"},"license":"ISC","_id":"@buzuosheng/hooks@1.0.0","maintainers":[{"name":"buzuosheng","email":"1015350043@qq.com"}],"homepage":"https://github.com/buzuosheng/buzuosheng-hooks","bugs":{"url":"https://github.com/buzuosheng/buzuosheng-hooks/issues"},"dist":{"shasum":"c90c5a7768c0bc2c39a716c70cf2211989def164","tarball":"https://registry.npmjs.org/@buzuosheng/hooks/-/hooks-1.0.0.tgz","fileCount":32,"integrity":"sha512-b8opUOi1uJxVNScfq0atMZXxE300Ph2R9IUB31OCmkn0uL5WJ5m7CCI4uPQ7haxJlud1qYPYJrhsAyXYFSygow==","signatures":[{"sig":"MEYCIQCZSvOFzQ1X/rPHBzHn2EATr8tquCettEsrKXAy1CpLyQIhAKn9L7PaZ9+Zv8UZQCYUXUqT3UMWz3wf2IN0aTrdLcgr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":97005},"main":"dist/index.js","husky":{"hooks":{"pre-commit":"npm run lint"}},"module":"dist/index.mjs","engines":{"node":">=16"},"gitHead":"f04452b020dcd6b8436e4c0edb5ca9801c04f4b2","private":false,"scripts":{"lint":"eslint src --fix --ext .ts","size":"size-limit","test":"jest","build":"tsup src/index.ts","analyze":"size-limit --why"},"typings":"dist/index.d.ts","_npmUser":{"name":"buzuosheng","email":"1015350043@qq.com"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+ssh://git@github.com/buzuosheng/buzuosheng-hooks.git","type":"git"},"size-limit":[{"path":"dist/index.mjs","limit":"10 KB"}],"_npmVersion":"9.5.1","description":"自定义react hooks, 包含useDebounce, useWorker等","directories":{},"_nodeVersion":"18.16.1","dependencies":{"immer":"^10.0.3","shallowequal":"^1.1.0"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.6.11","devDependencies":{"jest":"^29.7.0","tsup":"^7.2.0","husky":"^8.0.3","react":"^18.2.0","eslint":"^8.53.0","ts-jest":"^29.1.1","react-dom":"^18.2.0","size-limit":"^10.0.2","@babel/core":"^7.23.2","@types/jest":"^29.5.6","@types/react":"^18.2.36","@types/react-dom":"^18.2.14","@babel/preset-env":"^7.23.2","@babel/preset-react":"^7.22.15","@size-limit/esbuild":"^10.0.2","eslint-plugin-react":"^7.33.2","react-test-renderer":"^18.2.0","@testing-library/react":"^14.0.0","jest-environment-jsdom":"^29.7.0","@size-limit/esbuild-why":"^10.0.2","@babel/preset-typescript":"^7.23.2","@typescript-eslint/parser":"^6.10.0","@size-limit/preset-small-lib":"^10.0.2","@typescript-eslint/eslint-plugin":"^6.10.0"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"_npmOperationalInternal":{"tmp":"tmp/hooks_1.0.0_1699366775152_0.06521896802616745","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@buzuosheng/hooks","version":"1.0.1","keywords":["react","hooks","debounce","immer","Worker"],"author":{"name":"buzuosheng"},"license":"ISC","_id":"@buzuosheng/hooks@1.0.1","maintainers":[{"name":"buzuosheng","email":"1015350043@qq.com"}],"homepage":"https://github.com/buzuosheng/buzuosheng-hooks","bugs":{"url":"https://github.com/buzuosheng/buzuosheng-hooks/issues"},"dist":{"shasum":"2551a7ab9e3c7209dbbefd9eebae4049124c7fc7","tarball":"https://registry.npmjs.org/@buzuosheng/hooks/-/hooks-1.0.1.tgz","fileCount":31,"integrity":"sha512-/PPuQenvEtlJ4Bzw5JTG122nCU/gIGSJDX7QQ3V8EGHaKmW44Qd8WpbsE/ilfwpugbkL15/ppAMdLcJqTuP0qw==","signatures":[{"sig":"MEYCIQCD58w5g0bkK062dffbqHrK24tqHj/bx34hnBHlsjGvCAIhAPt4xJKnbu9zUNIjPbE63nIBMf+sbOPi6PL8f+T4e1/r","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":137068},"main":"dist/index.js","husky":{"hooks":{"pre-commit":"npm run lint"}},"module":"dist/index.mjs","engines":{"node":">=16"},"gitHead":"ae3c35a30e24f2b718bb5d82d90ae51aef1d429f","private":false,"scripts":{"lint":"eslint src --fix --ext .ts","size":"size-limit","test":"jest","build":"tsup src/index.ts","analyze":"size-limit --why"},"typings":"dist/index.d.ts","_npmUser":{"name":"buzuosheng","email":"1015350043@qq.com"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+ssh://git@github.com/buzuosheng/buzuosheng-hooks.git","type":"git"},"size-limit":[{"path":"dist/index.mjs","limit":"10 KB"}],"_npmVersion":"10.4.0","description":"自定义react hooks, 包含useDebounce, useWorker等","directories":{},"_nodeVersion":"20.11.0","dependencies":{"immer":"^10.0.3","shallowequal":"^1.1.0"},"_hasShrinkwrap":false,"packageManager":"pnpm@8.6.11","devDependencies":{"jest":"^29.7.0","tsup":"^7.2.0","husky":"^8.0.3","react":"^18.2.0","eslint":"^8.53.0","ts-jest":"^29.1.1","react-dom":"^18.2.0","size-limit":"^10.0.2","@babel/core":"^7.23.2","@types/jest":"^29.5.6","@types/react":"^18.2.36","@types/react-dom":"^18.2.14","@babel/preset-env":"^7.23.2","@babel/preset-react":"^7.22.15","@size-limit/esbuild":"^10.0.2","eslint-plugin-react":"^7.33.2","react-test-renderer":"^18.2.0","@testing-library/react":"^14.0.0","jest-environment-jsdom":"^29.7.0","@size-limit/esbuild-why":"^10.0.2","@babel/preset-typescript":"^7.23.2","@typescript-eslint/parser":"^6.10.0","@size-limit/preset-small-lib":"^10.0.2","@typescript-eslint/eslint-plugin":"^6.10.0"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"_npmOperationalInternal":{"tmp":"tmp/hooks_1.0.1_1731384007675_0.9766279383513501","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@buzuosheng/hooks","version":"1.1.0","description":"自定义react hooks, 包含useDebounce, useWorker等","private":false,"main":"dist/index.js","module":"dist/index.mjs","typings":"dist/index.d.ts","scripts":{"test":"jest","build":"tsup src/index.ts","lint":"eslint src --fix --ext .ts","size":"size-limit","analyze":"size-limit --why"},"keywords":["react","hooks","debounce","immer","Worker"],"author":{"name":"buzuosheng"},"homepage":"https://github.com/buzuosheng/buzuosheng-hooks","repository":{"type":"git","url":"git+ssh://git@github.com/buzuosheng/buzuosheng-hooks.git"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"prettier":{"printWidth":80,"semi":true,"singleQuote":true,"trailingComma":"es5"},"size-limit":[{"path":"dist/index.mjs","limit":"10 KB"}],"license":"ISC","engines":{"node":">=16"},"packageManager":"pnpm@8.6.11","devDependencies":{"@babel/core":"^7.23.2","@babel/preset-env":"^7.23.2","@babel/preset-react":"^7.22.15","@babel/preset-typescript":"^7.23.2","@size-limit/esbuild":"^10.0.2","@size-limit/esbuild-why":"^10.0.2","@size-limit/preset-small-lib":"^10.0.2","@testing-library/react":"^14.0.0","@types/jest":"^29.5.6","@types/react":"^18.2.36","@types/react-dom":"^18.2.14","@typescript-eslint/eslint-plugin":"^6.10.0","@typescript-eslint/parser":"^6.10.0","eslint":"^8.53.0","eslint-plugin-react":"^7.33.2","husky":"^8.0.3","jest":"^29.7.0","jest-environment-jsdom":"^29.7.0","react":"^18.2.0","react-dom":"^18.2.0","react-test-renderer":"^18.2.0","size-limit":"^10.0.2","ts-jest":"^29.1.1","tsup":"^7.2.0"},"dependencies":{"immer":"^10.0.3","shallowequal":"^1.1.0"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"_id":"@buzuosheng/hooks@1.1.0","gitHead":"8bf07c94860283918f17bbc00b628075bef32c5d","bugs":{"url":"https://github.com/buzuosheng/buzuosheng-hooks/issues"},"_nodeVersion":"20.11.0","_npmVersion":"10.4.0","dist":{"integrity":"sha512-whPvlmwTqBiPE063iJOT3IcnPNAKgI+UzL+mNEXuZiZ/AmjO1PHm41Sz9B5kGCExPlwG0Qgr1erNxtAG9Kegrw==","shasum":"e347a5b242d9ce59461effe2b1648160a7489576","tarball":"https://registry.npmjs.org/@buzuosheng/hooks/-/hooks-1.1.0.tgz","fileCount":25,"unpackedSize":130056,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCHCpq+ETk5Qsuke4cyc/AGtd7N2qVzuQqM805MVmL5fwIhAKSXNwTQA+q0nZ0nGP9GZMlByazYKSHX0Lj1xw35EvNO"}]},"_npmUser":{"name":"buzuosheng","email":"1015350043@qq.com"},"directories":{},"maintainers":[{"name":"buzuosheng","email":"1015350043@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hooks_1.1.0_1745598333852_0.308170960191388"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-07T14:19:34.931Z","modified":"2025-04-25T16:25:34.249Z","1.0.0":"2023-11-07T14:19:35.437Z","1.0.1":"2024-11-12T04:00:07.853Z","1.1.0":"2025-04-25T16:25:34.051Z"},"bugs":{"url":"https://github.com/buzuosheng/buzuosheng-hooks/issues"},"author":{"name":"buzuosheng"},"license":"ISC","homepage":"https://github.com/buzuosheng/buzuosheng-hooks","keywords":["react","hooks","debounce","immer","Worker"],"repository":{"type":"git","url":"git+ssh://git@github.com/buzuosheng/buzuosheng-hooks.git"},"description":"自定义react hooks, 包含useDebounce, useWorker等","maintainers":[{"name":"buzuosheng","email":"1015350043@qq.com"}],"readme":"# @buzuosheng-hooks\n\n一个实用的 React Hooks 库，提供了常用的自定义 Hooks，帮助你更高效地处理防抖、状态管理、Web Worker 等功能。\n\n## ✨ 特性\n\n- 🔍 **类型安全**：使用 TypeScript 编写，提供完整的类型定义\n- 📦 **轻量级**：无外部依赖（除 immer 和 shallowequal），体积小巧\n- 🧪 **测试完善**：完整的单元测试覆盖\n- 📃 **文档详尽**：每个 Hook 都有详细的文档和使用示例\n- 🛠️ **优化性能**：减少重渲染，优化计算任务\n\n## 📦 安装\n\n```bash\n# 使用 npm\nnpm install @buzuosheng/hooks\n\n# 使用 yarn\nyarn add @buzuosheng/hooks\n\n# 使用 pnpm\npnpm add @buzuosheng/hooks\n```\n\n> 注意：如果使用 `useImmer` Hook，还需要安装 `immer` 作为依赖。\n\n## 🔨 使用示例\n\n```tsx\nimport { useDebounce, useImmer, useWorker } from '@buzuosheng/hooks';\n\n// 防抖处理输入\nfunction SearchComponent() {\n  const [text, setText] = useState('');\n  const debouncedText = useDebounce(text, 500);\n  \n  useEffect(() => {\n    // 只在 debouncedText 变化时执行\n    fetchSearchResults(debouncedText);\n  }, [debouncedText]);\n  \n  return (\n    <input \n      value={text}\n      onChange={e => setText(e.target.value)}\n      placeholder=\"搜索...\"\n    />\n  );\n}\n\n// 使用 Immer 简化状态更新\nfunction TodoApp() {\n  const [todos, updateTodos] = useImmer([]);\n  \n  const addTodo = title => {\n    updateTodos(draft => {\n      draft.push({ id: Date.now(), title, completed: false });\n    });\n  };\n  \n  const toggleTodo = id => {\n    updateTodos(draft => {\n      const todo = draft.find(t => t.id === id);\n      if (todo) todo.completed = !todo.completed;\n    });\n  };\n  \n  // ...组件其余部分\n}\n```\n\n## 📚 可用 Hooks\n\n- [`useDebounce`](./docs/useDebounce.md) &mdash; 用于处理防抖值的 Hook，避免频繁更新。\n- [`useDebouncedCallback`](./docs/useDebouncedCallback.md) &mdash; 用于处理防抖函数的 Hook，附带取消和立即执行功能。\n- [`useImmer`](./docs/useImmer.md) &mdash; 用于简化不可变状态更新的 Hook，基于 Immer。\n- [`useShallow`](./docs/useShallow.md) &mdash; 用于优化状态更新的 Hook，支持浅比较和函数式更新。\n- [`useWorker`](./docs/useWorker.md) &mdash; 用于在 Web Worker 中执行耗时计算的 Hook，避免阻塞主线程。\n\n## 📃 详细文档\n\n每个 Hook 都有详细的文档，包括类型定义、参数说明、使用示例、注意事项等。点击上面的链接查看完整文档。\n\n## 🔗 相关链接\n\n- [GitHub 仓库](https://github.com/buzuosheng/hooks)\n- [问题反馈](https://github.com/buzuosheng/hooks/issues)\n- [贡献指南](https://github.com/buzuosheng/hooks/blob/main/CONTRIBUTING.md)\n\n## 📄 许可证\n\nMIT © [buzuosheng](https://github.com/buzuosheng)\n","readmeFilename":"README.md"}