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-eventemitter

v1.0.0

Published

An event emitter for the browser which broadcasts/listens to same-origin iframes

Downloads

4

Readme

Browser Events

This this node event emitter designed to be included in an application which makes use of separate document contexts but allows for a single "event bus" to communicate between these contexts. It uses a MutationObserver to add contexts to the local list, and when you call emit, it will use the postMessage API to propagate these events across the various contexts

ES6 & jsnext:main

This library is written in ES6 making use of it's feature set with reckless abandon. You'll find the source in the src/ directory, and a babelified version under dist/. The main key in the package.json points to dist/browser-events.js, the jsnext:main key points to the ES6 version. This allows this code to be used with something like rollup.

Class

This module is an ES6 class which extends the EventEmitter object. EGAD A CLASS. Relax. If you have a fundamental disagreement with using the class keyword in ES6, don't use it. It's pretty simple.

Personally, I'm tired of the anti-pattern of copy/pasting prototype/construction extension/assignment code when I want to do something like this in javascript, and I don't want to include all of util just to get util.inherits. Thankfully, if you're so fundamentally opposed you can use the transpiled version under dist/ which does the "appropriate" prototype juggling. If you're still upset about this, just relax. I'll be over here enjoying my new syntax and being lazy and not harming anyone, and you can be right where you, annoyed that someone is using it.

Usage

const BrowserEventEmitter = require('browser-eventemitter')
const emitter = new BrowserEventEmitter()
emitter.on('event', function (msg) {
  console.log(msg.some);
})
emitter.emit('event', {some: 'data'})
// data

`

Installation

npm install --save browser-events

Tests

Uses Zuul. Seems like PhantomJS doesn't work anymore on El Capitan.

License

Copyright © 2015 Scripto. Use under the Apache-2.0.