Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

raptor-pubsub

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raptor-pubsub - npm Package Compare versions

Comparing version 0.2.1-beta to 0.2.2-beta

72

lib/raptor-pubsub.js

@@ -100,65 +100,21 @@ /*

'use strict';
var listeners = require('raptor-listeners');
var EventEmitter = require('events').EventEmitter;
function Message(topic, props) {
listeners.Message.call(this, topic, props);
this.topic = topic;
}
Message.prototype = {
getTopic: function () {
return this.topic;
}
};
require('raptor-util').inherit(Message, listeners.Message);
var channels = {};
function Channel(name) {
this.name = name;
this.observable = listeners.createObservable();
}
Channel.prototype = {
publish: function (topic, data) {
var message;
//Convert the arguments into a Message object if necessary so that we can associate extra information with the message being published
if (listeners.isMessage(topic)) {
message = topic;
} else {
message = require('raptor-pubsub').createMessage(topic, data);
var globalChannel = new EventEmitter();
globalChannel.channel = function() {
var channel;
if (name) {
channel = channels[name];
if (!channel) {
channel = new EventEmitter();
channels[name] = channel;
}
this.observable.publish(message);
return message;
},
subscribe: function (topic, callback, thisObj) {
return this.observable.subscribe(topic, callback, thisObj);
} else {
channel = new EventEmitter();
}
return channel;
};
var channels = {};
module.exports = {
channel: function (name) {
var channel;
if (name) {
channel = channels[name];
if (!channel) {
channel = new Channel(name);
channels[name] = channel;
}
} else {
channel = new Channel();
}
return channel;
},
global: function () {
return this.channel('global');
},
publish: function (topic, props) {
var global = this.global();
global.publish.apply(global, arguments);
},
subscribe: function (topic, callback, thisObj) {
var global = this.global();
return global.subscribe.apply(global, arguments);
},
createMessage: function (topic, data) {
return new Message(topic, data);
}
};
module.exports = globalChannel;

4

package.json

@@ -15,3 +15,3 @@ {

"raptor-util": "^0.2.0-beta",
"raptor-listeners": "^0.2.0-beta"
"events": "^1.0.0"
},

@@ -28,3 +28,3 @@ "devDependencies": {

},
"version": "0.2.1-beta"
"version": "0.2.2-beta"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc