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

higgs

v0.0.1

Published

Implementation of the Higgs Boson protocol.

Downloads

10

Readme

higgs-node

Higgs Boson - Node JS

Node JS implementation of the Boson protocol.

It allows for communication between any Boson server implementation from JavaScript.

Example

The example below users the server example found in the Scala demo

  1. Start the Scala server
  2. Run the example below

var higgs = require("./higgs.js")
var client = new higgs.BosonClient("localhost", 12001)
client.connect()

for (var i = 0; i < 1000; i++)
    client.invoke('nodejs', [
        1.2, 1, null,
        {a:1, v:12345},
        [1, 2, 3],
        true, "test"
    ], function (a) {
        console.log(a)
    })

Output

[ 1.2000000476837158,
  1,
  null,
  { a: 1, v: 12345 },
  [ 1, 2, 3 ],
  true,
  'test' ]
...

Protocol and Deviation from the specs

  • JavaScript is powerful but limited in its own way, some of the data types the Boson protocol supports are not supported in JavaScript. Where possible, JavaScript equivalents are used.

Longs

JavaScript does not support longs. When de-serializing the 64 bits that would have otherwise been the entire contents of a long value are taken and broken into "high" and "low" bits.

  • The "high" bits (left most 32 bits of the 64 bits) are discarded
  • The "low" bits are then treated as an integer and returned. This means if a long value is received that cannot fit into 32 bits it won't give what you expect.
  • If Longs must be sent to the Node JS client then send it as a string!
  • I've considered doing something similar to mongo but it seems over kill if its not absolutely required. Open to suggestions on how to handle it.

Floats & Doubles

No matter what you try, no matter how much you yell floats are the only supported types WHEN SENDING, the server can send doubles back and they will be handled as expected. So on the server, don't expect Node JS to send a double, it'll always send a float.

It is possible for Node JS to send Doubles but to do that you'd have to be able to differentiate between a float and a double. Not found a sensible way to do that.

Maps & POLOs

A POLO is Boson's way of allowing a statically typed language such as Java/Scala to send any of its types. JavaScript doesn't really have static types and on most days everything is an "object".

  • When the Node JS client receives a POLO it creates a JavaScript hash/map from it. In that hash, the keys are the variable names and the values are what were the values of the variable when the POLO was serialized.

Arrays & Lists

  • Practically the only difference between an array and a list is that arrays are ordered and lists aren't. When the client receives a list it just de-serializes it into a JavaScript array.

Server

  • TODO - Only a Boson client is implemented in JavaScript so far. It allows you to invoke methods on a Boson server and receive whatever response that method returned.