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

opatomic-client

v0.1.59

Published

Opatomic client

Downloads

4

Readme

Opatomic client for javascript

This project contains source code for the node.js opatomic-client package. The code can also be built to run in a browser. Running in the browser is undocumented for now (to see source for a working example check out the admin tool).

Node.js package

Install with:

npm install opatomic-client

Usage Example

var libnet = require("net");
var libopac = require("opatomic-client");
var BigInteger = require("jsbn").BigInteger;
var BigDec = libopac.BigDec;

function echoResult(err, result) {
	if (err) {
		console.log("ERROR: " + libopac.stringify(err));
	} else {
		console.log("SUCCESS: " + libopac.opaType(result) + " " + libopac.stringify(result));
	}
}

var sock = new libnet.Socket();
sock.setNoDelay(true);
sock.connect(4567, "localhost", function() {
	console.log("connected");
	var c = libopac.newClient(sock);

	c.call("PING");
	c.call("PING", null, echoResult);
	c.call("ECHO", ["Hello"], echoResult);
	c.call("ECHO", [[undefined, null, false, true, -1, 0, 1, "string", []]], echoResult);

	c.call("INCR", ["TESTkey", -4], echoResult);
	c.call("INCR", ["TESTkey", new BigInteger("12345678901234567890")], echoResult);
	c.call("INCR", ["TESTkey.dec", new BigDec("-1.234")], echoResult);

	// callA() can be used for long running ops so they don't block responses
	// note: op may still block other responses (depends on server implementation)
	c.callA("SINTERSTORE", ["destkey", "set1", "set2"], echoResult);

	c.call("ECHO", ["Hello", "ExtraArg!"], echoResult);
	c.call("BADCMD", ["Hello"], echoResult);

	c.registerCB("_pubsub", echoResult);
	c.call("SUBSCRIBE",  ["channelName", "channelName2", "channelName3", "channelName2"]);
	c.call("PSUBSCRIBE", ["c*", "ch*", "n*", "*"]);
	c.call("PUBLISH", ["channelName", "chan message 1"]);
	c.call("PUNSUBSCRIBE");
	c.call("UNSUBSCRIBE", ["channelName", "channelName2", "channelName3", "channelName2"], function(err, result) {
		if (err) {
			console.log("Error: could not unsubscribe; " + err);
		} else {
			console.log("Unsubscribed");
			c.registerCB("_pubsub", null);
		}
	});
	c.call("PUBLISH", ["channelName", "chan message 2"]);

	// TODO: add example with bigdec

	c.call("QUIT");
});

API

  • newClient(socket)
  • client.call(opname[, args[, callback]])
  • client.callA(opname, args, callback)
  • client.registerCB(asyncID, callback)
  • client.callID(asyncID, opname, args)

Serializer supported types

  • undefined
  • null
  • boolean (false/true)
  • numbers (integers, floats, Infinity, -Infinity; NaN and -0 not supported)
  • strings
  • arrays
  • binary buffer (Buffer for node; Uint8Array for browser)
  • BigInteger (node "jsbn" package)
  • BigDec