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

isg-events

v0.1.0

Published

Synchronous and asynchronous cross-platform library for organizing events.

Downloads

10

Readme

isg-events

0.0.10

install

  • NPM npm install isg-events
  • GIT git clone https://github.com/isglazunov/events.git
  • download from releases

require

Node.js

var Events = require("isg-events");

Browser

<script src="isg-events.js"></script>

define

define(["isg-events"], function(Events){});

Ability to connect with define.amd added, but not tested. If something is wrong, fix it.

usage

It is recommended to use in conjunction with the underscore and async modules.

new Events;

var events = new Events;
var container = _.extend({}, new Events);

events.on(name, callback[, options]);

Available options:

{
    sync: false, // true // asynchronous / synchronous call handler.
    context: this, // this in the handler for the default `container`
    self: false, // true // adds the first argument of `self`
    limit: null // Number // how many times to call the handler
}

Asynchronous event

The following will be called only after a call next.

container.on("action", function(next, arg1, arg2){
    setTimeout(function(){
        console.log("0");
        next();
    }, 50);
});

Synchronous event.

The function next will be called automatically after the call handler.

container.on("action", function(arg1, arg2){
    setTimeout(function(){
        console.log("1");
    }, 100);
}, {sync: true});

Access to the handler.

The handler described below exclude yourself from the list of event handlers immediately after the call.

container.on("action", function(self, next, arg1, arg2){
    self.off();
    setTimeout(function(){
        console.log("2");
        next();
    }, 50);
});

Available attributes of self variable:

{
    index: Number // Personal index of each handler
    off: Function // Short-cut method to the handler could disable itself
    limit: Function // Returns a copy of the options limit
    // If the first argument is a number or null, the option replaces the limit for him
}

events.once(name, callback[, options])

Equivalent to calling: events.on(name, callback, {limit: 1});

events.trigger(name[[, Array arguments], callback];

container.trigger("action", function(){
    console.log("trigger");
}); 

If you call the trigger after the announcement of the above handlers, the console will look like this:

0
2
trigger
1

events.off(query)

Available query attributes:

{
    name: undefined, // String
    callback: undefined, // Function
    sync: undefined, // Boolean
    context: undefined, // any
    self: undefined, // Boolean
    limit: undefined // Number or Null
}

Each specified attribute narrows the scope of the search to detach from the list of handlers.

container.off({
    name: "action"
});

Disable all event handlers "action"

versions

0.0.10

Bigger readme. Some fixes.

0.0.9

The basic functionality.