Permalink
Browse files

tabs = 2 spaces + renamed main file to index.js

  • Loading branch information...
1 parent 8fe825f commit 4e487e8347a4fef657ca3944a811326779f20669 @morphar morphar committed Apr 1, 2013
Showing with 72 additions and 74 deletions.
  1. +0 −32 gevents.js
  2. +32 −0 index.js
  3. +32 −34 package.json
  4. +8 −8 test.js
View
@@ -1,32 +0,0 @@
-var util = require('util');
-var events = require('events');
-var redis = require('redis');
-
-var redisPub = redis.createClient();
-var redisSub = redis.createClient();
-
-var GEvents = function(globalPrefix) {
- events.EventEmitter.call(this);
-
- this.globalPrefix = globalPrefix || 'gevents_'
- this.setMaxListeners(100);
- var self = this;
- redisSub.on('pmessage', function(channelPattern, channel, message) {
- channel = channel.substr(self.globalPrefix.length);
- self.emit(channel, message);
- });
- redisSub.psubscribe(this.globalPrefix+'*');
-};
-util.inherits(GEvents, events.EventEmitter);
-
-GEvents.prototype.globalEmit = function() {
- if(arguments.length === 0) {
- return false;
- } else {
- var channel = this.globalPrefix + arguments[0];
- delete arguments[0];
- redisPub.publish(channel, JSON.stringify(arguments));
- }
-};
-
-module.exports = new GEvents();
View
@@ -0,0 +1,32 @@
+var util = require('util');
+var events = require('events');
+var redis = require('redis');
+
+var redisPub = redis.createClient();
+var redisSub = redis.createClient();
+
+var GEvents = function(globalPrefix) {
+ events.EventEmitter.call(this);
+
+ this.globalPrefix = globalPrefix || 'gevents_';
+ this.setMaxListeners(100);
+ var self = this;
+ redisSub.on('pmessage', function(channelPattern, channel, message) {
+ channel = channel.substr(self.globalPrefix.length);
+ self.emit(channel, message);
+ });
+ redisSub.psubscribe(this.globalPrefix+'*');
+};
+util.inherits(GEvents, events.EventEmitter);
+
+GEvents.prototype.globalEmit = function() {
+ if(arguments.length === 0) {
+ return false;
+ } else {
+ var channel = this.globalPrefix + arguments[0];
+ delete arguments[0];
+ redisPub.publish(channel, JSON.stringify(arguments));
+ }
+};
+
+module.exports = new GEvents();
View
@@ -1,36 +1,34 @@
{
- "name": "gevents",
- "version": "0.1.1",
- "description": "An extension to node.js events, that adds global events through redis",
- "keywords":[
- "events",
- "global",
- "redis"
- ],
- "author": "Dan Larsen",
- "maintainers": [{
- "name": "Dan Larsen",
- "email": "dan@techba.se",
- "url": "http://github.com/morphar"
- }],
- "dependencies": {
- "redis": ">=0.8.2"
- },
- "repository": {
- "type": "git",
- "url": "http://github.com/morphar/gevents.git"
- },
- "github": "http://github.com/morphar/gevents",
- "bugs": {
- "mail": "",
- "url": "http://github.com/morphar/gevents/issues"
- },
- "license": {
- "type": "MIT",
- "url": "http://github.com/morphar/gevents/blob/master/LICENSE"
- },
- "main": "./gevents.js",
- "engines": {
- "node": ">=0.8.0"
- }
+ "name": "gevents",
+ "version": "0.1.1",
+ "description": "An extension to node.js events, that adds global events through redis",
+ "keywords":[
+ "gevents",
+ "global",
+ "events",
+ "global",
+ "redis"
+ ],
+ "author": "Dan Larsen",
+ "maintainers": [{
+ "name": "Dan Larsen",
+ "email": "dan@techba.se",
+ "url": "http://github.com/morphar"
+ }],
+ "dependencies": {
+ "redis": ">=0.8.2"
+ },
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/morphar/gevents.git"
+ },
+ "github": "http://github.com/morphar/gevents",
+ "bugs": {
+ "url": "http://github.com/morphar/gevents/issues"
+ },
+ "license": "MIT",
+ "main": "./index.js",
+ "engines": {
+ "node": ">=0.8.0"
+ }
}
View
16 test.js
@@ -5,11 +5,11 @@ var GEvents2 = require('./gevents.js');
GEvents1.on('bla', function() { console.log('bla', arguments); });
setInterval(function() {
-
- if(!(process.pid % 2)) {
- GEvents2.emit('bla', { some: 'data' }, 'bla', 'yadda');
- } else {
- GEvents2.globalEmit('bla', { some: 'data2' });
- }
-
- }, 2000);
+
+ if(!(process.pid % 2)) {
+ GEvents2.emit('bla', { some: 'data' }, 'bla', 'yadda');
+ } else {
+ GEvents2.globalEmit('bla', { some: 'data2' });
+ }
+
+}, 2000);

0 comments on commit 4e487e8

Please sign in to comment.