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

pubsub-js

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pubsub-js - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

branding/logo.png

8

package.json
{
"name": "pubsub-js",
"version": "1.7.0",
"version": "1.8.0",
"description": "Dependency free publish/subscribe library",

@@ -14,3 +14,6 @@ "main": "./src/pubsub.js",

"lint": "eslint src/ test/",
"test": "mocha"
"test": "mocha",
"preversion": "npm test",
"version": "changes --commits --footer",
"postversion": "git push --follow-tags && npm publish --access public"
},

@@ -35,2 +38,3 @@ "repository": {

"devDependencies": {
"@studio/changes": "^2.0.0",
"eslint": "4.19.1",

@@ -37,0 +41,0 @@ "jsdoc-to-markdown": "^4.0.1",

<div align="center">
<p>
<h1> PubSubJS
<img src="https://raw.githubusercontent.com/mroderick/PubSubJS/master/branding/logo.png"/ alt="PubSubJS" title="PubSubJS" width="200" height="200">
</p>

@@ -45,2 +45,3 @@

- https://cdnjs.com/libraries/pubsub-js
- https://unpkg.com/pubsub-js
* [Download a tagged version](https://github.com/mroderick/PubSubJS/tags) from GitHub

@@ -132,2 +133,26 @@

### Get Subscriptions
```javascript
PubSub.getSubscriptions('token');
// subscriptions by token from all topics
```
### Count Subscriptions
```javascript
PubSub.countSubscriptions('token');
// count by token from all topics
```
### Error Handling
```javascript
// isPublished is a boolean that represents if any subscribers was registered for this topic
var isPublished = PubSub.publish('a');
// token will be false if something went wrong and subscriber was not registered
var token = PubSub.subscribe('MY TOPIC', mySubscriber);
```
### Hierarchical addressing

@@ -163,2 +188,5 @@

## Tips

@@ -245,2 +273,2 @@

* http://radio.uxder.com/ — oriented towards 'channels', free of dependencies
* https://github.com/pmelander/Subtopic - supports vanilla, underscore, jQuery and is even available in NuGet
* https://github.com/pmelander/Subtopic - supports vanilla, underscore, jQuery and is even available in NuGet

@@ -150,3 +150,3 @@ /**

/**
* Publishes the the message synchronously, passing the data to it's subscribers
* Publishes the message synchronously, passing the data to it's subscribers
* @function

@@ -223,2 +223,3 @@ * @alias publishSync

* @alias clearAllSubscriptions
* @return { int }
*/

@@ -234,2 +235,38 @@ PubSub.clearSubscriptions = function clearSubscriptions(topic){

/**
Count subscriptions by the topic
* @function
* @public
* @alias countSubscriptions
* @return { Array }
*/
PubSub.countSubscriptions = function countSubscriptions(topic){
var m;
var count = 0;
for (m in messages){
if (messages.hasOwnProperty(m) && m.indexOf(topic) === 0){
count++;
}
}
return count;
};
/**
Gets subscriptions by the topic
* @function
* @public
* @alias getSubscriptions
*/
PubSub.getSubscriptions = function getSubscriptions(topic){
var m;
var list = [];
for (m in messages){
if (messages.hasOwnProperty(m) && m.indexOf(topic) === 0){
list.push(m);
}
}
return list;
};
/**

@@ -236,0 +273,0 @@ * Removes subscriptions

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