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 🙏

© 2024 – Pkg Stats / Ryan Hefner

browser-event-hook

v0.0.3

Published

Simplify browser event handling

Downloads

5

Readme

browser-event-hook

browser-event-hook is a lightweight JavaScript library that provides a simple way to handle events.

Installation

You can install using npm:

npm install browser-event-hook

Usage

import { useBrowserEvent } from "browser-event-hook";

const { listen, dispatch } = useBrowserEvent();

const options = {
  // native event options
  once: false,
  passive: false,
  capture: false,
  ..., // Also can use other supported browser's event options

  // custom event options
  lazyDelay: 0, // Delay in milliseconds, default is 0, if the same event occurs within the delay time, the delay time is reset
};

const { on, off } = listen(window, "customEvent", (e) => {
    console.log(e.detail);
  },
  options // optional
);

dispatch(window, "customEvent", { detail: "Hello World!" });
// => Hello World!

off();  // remove the listener

dispatch(window, "customEvent", { detail: "Hello World!" });

// Nothing happens

on(); // add the listener again

dispatch(window, "customEvent", { detail: "Hello World!" });

// => Hello World!

Contribution Guidelines

  1. Fork the Project: Start by forking the project to your GitHub account. This allows you to freely try out modifications without affecting the original project.
  2. Create a Branch: After you have forked the project, create a branch on your fork for your feature or bug fix. This keeps your contributions nicely isolated and makes it easier to integrate your changes later.
  3. Make Commits: Make your contributions on your branch. Try to keep your changes focused and commit frequently with clear, descriptive commit messages.
  4. Follow the Style Guide: Please follow any coding style guides and conventions used in the project. Consistent code makes it easier for everyone to understand and maintain.
  5. Write Tests: If possible, write tests for your modifications. This ensures that your changes work as expected and prevents future changes from accidentally breaking your feature.
  6. Stay Up-to-Date: Periodically pull changes from the original project to keep your fork up-to-date. This makes it easier to merge your changes later.
  7. Make a Pull Request: When you're ready, make a pull request from your branch on your fork to the original project. In the pull request description, explain your changes and how they improve the project.

Remember, the key to good open source contribution is not just about code, it's also about collaboration and respect. Always be courteous to other contributors, respect the maintainer's decisions, and remember that everyone is volunteering their time to make the project better. Happy contributing!