GithubHelp home page GithubHelp logo

henrikjoreteg / wildemitter Goto Github PK

View Code? Open in Web Editor NEW
213.0 13.0 21.0 426 KB

A super lightweight EventEmitter similar to what comes in Node.js, but with a support for wildcard events '*'

License: MIT License

JavaScript 100.00%

wildemitter's Issues

Remove version from Bower.json

Bower's official spec says that including a version field in the bower.json file is no longer supported. Instead, version information is supposed to come only from Git tags.

The version number in the file right now is wrong, which causes the following error when installing WildEmitter from Bower:

mismatch Version declared in the json (1.1.0) is different than the resolved one (1.2.0)

Instead of updating it to the proper version number, it should just be removed.

Wildcard matching issue

This code at wildemitter.js#L131 unintentionally matches all wildcard events that have been registered:

split = item.split('*');

if (item === '*' || (split.length === 2 && eventName.slice(0, split[1].length) === split[1])) {
    result = result.concat(this.callbacks[item]);
}

The reason: split[1] is the empty part of the string after the '*' so we're comparing a 0 length slice of eventName ("") to split1.

Simply changing to

split = item.split('*');

if (item === '*' || (split.length === 2 && eventName.slice(0, split[0].length) === split[0])) {
    result = result.concat(this.callbacks[item]);
}

will solve the problem because now we're comparing the eventName to the part of the wildcard before the asterisk.

Request to add License

Hi, could you please add an appropriate license to this library? I'm hoping for MIT. Unfortunately this has been flagged by our company's legal compliance tools due to unknown license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.