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

libmill

v0.4.0

Published

bindings to libmill

Downloads

46

Readme

node.js function access to libmill

Build Status

go style concurrency for node.

an experiment

#install libmill and libsodium dependencies
$ git clone https://github.com/sustrik/libmill.git
$ cd libmill && ./autogen.sh && ./configure && make -j 8 && sudo make install
$ sudo /sbin/ldconfig # linux only

$ git clone https://github.com/jedisct1/libsodium.git
$ cd libsodium && ./autogen.sh && ./configure && make -j 8 && sudo make install
$ sudo /sbin/ldconfig # linux only

$ npm i && npm t

tcp library

for msgs over tcp/ip, a server can use tcplisten(). once a client connects, the server can use tcpaccept() to establish bidirectional tcp streams.

tcplisten() and tcpaccept()

var lib = require('libmill');

/* create an ipaddr */
var ipaddr = lib.iplocal(5555);

/* listen on the ipaddr */
var ls = lib.tcplisten(ipaddr);
console.log('listening on port %s', lib.tcpport(ls));

while(1){
  /* accept and establish tcp connection */
  var as = lib.tcpaccept(ls);
  console.log('\nnew connection\nmsg recvd: ' + lib.tcprecvuntil(as));

  /* close tcp connection */
  lib.tcpclose(as);
}

tcpconnect()

var lib = require('libmill');

/* create an ipaddr */
var ipaddr = lib.iplocal(5555);

/* connect over the ipaddr */
var cs = lib.tcpconnect(ipaddr);
var str = 'go style concurrency for node', num = 1;

/* send a few msg before tcpflush */
/* delimiter is set to '\r', tells tcprecvuntil when to finish */
send('msg # ', str);
send('msg # ', str);
send('msg #', str+'\r');
function send(n, msg){
  n+= num+++msg+'\n';
  lib.tcpsend(cs, new Buffer(n));
}

/* tcpsend() stores data in user space and tcpflush() pushes it to kernel */
lib.tcpflush(cs);

udp library

udplisten() and udprecv()

var lib = require('libmill');

/* create an ipaddr */
var ipaddr = lib.iplocal(4444);

/* listen on ipaddr */
var ls = lib.udplisten(ipaddr);
process.stdout.write('udp socket listening on port: ' + lib.udpport(ls) + '\n');

/* next, to get udp msgs, use udprecv
   if you pass a cb function as the 3rd param, the call will use libuv async
   the callback's param will contain your msg

   otherwise w/out a cb, it will block and udprecv's return value is your msg */


/* the non-blocking way (a for async) */
lib.udprecv(ls, 255, function (msg) {
  var buf = String(msg.buf) /* msg.buf is a node buffer of the packet body */
  var addr = msg.addr  /* string address of packet origin */
});

/* the blocking way  */
while (1) {
  var sz = 13;
  var deadline = 10;

  var msg = lib.udprecv(ls, sz, deadline); /* deadline is optional param */
  process.stdout.write(msg.buf + '\n');
}

udpsend()

var s = lib.udplisten(ipaddr);
var buf = new Buffer('Hello, world!');

lib.udpsend(s, ipaddr, buf);

test

see test directory

license

MIT

tested on circleci linux and osx.