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

@gby/event

v1.1.0

Published

@gby/event 称为 库构建模板,又称 公共代码构建模板 ,是专门用于构建 公共代码(如:封装的库、工具等) 的 vite 配置模板,当需要开发和构建公共代码时,直接克隆本项目即可,并默认在的 src 目录下开发即可;

Downloads

333

Readme

目录


背景

Web 提供了 EventTarget,Node.js 提供了 EventEmitter,但两者行为不一致,无法跨平台复用。此外,实际开发中常需要根据监听器数量来决定是否开启某些计算(如数据订阅、动画循环),而现有方案都不提供开箱即用的监听器计数事件。

@gby/event 提供了一套统一、轻量的事件 API,解决上述两个问题。

简介

@gby/event 是一个跨平台的事件库,核心导出两个类:

  • EventTrigger — 基础事件发射器
  • CountEventTrigger — 在 EventTrigger 基础上,额外提供监听器计数变化事件

特性:

  • 自动去重:同一函数引用对同一事件只注册一次,避免重复触发
  • AbortSignal 支持:监听器可随 AbortController 的中止自动解绑
  • 有限次数监听:addListenerWithTimes 到达指定次数后自动移除
  • 监听器计数事件:CountEventTrigger.countChangeEvents 可订阅任意事件的监听器增减
  • 异常隔离:ignoreErrortrue 时,单个监听器抛出异常不影响后续监听器执行
  • 完整 TypeScript 类型支持,事件参数类型安全

详情请看:

如果您在使用的过程中遇到了问题,或者有好的建议和想法,您都可以通过以下方式联系我,期待与您的交流:

安装

通过 npm 安装

npm install @gby/event

通过 <script> 标签引入

发行地址 下载以 .iife.js 为后缀的文件,然后在页面中引入:

<script src="path/to/event.iife.js"></script>
<script>
  const { EventTrigger, CountEventTrigger } = GbyEvent;
</script>

快速上手

import { EventTrigger } from '@gby/event';

type MyEvents = {
  greet: [name: string];
  ping:  [];
};

const et = new EventTrigger<MyEvents>();

// 添加监听器
const remove = et.addListener('greet', (name) => {
  console.log(`Hello, ${name}!`);
});

et.emit('greet', 'Alice'); // Hello, Alice!

// 移除监听器
remove();
et.emit('greet', 'Bob');   // 不再触发

教程

详情跳转至 教程

API 文档

详情跳转至 API接口文档


有您的支持,我会在开源的道路上,越走越远

赞赏码