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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rain-util

v0.4.6

Published

Generator based swiss knife for consuming apis, accessing postgres, and managing filesystem

Downloads

51

Readme

rain-util

Build Status npm npm npm

generator based toolkit for consuming apis, accessing postgres, and managing filesystem

npm i rain-util
const $util = require('rain-util');

for fast prototyping. use sub-packages if only a subset is needed

  • https://github.com/maxmill/rain-util-http
  • https://github.com/maxmill/rain-util-download
  • https://github.com/maxmill/rain-util-fs
  • https://github.com/maxmill/rain-util-postgres

http requests

extends request.js additional properties may be passed as params (httpSignature, multipart, headers)

const api = new $util.http('https://maps.googleapis.com/');
const api2 = new $util.http('https://my.api.com/',
  { 'x-default-header':'its value'},
  {httpSignature:{keyId:'rsa-key-1',algorithm='rsa-sha256',signature:'Base64(RSA-SHA256(signing string))'}
);

const req = new $util.http();

const apiResponse = yield mapsApi.get('maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA');
console.log('apiResponse',apiResponse);
req.get('full url');

const api2Response = yield api2.post('another url', requestBody);

postgres

queries, data access objects, transactions, schema data

const conn = { host: 'localhost', db: 'postgres', user: 'postgres', password: 'postgres' };
const $postgres =  new $util.postgres(conn); // connection string also acceptable

if($postgres) {
  postgres.db.query('SELECT test');
// create a test table
        const tableName = 'testers';
        const testTable = `DROP TABLE IF EXISTS ${tableName}; CREATE TABLE ${tableName}(id CHARACTER constYING(40))WITH(OIDS=FALSE);ALTER TABLE ${tableName} OWNER TO postgres;`;
        yield $postgres.db.query(testTable);

// load created table into $postgres object
        $postgres.table(tableName);

// add a record
        const recordId = '4a2b';
        yield $postgres.tables[`${tableName}`].upsert({id: recordId});

// find created record using dao
        const daoRecord = yield  $postgres.tables[`${tableName}`].findOne('id = ?', recordId);

// find created record using sql
        const findRecordSQL = `SELECT * FROM ${tableName} WHERE id = '${recordId}'`;
        const sqlRecord = (yield $postgres.db.query(findRecordSQL)).rows[0];

// add new record
  $postgres.tables.books.upsert({id:'4324'})

//within transaction, find new record and then delete it
  $postgres.db.transaction(function*() {
    let record = yield $postgres.tables[`${tableName}`].findOne('id = ?', '4324');  
    yield $postgres.dao.delete(record); // delete by model throws if more than one row is affected
    yield $postgres.dao.delete('id = 4324'); // delete by query, returns count
  });
}


// get schema information
const schema = yield $postgres.schema();

generator utilities

util.genify - (function) convert regular functions into generator functions
yield util.array.(forEach|map|filter|forEachSeries)

file utilities

extends co-fs - all core node fs methods available as generators

$util.fs.download   - (file or file array) downloads url(s) to file(s)
$util.fs.upsert     - (dir or dir array) creates dir if non-existent (uses mkdirp)
$util.fs.fetch     - (file or dir) read file or directory contents
$util.fs.rimraf     - (path) yieldable rm -rf
$util.fs.json.(read|write)  - (file, obj, options)

requires node 4.2 or higher

credits

  • https://github.com/request/request
  • https://github.com/jprichardson/node-jsonfile
  • https://github.com/substack/node-mkdirp
  • https://github.com/evs-chris/node-postgres-gen
  • https://www.npmjs.com/package/array-generators