diff --git a/es5.js b/es5.js index a200e44..bd74e05 100644 --- a/es5.js +++ b/es5.js @@ -53,20 +53,20 @@ function EventPubSub() { } function emit(type){ + this.emit$.apply(this, arguments); + if(!this._events_[type]){ + return this; + } arguments.splice=Array.prototype.splice; arguments.splice(0,1); - if(!this._events_[type]){ - return this.emit$.apply(this, type, arguments); - } - const handlers=this._events_[type]; for(let handler of handlers){ handler.apply(this, arguments); } - return this.emit$.apply(this, type, arguments); + return this; } function emit$(type, args){ diff --git a/event-pubsub-browser-es5.js b/event-pubsub-browser-es5.js index a40ca5b..8ee91a6 100644 --- a/event-pubsub-browser-es5.js +++ b/event-pubsub-browser-es5.js @@ -53,20 +53,21 @@ window.EventPubSub=function EventPubSub() { } function emit(type){ + this.emit$.apply(this, arguments); + if(!this._events_[type]){ + return this; + } + arguments.splice=Array.prototype.splice; arguments.splice(0,1); - if(!this._events_[type]){ - return emit$.apply(this, type, arguments); - } - const handlers=this._events_[type]; for(let handler of handlers){ handler.apply(this, arguments); } - return emit$.apply(this, type, arguments); + return this; } function emit$(type, args){ diff --git a/npm-debug.log b/npm-debug.log deleted file mode 100644 index 4efffbd..0000000 --- a/npm-debug.log +++ /dev/null @@ -1,108 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'publish' ] -2 info using npm@3.10.8 -3 info using node@v6.7.0 -4 verbose publish [ '.' ] -5 silly cache add args [ '.', null ] -6 verbose cache add spec . -7 silly cache add parsed spec Result { -7 silly cache add raw: '.', -7 silly cache add scope: null, -7 silly cache add escapedName: null, -7 silly cache add name: null, -7 silly cache add rawSpec: '.', -7 silly cache add spec: '/home/ssmp/git/event-pubsub', -7 silly cache add type: 'directory' } -8 verbose addLocalDirectory /home/ssmp/.npm/event-pubsub/4.2.0/package.tgz not in flight; packing -9 verbose correctMkdir /home/ssmp/.npm correctMkdir not in flight; initializing -10 info lifecycle event-pubsub@4.2.0~prepublish: event-pubsub@4.2.0 -11 silly lifecycle event-pubsub@4.2.0~prepublish: no script for prepublish, continuing -12 verbose tar pack [ '/home/ssmp/.npm/event-pubsub/4.2.0/package.tgz', -12 verbose tar pack '/home/ssmp/git/event-pubsub' ] -13 verbose tarball /home/ssmp/.npm/event-pubsub/4.2.0/package.tgz -14 verbose folder /home/ssmp/git/event-pubsub -15 verbose addLocalTarball adding from inside cache /home/ssmp/.npm/event-pubsub/4.2.0/package.tgz -16 verbose correctMkdir /home/ssmp/.npm correctMkdir not in flight; initializing -17 silly cache afterAdd event-pubsub@4.2.0 -18 verbose afterAdd /home/ssmp/.npm/event-pubsub/4.2.0/package/package.json not in flight; writing -19 verbose correctMkdir /home/ssmp/.npm correctMkdir not in flight; initializing -20 verbose afterAdd /home/ssmp/.npm/event-pubsub/4.2.0/package/package.json written -21 silly publish { name: 'event-pubsub', -21 silly publish version: '4.2.0', -21 silly publish description: 'Super light and fast Extensible PubSub events and EventEmitters for Node and the browser with support for ES6 by default, and ES5 versions for older verions of node and older IE/Safari versions. Easy for any developer level. No frills, just high speed pubsub events!', -21 silly publish main: 'event-pubsub.js', -21 silly publish directories: { example: 'examples' }, -21 silly publish scripts: { test: 'echo "Error: no test specified" && exit 1' }, -21 silly publish repository: -21 silly publish { type: 'git', -21 silly publish url: 'git+https://github.com/RIAEvangelist/event-pubsub.git' }, -21 silly publish keywords: [ 'event', 'events', 'pubsub', 'node', 'browser' ], -21 silly publish author: { name: 'Brandon Nozaki Miller' }, -21 silly publish license: 'Unlicense', -21 silly publish bugs: { url: 'https://github.com/RIAEvangelist/event-pubsub/issues' }, -21 silly publish homepage: 'https://github.com/RIAEvangelist/event-pubsub', -21 silly publish readme: '# Event PubSub\n\nnpm info : \n  \n\nGitHub info : \n  \n\n***Super light and fast*** Extensible PubSub events and EventEmitters for Node and the browser with support for ES6 by default, and ES5 versions for older verions of node and older IE/Safari versions.\n\nEasy for any developer level. No frills, just high speed events following the publisher subscriber pattern!\n\n[Pretty GitHub.io site](http://riaevangelist.github.io/event-pubsub/) \n\n[See NPM stats for event-pubsub](http://npm-stat.com/charts.html?package=event-pubsub&author=&from=&to=)\n\n**EXAMPLE FILES** \n\n1. [Node Event PubSub Examples](https://github.com/RIAEvangelist/event-pubsub/tree/master/examples/node) \n2. [Browser Event PubSub Examples](https://github.com/RIAEvangelist/event-pubsub/tree/master/examples/browser)\n\n**Node Install** \n`npm i --save event-pubsub` \nBy default the correct version (ES5/ES6) will be included. You can force the es5/6 version by requiring `event-pubsub/es5` or `event-pubsub/es6`.\n\n**Browser Install** \n*see browser examples above or below* \n\n```html\n\n\n\n\n```\n\n# Methods\n\n|Method|Arguments|Description|\n|------|---------|-----------|\n|subscribe|type (string), handler(function)|will bind the `handler` function to the the `type` event. Just like `addEventListener` in the browser|\n|on|same as above|same as above|\n|unSubscribe|type (string), handler(function or *)|will ***un***bind the `handler` function from the the `type` event. If the `handler` is `*`, all handlers for the event type will be removed. Just like `removeEventListener` in the browser, but also can remove all event handlers for the type.|\n|off|same as above|same as above|\n|publish|type (string), ...data arguments|will call all `handler` functions bound to the event `type` and pass all `...data arguments` to those handlers|\n|emit|same as above|same as above|\n|trigger|same as above|same as above|\n\nWhile `publish`, `subscribe`, and `unSubscribe` are the proper method names for the publisher/subscriber model, we have included `on`, `off`, and `emit` as well because these are the most common event method names, and shorter. We have also kept the `trigger` method as an alias for `publish` and `emit` for backwards compatability with earlier versions of `event-pubsub`.\n\n# The ` * ` type\n\nThe ` * ` type is a special event type that will be triggered by ***any publish or emit*** the handlers for these should expect the first argument to be the type and all arguments after to be data arguments.\n\n\n## Basic Examples\n\n***NOTE - the only difference between node and browser code is how the `events` variable is created*** \n* node ` const events = new Events `\n* browser `const events = new window.EventPubSub;`\n\n#### Node\n\n```javascript\n\n// ES5/ES6 now automatically chosen based on node version\nconst Events = new require(\'event-pubsub\');\nconst events=new Events;\n\nevents.on(\n \'hello\',\n function(data){\n console.log(\'hello event recieved \', data);\n events.emit(\n \'world\',\n {\n type:\'myObject\',\n data:{\n x:\'YAY, Objects!\'\n }\n }\n )\n }\n);\n\nevents.on(\n \'world\',\n function(data){\n console.log(\'World event got\',data);\n events.off(\'*\',\'*\');\n console.log(\'Removed all events\');\n }\n);\n\nevents.emit(\n \'hello\',\n \'world\'\n);\n\n\n\n```\n\n#### Basic Chaining\n\n```javascript\n\nevents.on(\n \'hello\',\n someFunction\n).on(\n \'goodbye\',\n anotherFunction\n).emit(\n \'hello\',\n \'world\'\n);\n\nevents.emit(\n \'goodbye\',\n \'complexity\'\n).off(\n \'hello\',\n \'*\'\n);\n\n```\n\n#### Browser\n##### HTML\n\n```html\n\n\n \n \n
\n