node package manager


Utils library shared between the digger digger libraries


Small utils library shared between the and digger libraries


as a node module:

$ npm install digger-utils

or in the browser using browserify


returns a compact uuid using hat

var utils = require('digger-utils');
var id = utils.diggerid();
// id = 95a4bdcc8dc1c7a16da87da7c4b07c38 

returns a random string of (chars) length

var utils = require('digger-utils');
var id = utils.littleid();
// id = d0cd49 

A naive test to see if a string is a digger id (by checking the length - needs work)

parses a string so it will match literally in a regular expression

var utils = require('digger-utils');
var match = '{[]}'; // this will not match as a RegExp 
var escaped = utils.escapeRegexp(match);
// escaped = \{\[\]\} 

returns a pure javascript object representing the passed HTTP req

var utils = require('digger-utils');
// GET /apples.html 
app.use(function(req, res, next){
    var json = utils.json_request(req);

Returns true is the passed argument is actually an array

Converts the given argument into an array (useful for 'arguments')

Returns true if the given object has no keys

Removes any field starting with an '_' from the given object

uses the extend module so we can deep extend objects

takes a list of containers and appends ones that find their parent in the list

var flat_list_of_containers = [...];
var tree_of_containers = utils.combine_tree_results(flat_list_of_containers);

A copy of node utils.inherits for inheriting classes

Returns true if running on node.js - false if on the browser

Takes 2 module names - one for node.js and one for the browser and requires the correct one