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

ray-event-tools

v1.0.2

Published

event tools

Readme

ray-event-tools

npm install --save ray-event-tools

usage

EventTrigger

import { EventTrigger } from 'ray-event-tools';
// or import EventTrigger from 'ray-event-tools/lib/eventTrigger';

const et = new EventTrigger();

et.addEventListener('loaded', fn1, 0);
et.addEventListener('unloaded', fn2, 0);

// 触发 loaded
et.dispatchEvent({ type: 'loaded' });
  • methods
/**
 * Event Trigger
 * @params params
 * @params params.name
 */
constructor(params: Object);
/**
 * 添加事件监听
 * @param type 事件类型
 * @param listener 事件回调
 * @param priority 事件优先权
 */
addEventListener(type: string, listener: EventListener, priority: number): Object;
/**
 * 判断是否已经有事件监听
 * @param type
 * @param listener
 */
hasEventListener(type: string, listener: EventListener): Boolean;
/**
 * 移除事件
 * @param type
 * @param listener
 */
removeEventListener(type: string, listener: EventListener): void;
/**
 * 移除所有事件
 */
removeAllListeners(): void;
  /**
  * 触发事件
  * @param event
  */
dispatchEvent(event: Event): true;

RayEmitter

  • 自定义创建
import { RayEmitter } from 'ray-event-tools';
// or import RayEmitter from 'ray-event-tools/lib/eventEmitter';

const emitterObj = {};
const emitterInstance = new RayEmitter(emitterObj);

// Listen on the given `event` with `fn`.
emitterInstance.on(event, fn);
emitterInstance.addEventListener(event, fn);

// Adds an `event` listener that will be invoked a single time then automatically removed.
emitterInstance.once(event, fn);

// Remove the given callback for `event` or all registered callbacks.
emitterInstance.off(event, fn);
emitterInstance.removeListener(event, fn);
emitterInstance.removeAllListeners(event, fn);
emitterInstance.removeEventListener(event, fn);

// Emit `event` with the given args.
emitterInstance.emit(event);
// Return array of callbacks for `event`.
emitterInstance.listeners(event);
// Check if this emitter has `event` handlers.
emitterInstance.hasListeners(event);
  • 使用内置默认 instance
import { emitterInstance } from 'ray-event-tools';

...

events

  • 使用默认 events
import events from 'ray-event-tools/lib/events';

events 包含以下属性:

  • EventManager
  • fn
  • DOM
  • platform
  • browser
  • Class
  • Lang
  • toCamelCase

author

ilex.h

changelog

  • 2019-1-8 v1.0.2

    add events and modify EventTrigger bugs

  • 2018-12-29 v1.0.0

    init

License

MIT