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

ioto-multi-tap

v1.0.2

Published

一个用于处理短时间内连续触发调用的 JavaScript 工具类

Readme

MultiTap

MultiTap 是一个用于在短间隔内连续触发调用时,根据调用次数执行不同处理函数的 JavaScript 类。
你可以为不同的连续调用次数指定专属的处理函数,例如:

  • 单击时执行 handler1
  • 400ms 内连续按两次时执行 handler2
  • 400ms 内连续按三次时执行 handler3(以及更多可选 handler)

如果连续调用次数超出了你提供的处理函数数量,则自动使用最后一个处理函数作为默认处理逻辑。

安装

NPM

npm install ioto-multi-tap

PNPM

pnpm add ioto-multi-tap

YARN

yarn add ioto-multi-tap

直接引入

src/ioto-multi-tap.js 文件加入到你的项目中即可。
例如,你可以直接在 HTML 中通过 <script> 标签引入:

<script src="path/to/ioto-multi-tap.js"></script>

使用方法

ESM 模块导入

import { MultiTap } from 'ioto-multi-tap';

// 创建实例并设置处理函数
const multiTap = new MultiTap([
  // 单击处理函数
  (data, count) => console.log(`单击:${count} 次,数据:`, data),
  // 双击处理函数
  (data, count) => console.log(`双击:${count} 次,数据:`, data),
  // 三击处理函数(可选)
  (data, count) => console.log(`三击:${count} 次,数据:`, data)
]);

// 在需要的地方调用 trigger 方法,可以传入任意数据
const data = { value: 'test' };
multiTap.trigger(data);

CommonJS 模块导入

const { MultiTap } = require('ioto-multi-tap');

// 创建实例并设置处理函数
const multiTap = new MultiTap([
  // 单击处理函数
  (data, count) => console.log(`单击:${count} 次,数据:`, data),
  // 双击处理函数
  (data, count) => console.log(`双击:${count} 次,数据:`, data),
  // 三击处理函数(可选)
  (data, count) => console.log(`三击:${count} 次,数据:`, data)
]);

与 DOM 事件结合

// 监听按钮点击事件
document.querySelector('#myButton').addEventListener('click', () => {
  multiTap.trigger();
});

运行测试

项目包含了基本的测试用例,你可以通过以下命令运行测试:

npm test

许可证

MIT