npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

larvitamintercom

v0.4.86

Published

[![Build Status](https://github.com/larvit/larvitamintercom/actions/workflows/ci.yml/badge.svg)](https://github.com/larvit/larvitamintercom/actions)

Downloads

2,045

Readme

Build Status

Larvitamintercom

Communication wrapper for rabbitmq in autobahn.

Usage

Connection

When instantiating a new intercom it will try to connect instantly and on connection error or connection lost it will try to reconnect an infinite number of times every 1sec.

Send

send() to autobahn.

const	Intercom	= require('larvitamintercom'),
	conStr	= 'amqp://user:[email protected]/',
	intercom	= new Intercom(conStr);

let	message	= {'hello':	'world'},
	options	= {'exchange':	'foo'}; // Will default to "default" if options is omitted

intercom.send(message, options, function (err, msgUuid) {
	// called when message is accepted by queue handler
	// msgUuid will be a unique UUID for this specific message
});

Default send options:

{
	'exchange':	'default',
	'durable':	true,
	'forceConsumeQueue':	false // Will create a queue for consumtion even if there is no current listeners. This way no message will ever be lost, since they will wait in this queue until some consumer consumes them.
}

Read

There are two types of read operations; "consume" and "subscribe".

A message can only be "consumed" once, but it can be "subscribed" several times, by different readers.

Consumers can be assigned to an exchanged after the message have been sent, and they still receive the message. However, very importantly, ONE consumer must be assigned before the send happends, or the consumer queue never gets declared!

Subscribers, in contrast, must subscribe BEFORE the message is sent or they will not receive it.

Each subscriber only get each message once.

Consume

const	Intercom	= require('larvitamintercom'),
	conStr	= 'amqp://user:[email protected]/',
	intercom	= new Intercom(conStr);

let	options = {'exchange': 'foo'}; // Will default to "default" if options is omitted

intercom.consume(options, function (message, ack, deliveryTag) {
	// message being the object sent with intercom.send()

	// deliveryTag is an identification of this delivery

	// Must be ran! Always! ACK!!
	ack();
	// or
	ack(new Error('Something was wrong with the message'));
}, function (err) {
	// Callback from established consume connection
});
Default consume options:
{
	'exchange':	'default'
}

Subscribe

const	Intercom	= require('larvitamintercom').Intercom,
	conStr	= 'amqp://user:[email protected]/',
	intercom	= new Intercom(conStr);

let options = {'exchange': 'default'};

intercom.subscribe(options, function (message, ack, deliveryTag) {
	// message subscribe the object sent with intercom.send()

	// deliveryTag is an identification of this delivery

	// Must be ran! Always! ACK!!
	ack();
	// or
	ack(new Error('Something was wrong with the message'));
}, function (err, subscribeInstance) {
	// Callback from established subscribe connection
});
Default subscribe options:
{
	'exchange':	'default'
}

Custom logging

const	Intercom	= require('larvitamintercom').Intercom,
	winston	= require('winston'),
	log	= winston.createLogger({'transports': [new winston.transports.Console()]}),
	conStr	= 'amqp://user:[email protected]/',
	intercom	= new Intercom({'conStr': conStr, 'log': log});