0.1.1 • Published 8 years ago

turms v0.1.1

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Turms is a simple and lightweight Node messaging system. It provides Hub, Subscriber and Message objects.

Turms consists of two modules/files. turms.js is the messenger and provides factory functions for Message, Subscriber and Hub objects. timer.js is a more accurate and self-adjusting alternative to setTimeout that Hub uses for sending delayed messages.

Turms has no dependencies unless you want to run the tests. Then it uses Mocha and Chai.

Usage:

const Turms = require('./turms');
const hub = Turms.Hub();
const subscriber = Turms.Subscriber();

hub.addSubscription(subscriber, 'message', (message) => console.log(message.data));

hub.sendMessage(
	Turms.Message({
		// type could be ignored as 'message' is the default type.
		type: 'message',
		data: { foo: 'bar', bar: 'foo' }
		// other options are:
		//     delay, for sending a message in the future
		// and
		//     recipient, for sending a message only to a specific subscriber
	})
);

Output:

{ foo: 'bar', bar: 'foo' }

More documentation can be found at the Wiki.

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.1

8 years ago