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

frequency-wave

v1.1.7

Published

Frequency is a clean memory conservative pubsub system

Downloads

24

Readme

Frequency-wave

A plug and play PubSub system that just works as if it were an FM radio :)))

Why another publish and subscribe pattern you ask?

Simply because creating custom events that get fired syntactically in the browser is a very handy pattern. With thousands of implementations out in the wild and still it wasn't clear to see which one was memory conservative (this could be my own short-sidedness). Conserving memory is extremely important depending on how complex your application state is. Frequency wave focuses clearly on just that. Allowing you to remove name-spaced events so you do not pollute your own global scopes with unnecessary memory usage.

Solution

On of the solutions to this problem is to include a system that gives the developer the ability to flush out stations (transmitters).

Usage in the browser

Include the minified js file from npm by installing from npm repository and importing it in your build tool

npm i -S frequency-wave

####API (consider the following sequence and comments)

/*
* @param string station is the current namespace for your event
* @param string tuner the identifier for your event
* @wave object for the object you are passing
*/
frequency.tuneIn(station, tuner, wave);


/*
* @param string station the current namespace for your event
* @param string tuner the identifier for your event
*/
frequency.transmit(station, 'Alarm');


/*
* @param string station is the current namespace for your event
* @param string tuner the identifier for your event
*/
frequency.tuneOut(station, tuner);


frequency.tuneIn('FM', 'Alarm', firstAlarm); // creates listener for Alarm for the FM station, runs callback firstAlarm
frequency.tuneIn('FM', 'Alarm2', firstAlarm); // creates listener for Alarm2 for the FM station, runs callback firstAlarm
frequency.tuneIn('FM', 'Alarm', secondAlarm); // creates listener for Alarm for the AM station, runs callback secondAlarm

frequency.transmit('FM', 'Alarm'); // broadcasts a global wave containing the station and frequency
frequency.transmit('FM', 'Alarm2'); // will trigger firstAlarm

frequency.tuneOut('FM', 'Alarm'); // tune out the first alarm frequency on the FM station
frequency.transmit('FM', 'Alarm'); // will no longer work
frequency.transmit('FM', 'Alarm2'); // will still work (benefit: you are name-spacing your Pubsub events)

frequency.shutDown('FM'); // Station gets destroyed, no channel is listened to anymore and memory released to be allocated somewhere else

function firstAlarm() {
    console.log('I run firstAlarm');
}

function secondAlarm() {
    console.log('I run secondAlarm');
}

Usage for this product

Anyone can contribute. The project is build on webpack. You can get the project running with the following command

npm start