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 🙏

© 2026 – Pkg Stats / Ryan Hefner

freeze-click

v1.4.2

Published

防止多次点击

Downloads

16

Readme

freeze-click


author: bugszhou | Email:[email protected] description: 防止多次点击

freeze-click(冻结点击):在用户点击一个按钮时,为了节流保证用户在接口返回后,再次点击才触发下一次请求

Usual

  • 默认冻结10s,10s内只请求一次,需要手动调用cancel取消冻结才能发送第二次请求。未调用cancel将在60s后自动释放。
  1. install
npm install --save freeze-click;
  1. Use
import freezeClick from 'freeze-click';

const handleClick = freezeClick((t) => {
    //t 为freeze-click实例
    setTimeout(() => {
        console.log('click');
    }, 5000);
});

// just call one time
handleClick();
handleClick();
handleClick();

setTimeout(() => {
    handleClick(); // call again
}, 6000);

freezeClick(func, [freezeTime=60*1000])

const freezeFn = freezeClick(func, 10000);

创建并返回一个冻结函数,在 freezeTime(默认60*1000ms,单位ms) 秒内最多执行 func 一次的函数。 在执行func(freezeFnObj)函数时,会把冻结函数的实例(freezeFnObj)作为第一个参数,freezeFnObj含有 cancel 方法用于取消延迟的函数。

  • 例如:
const handleClick = freezeClick((freezeFnObj) => {
    //t 为freeze-click实例
    setTimeout(() => {
        console.log('click');
        freezeFnObj.cancel()
    }, 5000);
});

handleClick();
setTimeout(() => {
    handleClick(); // call again
}, 5100);
  • 参数

func(Function): 需要冻结的函数,第一个参数为freezeFnObj含有 cancel 方法用于取消延迟的函数。 freezeTime(number): 需要冻结的时间,单位ms

  • 返回

(Function): 冻结后的函数

setWaitTime(wait = 10 * 1000)

修改冻结时间

import {setWaitTime} from 'freeze-click';

setWaitTime(500);