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

prevent-repeat-click

v1.1.0

Published

`prevent-repeat-click` 是一个按钮防重复点击的一个小工具。 ## 安装 ```js npm install prevent-repeat-click --save ``` ## 使用 ### 引入 导出两个函数 - syncPreventRepeatClick 是同步任务的防重复 - asyncPreventRepeatClick 是异步任务的防重复 ```js import { syncPreventRepeatClick, asyncPreventRepeatClick } fr

Readme

prevent-repeat-click.js NPM Version

简介

prevent-repeat-click 是一个按钮防重复点击的一个小工具。

安装

npm install prevent-repeat-click --save

使用

引入

导出两个函数

  • syncPreventRepeatClick 是同步任务的防重复
  • asyncPreventRepeatClick 是异步任务的防重复
import { syncPreventRepeatClick, asyncPreventRepeatClick } from 'prevent-repeat-click'

js

<button id="button-sync">同步任务防重复测试</button>
<button id="button-async">异步任务防重复测试</button>

function syncSubmit() {
  console.log('同步提交成功')
}
function asyncSubmit() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log('异步提交成功')
      resolve()
    }, 3000)
  })
}
document.getElementById('button-sync').onclick = () => {
  syncPreventRepeatClick(syncSubmit)
}
document.getElementById('button-async').onclick = () => {
  asyncPreventRepeatClick(asyncSubmit)
}

VUE

// main.js
Vue.prototype.$syncPreventRepeatClick = syncPreventRepeatClick
Vue.prototype.$asyncPreventRepeatClick = asyncPreventRepeatClick
<el-button @click="$syncPreventRepeatClick(syncSubmit)">同步任务防重复测试</el-button>
<el-button @click="$asyncPreventRepeatClick(asyncSubmit)">异步任务防重复测试</el-button>

methods: {
  syncSubmit () {
    console.log('同步提交成功')
  },
  asyncSubmit () {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        console.log('异步提交成功')
        resolve()
      }, 3000)
    })
  },
}

REACT

参考上面 js

参数说明

syncPreventRepeatClick(method_name, [delay], [params])
asyncPreventRepeatClick(method_name, [delay], [params])

| 参数名 | 说明 | 是否必填 | 类型 | 默认值 | | ----------- | ------------------------------------------------- | -------- | ------ | ------ | | method_name | 需要执行的函数名,注意异步函数需要返回一个promise | 是 | String | - | | delay | 多少毫秒后可以下一次点击 | 否 | Number | 500 | | params | 给函数传递的参数 | 否 | any | - |

测试

http-server

访问: http://localhost:8081/test/index

可以看到双击提交按钮,只会触发一次‘提交成功’