starting to factor functions from cjdns/contrib/nodejs from standalone scripts into modules