Utils library shared between the digger digger libraries
npm install digger-utilsSmall utils library shared between the digger.io and digger libraries
as a node module:
$ npm install digger-utils
or in the browser using browserify
``js
var utils = require('digger-utils');
var id = utils.diggerid();
// id = 95a4bdcc8dc1c7a16da87da7c4b07c38
`littleid
returns a random string of (chars) length
`js
var utils = require('digger-utils');
var id = utils.littleid();
// id = d0cd49
`
`js
var utils = require('digger-utils');
var match = '{[]}'; // this will not match as a RegExp
var escaped = utils.escapeRegexp(match);
// escaped = \{\[\]\}
`
`js
var utils = require('digger-utils');
// GET /apples.html
app.use(function(req, res, next){
var json = utils.json_request(req);
/*
{
method:'get',
url:'/apples.html'
}
*/
})
`
uses the extend module so we can deep extend objects
`js
var flat_list_of_containers = [...];
var tree_of_containers = utils.combine_tree_results(flat_list_of_containers);
``
MIT