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.3.4 to 1.3.5

3

package.json
{
"name": "pubsub-js",
"version": "1.3.4",
"version": "1.3.5",
"description": "Dependency free publish/subscribe library",
"main": "./src/pubsub.js",
"directories": {

@@ -6,0 +7,0 @@ "lib": "src",

@@ -1,24 +0,22 @@

# PubSubJS [![Build Status](https://travis-ci.org/mroderick/PubSubJS.png)](https://travis-ci.org/mroderick/PubSubJS)
# PubSubJS
PubSubJS is a dependency free library for doing [publish/subscribe](http://en.wikipedia.org/wiki/Publish/subscribe)
messaging in [JavaScript](https://developer.mozilla.org/en/JavaScript).
[![Build Status](https://travis-ci.org/mroderick/PubSubJS.png)](https://travis-ci.org/mroderick/PubSubJS) [![NPM version](https://badge.fury.io/js/pubsub-js.png)](http://badge.fury.io/js/pubsub-js)
In order to not have surprising behaviour where the execution chain generates more than one message,
publication of messages with PubSub are done asyncronously (this also helps keep your code responsive, by
dividing work into smaller chunks, allowing the event loop to do it's business).
PubSubJS is a dependency free [publish/subscribe](http://en.wikipedia.org/wiki/Publish/subscribe) library for [JavaScript](https://developer.mozilla.org/en/JavaScript).
If you're feeling adventurous, you can also use syncronous message publication (speedup in browsers), which can lead
to some very confusing conditions, when one message triggers publication of another message in the same execution chain.
Don't say I didn't warn you.
PubSubJS has synchronisation decoubling, so messages are delivered asynchronously. This helps keep your program predictable as the originator of messages will not be blocked while consumers process messages.
## Goals
For the adventurous, PubSubJS also supports synchronous message publication. This can give a speedup in some environments (browsers, not all), but can also lead to some very difficult to reason about programs, when one message triggers publication of another message in the same execution chain.
* No dependencies
For benchmarks, see [A Comparison of JS Publish/Subscribe Approaches](http://jsperf.com/pubsubjs-vs-jquery-custom-events/51)
## Key features
* Dependency free
* Synchronization decoupling
* ES3 compatible. PubSubJS should be able to run everywhere that can execute JavaScript. Browsers, servers, ebook readers, old phones, game consoles.
* AMD / CommonJS module support
* No modification of subscribers (jQuery custom events modify subscribers)
* No use of DOM for exchanging messages
* No reliance of running in a browser
* Easy to understand (messages are async by default)
* Small(ish)
* Compatible! ES3 compatible, should be able to run everywhere that can execute JavaScript
* AMD / CommonJS module
* Easy to understand and use (thanks to synchronization decoupling)
* Small(ish), less than 1kb minified and gzipped

@@ -30,3 +28,3 @@ ## Examples

```javascript
// create a function to receive the message
// create a function to receive messages
var mySubscriber = function( msg, data ){

@@ -36,3 +34,3 @@ console.log( msg, data );

// add the function to the list of subscribers to a particular message
// add the function to the list of subscribers for a particular message
// we're keeping the returned token, in order to be able to unsubscribe

@@ -45,3 +43,3 @@ // from the message later on

// publish a message syncronously, which is faster by orders of magnitude,
// publish a message syncronously, which is faster in some environments,
// but will get confusing when one message triggers new messages in the

@@ -98,3 +96,2 @@ // same execution chain

// create a subscriber to receive only leaf message from hierarchy op topics

@@ -108,3 +105,2 @@ var mySpecificSubscriber = function( msg, data ){

// Publish some topics

@@ -121,3 +117,2 @@ PubSub.publish( 'car.purchase', { name : 'my new car' } );

## Tips

@@ -170,3 +165,2 @@

```javascript

@@ -193,2 +187,6 @@ var topic = 'greeting',

In the jQuery build, the global ```PubSub``` global is still available, so you can mix and match both ```Pubsub``` and ```$.pubsub``` as needed.
There is also an article about [Using PubSubJS with jQuery](http://roderick.dk/resources/using-pubsubjs-with-jquery/)
## Development

@@ -202,4 +200,2 @@

**Note:** Before running the tests, you should [download jQuery 1.7.2](http://code.jquery.com/jquery-1.7.2.js) and put it in the lib folder.
### Linting

@@ -218,2 +214,8 @@

```
or by running
```bash
$ npm test
```
## Future of PubSubJS

@@ -229,2 +231,3 @@

* [Addy Osmani's mini book on Patterns](http://addyosmani.com/resources/essentialjsdesignpatterns/book/#observerpatternjavascript)
* [Publish / Subscribe Systems, A summary of 'The Many Faces of Publish / Subscribe'](http://downloads.ohohlfeld.com/talks/hohlfeld_schroeder-publish_subscribe_systems-dsmware_eurecom2007.pdf)

@@ -272,2 +275,3 @@ ## Versioning

* http://amplifyjs.com/api/pubsub/
* http://radio.uxder.com/ — oriented towards 'channels', free of dependencies
* 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

@@ -37,3 +37,3 @@ /*

name: 'PubSubJS',
version: '1.3.4'
version: '1.3.5'
},

@@ -40,0 +40,0 @@ messages = {},

@@ -13,3 +13,3 @@ /*jslint white:true, plusplus:true */

var PubSub = global.PubSub || require("../src/pubsub"),
EXPECTED_VERSION = "1.3.4";
EXPECTED_VERSION = "1.3.5";

@@ -16,0 +16,0 @@ buster.testCase( "PubSub module", {

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