npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@corgwn/hooks

v1.0.0

Published

hooks for corgwn

Downloads

1

Readme

npm (tag)

包含了 @corgwn/react 组件中完整的功能,可以用来打造你自己的组件

安装


npm i @corgwn/hooks@alpha

useAudioPlayer


import { useAudioPlayer } from '@corgwn/hooks'

const { play }  = useAudioPlayer('xxx.mp3')

返回

| 参数 | 说明 | 类型 | 备注 | | --- | --- | --- | --- | | currentTime | 当前时间 | number | 秒为单位 | | totalTime | 总时长 | number | 秒为单位 | | currentTimeText | 总时长的格式化文本 | string | mm:ss 格式 | | totalTimeText | 当前时间的格式化文本 | string | mm:ss 格式 | | updateTime | 更新当前时间 | (val: number) => void | 只会更新 hook 中的时间 | jump | 更新当前时间 | (val: number) => void | 更新播放器的时间,同时 hook 中的时间也会自动更新 | volume | 音量 | number \| null | 范围0-100,静音状态下为 null | | updateVolume | 更新音量 | (val: number) => void | 超出范围的值会被处理成边界值 | | mute | 静音 | () => void | - | | unmute | 取消静音 | () => void | 会将音量恢复为之前的大小 | | isPlay | 是否是播放状态 | boolean | - | | isCanPlay | 是否可以播放 | boolean | - | | play | 播放 | () => void | - | | pause | 暂停 | () => void | - | | imageSrc | ID3 解析的歌曲封面 | string | - | | title | ID3 解析的歌曲名 | string | - | | artist | ID3 解析的歌曲创作者 | string | - |

参数

| 参数 | 说明 | 类型 | 备注 | | --- | --- | --- | --- | | source | 音频链接或文件 | string | File | Blob | - | | loaded | 音频加载完成后的回调函数 | () => void | 可选 |

useTodo


import { useTodo } from '@corgwn/hooks'

const { add } = useTodo([{
    name: 'eat',,
    label: '吃饭',
    done: false
}])

返回

| 参数 | 说明 | 类型 | 备注 | | --- | --- | --- | --- | | todos | 待办数据 | (TodoListItem & LoadMap)[] | 同时会有一个 loadMap 属性包含了各种事件的加载状态 | | addLoading | 新增的加载状态 | boolean | - | | add | 新增待办 | (val: TodoListItem) => Promise<void> | - | | remove | 移除待办 | (name: string) => Promise<void> | - | | complete | 完成待办 | (name: string) => Promise<void> | - | | uncomplete | 取消已完成 | (name: string) => Promise<void> | - | | change | 更新待办 | (name: stirng, newVal: string) => Promise<void> | | event | 监听事件 | (event: 'update' \| 'updated', callback) => void | 可以在这里监听更新和更新完成事件,其中更新回调可以返回 false 来取消此次更新,更新完成回调会获取到最新的数据 |

参数

| 参数 | 说明 | 类型 | 备注 | | --- | --- | --- | --- | | todoList | 待办数据 | TodoListItem[] | - |