Commits

Sean Wilkinson  committed 93fe86f

Separated NPM module as a Git submodule

  • Participants
  • Parent commits 9269e97

Comments (0)

Files changed (19)

+[submodule "src/npm-package"]
+	path = src/npm-package
+	url = https://github.com/qmachine/qm-nodejs.git

Submodule src/npm-package

+Subproject commit 05231e32217c72d22dcd7390043b53fea0e6cfd9

File src/npm-package/.npmignore

-#-  NPM configuration file
-
-#-  .npmignore ~~
-#                                                       ~~ (c) SRW, 18 Sep 2012
-
-.hgignore
-
-#-  vim:set syntax=gitconfig:

File src/npm-package/examples/client.js

-//- JavaScript source code
-
-//- client.js ~~
-//                                                      ~~ (c) SRW, 28 Jun 2012
-//                                                  ~~ last updated 12 Nov 2012
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Declarations
-
-    var qm;
-
- // Definitions
-
-    qm = require('lib/main');
-
- // Invocations
-
-    qm.launch_client({
-        hostname:   '127.0.0.1',
-        port:       8177
-    });
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/examples/roll-up.js

-//- JavaScript source code
-
-//- roll-up.js ~~
-//
-//  NOTE: This file isn't just an example -- it is also used as part of the
-//  QM project's build process :-)
-//
-//                                                      ~~ (c) SRW, 17 Dec 2012
-//                                                  ~~ last updated 21 Dec 2012
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Declarations
-
-    var directory, json_file;
-
- // Definitions
-
-    directory = (process.argv.length > 2) ? process.argv[2] : 'public_html';
-
-    json_file = (process.argv.length > 3) ? process.argv[3] : 'katamari.json';
-
- // Demonstration
-
-    require('../').roll_up(directory, json_file);
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/examples/service.js

-//- JavaScript source code
-
-//- service.js ~~
-//                                                      ~~ (c) SRW, 26 Sep 2012
-//                                                  ~~ last updated 15 May 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Declarations
-
-    var examples, qm;
-
- // Definitions
-
-    examples = {
-        max_http_sockets:   1000,
-        persistent_storage: {
-            avar_ttl:       60,
-            couch:          'http://127.0.0.1:5984/db',
-            gc_interval:    1,
-            mongo:          'mongodb://localhost:27017/qm',
-            postgres:       'postgres://localhost:5432/' + process.env.USER,
-            redis:          'redis://:@127.0.0.1:6379',
-            sqlite:         'qm.db'
-        },
-        trafficlog_storage: {
-            couch:          'http://127.0.0.1:5984/traffic',
-            mongo:          'mongodb://localhost:27017/qm'
-        },
-        worker_procs:       require('os').cpus().length
-    };
-
-    qm = require('lib/main');
-
- // Invocations
-
-    qm.launch_service({
-        enable_api_server:  true,
-        enable_CORS:        true,
-        enable_www_server:  true,
-        persistent_storage: {
-            avar_ttl:       60,
-            mongo:          examples.persistent_storage.mongo
-        },
-        trafficlog_storage: {
-            mongo:          examples.trafficlog_storage.mongo
-        },
-        worker_procs:       0
-    });
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/client.js

-//- JavaScript source code
-
-//- client.js ~~
-//                                                      ~~ (c) SRW, 25 Aug 2012
-//                                                  ~~ last updated 01 Apr 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 1, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
-    /*properties launch */
-
- // Out-of-scope definitions
-
-    exports.launch = function () {
-     // This function needs documentation.
-        throw new Error('The Node.js "native" client is under construction.');
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/configure.js

-//- JavaScript source code
-
-//- configure.js ~~
-//                                                      ~~ (c) SRW, 17 Dec 2012
-//                                                  ~~ last updated 01 Apr 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 2, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
-    /*properties exports, hasOwnProperty */
-
- // Out-of-scope definitions
-
-    module.exports = function configure(user_input, default_values) {
-     // This function needs documentation.
-        if ((user_input instanceof Object) === false) {
-            user_input = {};
-        }
-        var key, y;
-        y = (default_values instanceof Array) ? [] : user_input;
-        for (key in default_values) {
-            if (default_values.hasOwnProperty(key)) {
-                if (default_values[key] instanceof Object) {
-                    y[key] = configure(user_input[key], default_values[key]);
-                } else if (user_input.hasOwnProperty(key)) {
-                    y[key] = user_input[key];
-                } else {
-                    y[key] = default_values[key];
-                }
-            }
-        }
-        return y;
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/couch-api-ddoc.js

-//- JavaScript source code
-
-//- couch-api-ddoc.js ~~
-//                                                      ~~ (c) SRW, 23 Oct 2012
-//                                                  ~~ last updated 20 May 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*global exports: false, getRow: false, send: false */
-
-    /*jshint maxparams: 2, quotmark: single, strict: true */
-
-    /*jslint couch: true, indent: 4, maxlen: 80, nomen: true, unparam: true */
-
-    /*properties
-        'as-array', body, box_status, 'Content-Type', data, _deleted, exp_date,
-        hasOwnProperty, headers, _id, jobs, key, lists, map, outdated, parse,
-        _rev, shows, split, stringify, updates, upsert, value, views
-    */
-
- // Out-of-scope definitions
-
-    exports._id = '_design/app';
-
-    exports.lists = {
-        'as-array': function () {
-         // This function needs documentation.
-            var first, row;
-            first = true;
-            row = getRow();
-            send('[');
-            while (row !== null) {
-                if (first === true) {
-                    first = false;
-                    send(JSON.stringify(row.value));
-                } else {
-                    send(',' + JSON.stringify(row.value));
-                }
-                row = getRow();
-            }
-            send(']');
-            return;
-        }
-    };
-
-    exports.shows = {
-        data: function (doc) {
-         // This function needs documentation.
-            var response;
-            response = {
-                headers: {
-                    'Content-Type': 'application/json'
-                }
-            };
-            if ((doc === null) || (doc.hasOwnProperty('body') === false)) {
-             // If a document with the requested docid doesn't exist, return a
-             // plain old JSON object to avoid giving [evil] robots any useful
-             // information via 404s.
-                response.body = '{}';
-            } else {
-                response.body = doc.body;
-            }
-            return response;
-        }
-    };
-
-    exports.updates = {
-     // NOTE: Do not out-clever yourself here! You _can_ add the CORS
-     // headers in this function, but if you're already doing it inside an
-     // external webserver like Nginx or Node.js, it will cause CORS _not_
-     // to work.
-        upsert: function (doc, req) {
-         // This function needs documentation.
-            var key, newDoc, response;
-            newDoc = JSON.parse(req.body);
-            response = {
-                headers: {
-                    'Content-Type': 'text/plain'
-                },
-                body: ''
-            };
-            if (doc === null) {
-             // We are inserting a new document.
-                return [newDoc, response];
-            }
-         // We are updating the existing document.
-            for (key in newDoc) {
-                if (newDoc.hasOwnProperty(key)) {
-                    doc[key] = newDoc[key];
-                }
-            }
-            return [doc, response];
-        }
-    };
-
-    exports.views = {
-        jobs: {
-            map: function (doc) {
-             // This function needs documentation.
-                var flag;
-                flag = ((doc.hasOwnProperty('box_status'))  &&
-                        (doc.hasOwnProperty('key')));
-                if (flag === true) {
-                    emit(doc.box_status.split('&'), doc.key);
-                }
-                return;
-            }
-        },
-        outdated: {
-            map: function (doc) {
-             // This function outputs a JSON array that I can modify slightly
-             // and POST back to Couch via the Bulk Documents API in order to
-             // delete all documents that are past their expiration dates.
-                if (doc.hasOwnProperty('exp_date')) {
-                    emit(doc.exp_date, {
-                        _id: doc._id,
-                        _rev: doc._rev,
-                        _deleted: true
-                    });
-                }
-                return;
-            }
-        }
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/couch-log-ddoc.js

-//- JavaScript source code
-
-//- couch-log-ddoc.js ~~
-//                                                      ~~ (c) SRW, 31 Mar 2013
-//                                                  ~~ last updated 20 May 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*global exports: false, getRow: false, send: false, sum: false */
-
-    /*jshint maxparams: 2, quotmark: single, strict: true */
-
-    /*jslint couch: true, indent: 4, maxlen: 80, nomen: true, unparam: true */
-
-    /*properties
-        'as-array', box_frequency, hasOwnProperty, _id, identity, ip,
-        ip_frequency, ips, lists, map, method, reduce, replace, shows, slice,
-        split, stringify, timestamp, updates, url, value, views
-    */
-
- // Out-of-scope definitions
-
-    exports._id = '_design/app';
-
-    exports.lists = {
-        'as-array': function () {
-         // This function can be useful for dumping the entire contents of the
-         // database for export into another database:
-         //
-         //     $ curl -o couch-dump.json \
-         //         localhost:5984/traffic/_design/app/_list/as-array/identity
-         //
-            var first, row;
-            first = true;
-            row = getRow();
-            send('[');
-            while (row !== null) {
-                if (first === true) {
-                    first = false;
-                    send(JSON.stringify(row.value));
-                } else {
-                    send(',' + JSON.stringify(row.value));
-                }
-                row = getRow();
-            }
-            send(']');
-            return;
-        }
-    };
-
-    exports.shows = {};
-
-    exports.updates = {};
-
-    exports.views = {
-
-        box_frequency: {
-            map: function (doc) {
-             // This function needs documentation.
-                var pattern;
-                if (doc.hasOwnProperty('url')) {
-                    pattern = /^\/box\/([\w\-]+)\?/;
-                    doc.url.replace(pattern, function (match, box) {
-                     // This function needs documentation.
-                        emit(box, 1);
-                        return;
-                    });
-                    return;
-                }
-                return;
-            },
-            reduce: function (keys, values) {
-             // This function needs documentation.
-                return sum(values);
-            }
-        },
-
-        identity: {
-            map: function (doc) {
-             // This function needs documentation.
-                if (doc._id.slice(0, 8) !== '_design/') {
-                    emit(null, {
-                        ip:         doc.ip,
-                        method:     doc.method,
-                        timestamp:  doc.timestamp,
-                        url:        doc.url
-                    });
-                }
-                return;
-            }
-        },
-
-        ip_frequency: {
-            map: function (doc) {
-             // This function needs documentation.
-                if (doc.hasOwnProperty('ip')) {
-                    emit(doc.ip.split(', ')[0], 1);
-                }
-                return;
-            },
-            reduce: function (keys, values) {
-             // This function needs documentation.
-                return sum(values);
-            }
-        }
-
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/defs-couch.js

-//- JavaScript source code
-
-//- defs-couch.js ~~
-//
-//  NOTE: I need to experiment with `require('https').globalAgent.maxSockets`!
-//
-//                                                      ~~ (c) SRW, 25 Sep 2012
-//                                                  ~~ last updated 20 May 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 3, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true, nomen: true */
-
-    /*properties
-        api, avar_ttl, body, box_status, ceil, collect_garbage, 'Content-Type',
-        couch, create, end, error, exp_date, get_box_key, get_box_status,
-        headers, _id, isMaster, join, key, keys, length, log, method, now, on,
-        parse, post_box_key, protocol, push, request, _rev, statusCode,
-        stringify, toString, trim
-    */
-
- // Declarations
-
-    var cluster, create_db, http, https, stringify, upload_ddoc, url;
-
- // Definitions
-
-    cluster = require('cluster');
-
-    create_db = function (conn, callback) {
-     // This function needs documentation.
-        var options, protocol, req;
-        options = Object.create(conn);
-        options.method = 'PUT';
-        protocol = (conn.protocol === 'http:') ? http : https;
-        req = protocol.request(options, function (response) {
-         // This function needs documentation.
-            var temp = [];
-            response.on('data', function (chunk) {
-             // This function needs documentation.
-                temp.push(chunk.toString());
-                return;
-            });
-            response.on('end', function () {
-             // This function needs documentation.
-                return callback(null, temp.join(''));
-            });
-            return;
-        });
-        req.on('error', callback);
-        req.end();
-        return;
-    };
-
-    http = require('http');
-
-    https = require('https');
-
-    stringify = function (obj, keys) {
-     // This function only exists to serialize the design document cleanly. It
-     // doesn't demand the level of sophistication that the browser client's
-     // `serialize` method does because we know that this function will run in
-     // Node.js and that all functions will be serializable :-)
-        /*jslint unparam: true */
-        var i, n, temp;
-        temp = {};
-        n = keys.length;
-        for (i = 0; i < n; i += 1) {
-            temp[keys[i]] = obj[keys[i]];
-        }
-        return JSON.stringify(temp, function (key, val) {
-         // See the explanation above ;-)
-            if ((typeof val === 'function') && (val instanceof Function)) {
-                return val.toString();
-            }
-            return val;
-        });
-    };
-
-    upload_ddoc = function (file, app_url, callback) {
-     // This function needs documentation.
-        var opts, protocol, req;
-        opts = url.parse(app_url);
-        opts.method = 'GET';
-        protocol = (opts.protocol === 'http:') ? http : https;
-        req = protocol.request(opts, function (response) {
-         // This function needs documentation.
-            var temp = [];
-            response.on('data', function (chunk) {
-             // This function needs documentation.
-                temp.push(chunk.toString());
-                return;
-            });
-            response.on('end', function () {
-             // This function needs documentation.
-                var new_dd, $new_dd, old_dd, $old_dd, opts2, req2;
-                new_dd = require(file);
-                $old_dd = temp.join('');
-                if (response.statusCode === 200) {
-                    old_dd = JSON.parse($old_dd);
-                    new_dd = require(file);
-                    new_dd._id = old_dd._id;
-                    new_dd._rev = old_dd._rev;
-                    $new_dd = stringify(new_dd, Object.keys(old_dd));
-                    $old_dd = stringify(old_dd, Object.keys(old_dd));
-                    if ($new_dd === $old_dd) {
-                        return callback(null, 'Design document unchanged.');
-                    }
-                } else {
-                    $new_dd = stringify(new_dd, Object.keys(new_dd));
-                }
-                console.log('Uploading a new design document ...');
-                opts2 = Object.create(opts);
-                opts2.method = 'PUT';
-                req2 = protocol.request(opts2, function (response) {
-                 // This function needs documentation.
-                    var temp = [];
-                    response.on('data', function (chunk) {
-                     // This function needs documentation.
-                        temp.push(chunk.toString());
-                        return;
-                    });
-                    response.on('end', function () {
-                     // This function needs documentation.
-                        return callback(null, temp.join(''));
-                    });
-                    return;
-                });
-                req2.on('error', callback);
-                req2.end($new_dd);
-                return;
-            });
-            return;
-        });
-        req.on('error', callback);
-        req.end();
-        return;
-    };
-
-    url = require('url');
-
- // Out-of-scope definitions
-
-    exports.api = function (options) {
-     // This function needs documentation.
-
-        var app_url, collect_garbage, conn, exp_date, get_box_key,
-            get_box_status, protocol, post_box_key;
-
-        app_url = options.couch + '/_design/app/';
-
-        collect_garbage = function () {
-         // This function removes old documents from the "db" database, but it
-         // does not trigger compaction. The reason is simple -- automatic
-         // compaction is a standard feature of CouchDB 1.2 and later. To read
-         // more about configuring your couch, see http://goo.gl/V634R.
-            var callback, opts, req, target;
-            callback = function (err) {
-             // This function needs documentation.
-                if (err !== null) {
-                    console.error('Error:', err);
-                    return;
-                }
-                console.log('Finished collecting garbage.');
-                return;
-            };
-            target = app_url + '_list/as-array/outdated?startkey=0&endkey=' +
-                    Math.ceil(Date.now() / 1000);
-            opts = url.parse(target);
-            opts.method = 'GET';
-            req = protocol.request(opts, function (res) {
-             // This function needs documentation.
-                var temp = [];
-                res.on('data', function (chunk) {
-                 // This function needs documentation.
-                    temp.push(chunk.toString());
-                    return;
-                });
-                res.on('end', function () {
-                 // This function needs documentation.
-                    var body, opts2, req2;
-                    body = temp.join('');
-                    if (body === '[]') {
-                        return callback(null);
-                    }
-                    opts2 = url.parse(options.couch + '/_bulk_docs');
-                    opts2.headers = {'Content-Type': 'application/json'};
-                    opts2.method = 'POST';
-                    req2 = protocol.request(opts2, function () {
-                     // This function omits named parameters because it omits
-                     // them anyway.
-                        return callback(null);
-                    });
-                    req2.on('error', callback);
-                    req2.end('{"docs":' + body + '}');
-                    return;
-                });
-                return;
-            });
-            req.on('error', callback);
-            req.end();
-            return;
-        };
-
-        conn = url.parse(options.couch);
-
-        exp_date = function () {
-         // This function needs documentation.
-            return Math.ceil((Date.now() / 1000) + options.avar_ttl);
-        };
-
-        get_box_key = function (params, callback) {
-         // This function needs documentation.
-            var opts, req, target;
-            target = app_url + '_show/data/' + params[0] + '&' + params[1];
-            opts = url.parse(target);
-            opts.method = 'GET';
-            req = protocol.request(opts, function (res) {
-             // This function needs documentation.
-                var temp = [];
-                res.on('data', function (chunk) {
-                 // This function needs documentation.
-                    temp.push(chunk.toString());
-                    return;
-                });
-                res.on('end', function () {
-                 // This function needs documentation.
-                    return callback(null, temp.join(''));
-                });
-                return;
-            });
-            req.on('error', callback);
-            req.end();
-            return;
-        };
-
-        get_box_status = function (params, callback) {
-         // This function needs documentation.
-            var opts, req, target;
-            target = app_url + '_list/as-array/jobs?key=["' +  params[0] +
-                    '","' + params[1] + '"]';
-            opts = url.parse(target);
-            opts.method = 'GET';
-            req = protocol.request(opts, function (res) {
-             // This function needs documentation.
-                var temp = [];
-                res.on('data', function (chunk) {
-                 // This function needs documentation.
-                    temp.push(chunk.toString());
-                    return;
-                });
-                res.on('end', function () {
-                 // This function needs documentation.
-                    return callback(null, JSON.parse(temp.join('')));
-                });
-                return;
-            });
-            req.on('error', callback);
-            req.end();
-            return;
-        };
-
-        protocol = (conn.protocol === 'http:') ? http : https;
-
-        post_box_key = function (params, callback) {
-         // This function needs documentation.
-            var obj, opts, req;
-            if (params.length === 4) {
-                obj = {
-                    _id:        params[0] + '&' + params[1],
-                    body:       params[3],
-                    box_status: params[0] + '&' + params[2],
-                    exp_date:   exp_date(),
-                    key:        params[1]
-                };
-            } else {
-                obj = {
-                    _id:        params[0] + '&' + params[1],
-                    body:       params[2],
-                    exp_date:   exp_date(),
-                    key:        params[1]
-                };
-            }
-            opts = url.parse(app_url + '_update/upsert/' + obj._id);
-            opts.headers = {'Content-Type': 'application/json'};
-            opts.method = 'POST';
-            req = protocol.request(opts, function (res) {
-             // This function needs documentation.
-                res.on('data', function () {
-                 // This function is empty, but it is necessary due to changes
-                 // in the way that the streaming API works in Node.js, as of
-                 // version 0.10 and later.
-                    return;
-                });
-                res.on('end', function () {
-                 // This function needs documentation.
-                    if ((res.statusCode !== 201) && (res.statusCode !== 202)) {
-                     // Ordinarily, we want a 201, but batch mode returns an
-                     // "HTTP 202: Accepted" response, and Cloudant's BigCouch
-                     // seems to use batch mode sometimes. All other status
-                     // codes indicate an error.
-                        return callback(res.statusCode);
-                    }
-                    return callback(null);
-                });
-                return;
-            });
-            req.on('error', callback);
-            req.end(JSON.stringify(obj));
-            return;
-        };
-
-        if (cluster.isMaster) {
-            create_db(conn, function (err, response) {
-             // This function needs documentation.
-                if (err !== null) {
-                    console.error('Error:', err);
-                }
-                upload_ddoc('./couch-api-ddoc', app_url, function (err) {
-                 // This function also accepts a second argument that contains
-                 // the "results" of the query, but because I don't use it, I
-                 // have omitted it to avoid irritating JSLint et al.
-                    if (err !== null) {
-                        console.error('Error:', err);
-                    }
-                    console.log(response.trim());
-                    console.log('API: CouchDB storage is ready.');
-                    return;
-                });
-                return;
-            });
-        }
-        return {
-            collect_garbage: collect_garbage,
-            get_box_key: get_box_key,
-            get_box_status: get_box_status,
-            post_box_key: post_box_key
-        };
-    };
-
-    exports.log = function (options) {
-     // This function needs documentation.
-        var app_url, conn, protocol;
-        app_url = options.couch + '/_design/app/';
-        conn = url.parse(options.couch);
-        protocol = (conn.protocol === 'http:') ? http : https;
-        if (cluster.isMaster) {
-            create_db(conn, function (err, response) {
-             // This function needs documentation.
-                if (err !== null) {
-                    console.error('Error:', err);
-                }
-                upload_ddoc('./couch-log-ddoc', app_url, function (err) {
-                 // This function also accepts a second argument that contains
-                 // the "results" of the query, but because I don't use it, I
-                 // have omitted it to avoid irritating JSLint et al.
-                    if (err !== null) {
-                        console.error('Error:', err);
-                    }
-                    console.log(response.trim());
-                    console.log('LOG: CouchDB storage is ready.');
-                    return;
-                });
-                return;
-            });
-        }
-        return function (obj) {
-         // This function needs documentation.
-            var req;
-            conn.headers = {'Content-Type': 'application/json'};
-            conn.method = 'POST';
-            req = protocol.request(conn, function (res) {
-             // This function needs documentation.
-                res.on('data', function () {
-                 // This function is empty, but it is necessary due to changes
-                 // in the way that the streaming API works in Node.js, as of
-                 // version 0.10 and later.
-                    return;
-                });
-                res.on('end', function () {
-                 // See the explanation given above.
-                    return;
-                });
-                return;
-            });
-            req.on('error', function (message) {
-             // This function needs documentation.
-                console.error('Error:', message);
-                return;
-            });
-            req.end(JSON.stringify(obj));
-            return;
-        };
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/defs-mongo.js

-//- JavaScript source code
-
-//- defs-mongo.js ~~
-//
-//  These definitions are getting a lot more attention now :-)
-//
-//                                                      ~~ (c) SRW, 05 Nov 2012
-//                                                  ~~ last updated 22 Jun 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 2, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true, nomen: true */
-
-    /*properties
-        _id, api, avar_ttl, body, box_status, collect_garbage, collection,
-        connect, ensureIndex, error, exp_date, expireAfterSeconds, find,
-        findOne, get_box_key, get_box_status, isWorker, key, length, log,
-        mongo, MongoClient, on, post_box_key, push, safe, save, stream, update,
-        upsert
-    */
-
- // Declarations
-
-    var cluster, mongo;
-
- // Definitions
-
-    cluster = require('cluster');
-
-    mongo = require('mongodb').MongoClient;
-
- // Out-of-scope definitions
-
-    exports.api = function (options) {
-     // This function needs documentation, but as far as connection pooling is
-     // concerned, my strategy is justified by the post on Stack Overflow at
-     // http://stackoverflow.com/a/14464750.
-
-        var collect_garbage, db, get_box_key, get_box_status, post_box_key;
-
-        collect_garbage = function () {
-         // This function isn't even needed anymore, because these definitions
-         // are now taking advantage of TTL collections :-)
-            console.log('(fake garbage collection)');
-            return;
-        };
-
-        get_box_key = function (params, callback) {
-         // This function needs documentation.
-            var pattern = {_id: params[0] + '&' + params[1]};
-            db.collection('avars').findOne(pattern, function (err, item) {
-             // This function needs documentation.
-                if (err !== null) {
-                    return callback(err, undefined);
-                }
-                return callback(null, (item === null) ? undefined : item.body);
-            });
-            return;
-        };
-
-        get_box_status = function (params, callback) {
-         // This function needs documentation.
-            var items, pattern, stream;
-            items = [];
-            pattern = {box_status: params[0] + '&' + params[1]};
-            stream = db.collection('avars').find(pattern).stream();
-            stream.on('close', function () {
-             // This function needs documentation.
-                return callback(null, items);
-            });
-            stream.on('data', function (item) {
-             // This function needs documentation.
-                items.push(item.key);
-                return;
-            });
-            stream.on('error', callback);
-            return;
-        };
-
-        post_box_key = function (params, callback) {
-         // This function needs documentation.
-            var obj, options, spec;
-            if (params.length === 4) {
-                obj = {
-                    _id:        params[0] + '&' + params[1],
-                    body:       params[3],
-                    box_status: params[0] + '&' + params[2],
-                    exp_date:   new Date(),
-                    key:        params[1]
-                };
-            } else {
-                obj = {
-                    _id:        params[0] + '&' + params[1],
-                    body:       params[2],
-                    exp_date:   new Date(),
-                    key:        params[1]
-                };
-            }
-            options = {safe: true, upsert: true};
-            spec = {_id: params[0] + '&' + params[1]};
-            db.collection('avars').update(spec, obj, options, callback);
-            return;
-        };
-
-        mongo.connect(options.mongo, function (err, db_handle) {
-         // This function is a LOT simpler than what I had before!
-            if (err !== null) {
-                throw err;
-            }
-            db = db_handle;
-            if (cluster.isWorker) {
-                return;
-            }
-            db.collection('avars').ensureIndex('exp_date', {
-                expireAfterSeconds: options.avar_ttl
-            }, function (err) {
-             // This function needs documentation.
-                if (err !== null) {
-                    throw err;
-                }
-                console.log('API: MongoDB storage is ready.');
-                return;
-            });
-            return;
-        });
-
-        return {
-            collect_garbage: collect_garbage,
-            get_box_key: get_box_key,
-            get_box_status: get_box_status,
-            post_box_key: post_box_key
-        };
-    };
-
-    exports.log = function (options) {
-     // This function needs documentation.
-        var db;
-        mongo.connect(options.mongo, function (err, db_handle) {
-         // This function needs documentation.
-            if (err !== null) {
-                throw err;
-            }
-            db = db_handle;
-            return;
-        });
-        return function (obj) {
-         // This function needs documentation.
-            db.collection('traffic').save(obj, function (err) {
-             // This function needs documentation.
-                if (err !== null) {
-                    console.error('Error:', err);
-                }
-                return;
-            });
-            return;
-        };
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/defs-postgres.js

-//- JavaScript source code
-
-//- defs-postgres.js ~~
-//
-//  NOTE: SQL is _not_ a particular strength of mine, and I appreciate input!
-//
-//                                                      ~~ (c) SRW, 25 Sep 2012
-//                                                  ~~ last updated 20 May 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 3, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Declarations
-
-    var cluster, pg;
-
- // Definitions
-
-    cluster = require('cluster');
-
-    pg = require('pg');                 //- or, use `require('pg').native` ...
-
- // Out-of-scope definitions
-
-    module.exports = function (options) {
-     // This function needs documentation.
-
-        var collect_garbage, connection_string, exp_date, get_box_key,
-            get_box_status, post_box_key;
-
-        collect_garbage = function () {
-         // This function needs documentation.
-            pg.connect(connection_string, function (err, client, done) {
-             // This function needs documentation.
-                if (err !== null) {
-                    console.error('Error:', err);
-                    done();
-                    return;
-                }
-                var now, sql;
-                now = Math.ceil(Date.now() / 1000);
-                sql = 'DELETE FROM avars WHERE (exp_date < $1)';
-                client.query(sql, [now], function (err) {
-                 // This function n needs documentation.
-                    if (err !== null) {
-                        console.error('Error:', err);
-                    } else {
-                        console.log('Finished collecting garbage.');
-                    }
-                    done();
-                    return;
-                });
-                return;
-            });
-            return;
-        };
-
-        connection_string = options.postgres;
-
-        exp_date = function () {
-         // This function needs documentation.
-            return Math.ceil((Date.now() / 1000) + options.avar_ttl);
-        };
-
-        get_box_key = function (params, callback) {
-         // This function needs documentation.
-            pg.connect(connection_string, function (err, client, done) {
-             // This function needs documentation.
-                if (err !== null) {
-                    done();
-                    return callback(err, undefined);
-                }
-                var x = 'SELECT body FROM avars WHERE box_key = $1';
-                client.query(x, [params.join('&')], function (err, results) {
-                 // This function needs documentation.
-                    done();
-                    if (err !== null) {
-                        return callback(err, undefined);
-                    }
-                    if (results.rows.length < 1) {
-                        return callback(null, undefined);
-                    }
-                    return callback(null, results.rows[0].body);
-                });
-                return;
-            });
-            return;
-        };
-
-        get_box_status = function (params, callback) {
-         // This function needs documentation.
-            pg.connect(connection_string, function (err, client, done) {
-             // This function needs documentation.
-                if (err !== null) {
-                    done();
-                    return callback(err, undefined);
-                }
-                var x = 'SELECT key FROM avars WHERE box_status = $1';
-                client.query(x, [params.join('&')], function (err, results) {
-                 // This function needs documentation.
-                    done();
-                    if (err !== null) {
-                        return callback(err, undefined);
-                    }
-                    var y = (results === undefined) ? {rows: []} : results;
-                    return callback(null, y.rows.map(function (row) {
-                     // This function needs documentation.
-                        return row.key;
-                    }));
-                });
-                return;
-            });
-            return;
-        };
-
-        post_box_key = function (params, callback) {
-         // This function needs documentation.
-            pg.connect(connection_string, function (err, client, done) {
-             // This function needs documentation.
-                if (err !== null) {
-                    done();
-                    return callback(err, undefined);
-                }
-                var args, sql;
-                if (params.length === 4) {
-                    args = [
-                        params[3],
-                        params[0] + '&' + params[1],
-                        params[0] + '&' + params[2],
-                        exp_date(),
-                        params[1]
-                    ];
-                    sql = 'SELECT upsert_task($1, $2, $3, $4, $5)';
-                } else {
-                    args = [
-                        params[2],
-                        params[0] + '&' + params[1],
-                        exp_date()
-                    ];
-                    sql = 'SELECT upsert_avar($1, $2, $3)';
-                }
-                client.query(sql, args, function (err, results) {
-                 // This function needs documentation.
-                    done();
-                    return callback(err, results);
-                });
-                return;
-            });
-            return;
-        };
-
-        if (cluster.isMaster) {
-            pg.connect(connection_string, function (err, client, done) {
-             // This function needs documentation.
-                if (err !== null) {
-                    done();
-                    throw err;
-                }
-                var lines;
-                lines = [
-                    'CREATE TABLE IF NOT EXISTS avars (',
-                    '   body TEXT NOT NULL,',
-                    '   box_key TEXT NOT NULL,',
-                    '   box_status TEXT,',
-                    '   exp_date INTEGER NOT NULL,',
-                    '   key TEXT,',     //- this doesn't need to be "NOT NULL"
-                    '   PRIMARY KEY (box_key)',
-                    ');',
-                    'CREATE OR REPLACE FUNCTION upsert_avar' +
-                        '(b2 TEXT, bk2 TEXT, ed2 INTEGER) RETURNS VOID AS',
-                    '$$',
-                    'BEGIN',
-                    '   LOOP',
-                    '       UPDATE avars',
-                    '           SET body = b2,' +
-                        '           box_status = NULL,' +
-                        '           exp_date = ed2,' +
-                        '           key = NULL',
-                    '           WHERE box_key = bk2;',
-                    '       IF found THEN',
-                    '           RETURN;',
-                    '       END IF;',
-                    '       BEGIN',
-                    '           INSERT INTO avars (body, box_key, exp_date)',
-                    '               VALUES (b2, bk2, ed2);',
-                    '           RETURN;',
-                    '       EXCEPTION WHEN unique_violation THEN',
-                    '       END;',
-                    '   END LOOP;',
-                    'END;',
-                    '$$',
-                    'LANGUAGE plpgsql;',
-                    'CREATE OR REPLACE FUNCTION upsert_task' +
-                        '(b2 TEXT, bk2 TEXT, bs2 TEXT, ed2 INTEGER, k2 TEXT)' +
-                        'RETURNS VOID AS',
-                    '$$',
-                    'BEGIN',
-                    '   LOOP',
-                    '       UPDATE avars',
-                    '           SET body = b2,' +
-                        '           box_status = bs2,' +
-                        '           exp_date = ed2,' +
-                        '           key = k2',
-                    '           WHERE box_key = bk2;',
-                    '       IF found THEN',
-                    '           RETURN;',
-                    '       END IF;',
-                    '       BEGIN',
-                    '           INSERT INTO avars ' +
-                        '           (body, box_key, box_status, exp_date, key)',
-                    '               VALUES (b2, bk2, bs2, ed2, k2);',
-                    '           RETURN;',
-                    '       EXCEPTION WHEN unique_violation THEN',
-                    '       END;',
-                    '   END LOOP;',
-                    'END;',
-                    '$$',
-                    'LANGUAGE plpgsql;'
-                ];
-                client.query(lines.join('\n'), function (err) {
-                 // This function also accepts a second argument that contains
-                 // the "results" of the query, but because I don't use it, I
-                 // have omitted it to avoid irritating JSLint et al.
-                    done();
-                    if (err !== null) {
-                        throw err;
-                    }
-                    console.log('API: Postgres storage is ready.');
-                    return;
-                });
-                return;
-            });
-        }
-
-        return {
-            collect_garbage: collect_garbage,
-            get_box_key: get_box_key,
-            get_box_status: get_box_status,
-            post_box_key: post_box_key
-        };
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/defs-redis.js

-//- JavaScript source code
-
-//- defs-redis.js ~~
-//
-//  The first step here was just to get things running with plain old arrays in
-//  JavaScript, and I accomplished that. The next step is to jettison anything
-//  that hinders performance, since it's downright sinful to choose a platform
-//  like Node.js + Redis and then squander cycles needlessly ...
-//
-//                                                      ~~ (c) SRW, 23 Nov 2012
-//                                                  ~~ last updated 20 May 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 2, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Declarations
-
-    var cluster, redis, url;
-
- // Definitions
-
-    cluster = require('cluster');
-
-    redis = require('redis');
-
-    url = require('url');
-
- // Out-of-scope definitions
-
-    module.exports = function (options) {
-     // This function needs documentation.
-        var collect_garbage, conn, db, exp_date, get_box_key, get_box_status,
-            post_box_key;
-
-        collect_garbage = function () {
-         // This function needs documentation.
-            var remaining, seek_and_destroy;
-            seek_and_destroy = function (queue) {
-             // This function needs documentation.
-                var box = queue.replace(/^\$\:([\w\-]+)[&][\w\-]+/, '$1');
-                db.smembers(queue, function (err, response) {
-                 // This function needs documentation.
-                    if (err !== null) {
-                        console.error('Error:', err);
-                        return;
-                    }
-                    var callback, n;
-                    callback = function () {
-                     // This function needs documentation.
-                        n -= 1;
-                        if (n === 0) {
-                            remaining -= 1;
-                            if (remaining === 0) {
-                                console.log('Finished collecting garbage.');
-                            }
-                        }
-                        return;
-                    };
-                    n = response.length;
-                    response.forEach(function (key) {
-                     // This function needs documentation.
-                        db.exists(box + '&' + key, function (err, response) {
-                         // This function needs documentation.
-                            if (err !== null) {
-                                console.error('Error:', err);
-                            }
-                            if (response === 0) {
-                                db.srem(queue, key, function (err) {
-                                 // This function accepts a second argument,
-                                 // but I have omitted it because it irritates
-                                 // JSLint et al. otherwise.
-                                    if (err !== null) {
-                                        console.error('Error:', err);
-                                    }
-                                    return callback();
-                                });
-                            } else {
-                                callback();
-                            }
-                            return;
-                        });
-                        return;
-                    });
-                    if (n === 0) {
-                        callback();
-                    }
-                    return;
-                });
-                return;
-            };
-            db.keys('$:*', function (err, queues) {
-             // This function needs documentation.
-                if (err !== null) {
-                    console.error('Error:', err);
-                    return;
-                }
-                remaining = queues.length;
-                queues.forEach(seek_and_destroy);
-                if (remaining === 0) {
-                    console.log('Finished collecting garbage.');
-                }
-                return;
-            });
-            return;
-        };
-
-        conn = url.parse(options.redis);
-
-        db = redis.createClient(conn.port, conn.hostname, {
-         // For more information, see http://git.io/PRZ7Bw .
-            detect_buffers: false,
-            enable_offline_queue: true,
-            no_ready_check: true,
-            parser: 'hiredis',
-            return_buffers: false,
-            socket_nodelay: true
-        });
-
-        exp_date = function () {
-         // This function needs documentation.
-            return Math.ceil(options.avar_ttl);
-        };
-
-        get_box_key = function (params, callback) {
-         // This function needs documentation.
-            db.hget(params[0] + '&' + params[1], 'body', callback);
-            return;
-        };
-
-        get_box_status = function (params, callback) {
-         // This function needs documentation.
-            db.smembers('$:' + params[0] + '&' + params[1], callback);
-            return;
-        };
-
-        post_box_key = function (params, callback) {
-         // This function needs documentation.
-            var body, box, key, status;
-            if (params.length === 4) {
-                body = params[3];
-                status = params[2];
-            } else {
-                body = params[2];
-            }
-            box = params[0];
-            key = params[1];
-            db.hget(box + '&' + key, 'status', function (err, res) {
-             // This function needs documentation.
-                if (err !== null) {
-                    return callback(err, res);
-                }
-                var multi, set1, set2, updated;
-                multi = db.multi();
-                updated = {body: body};
-                if (res !== null) {
-                    set1 = '$:' + box + '&' + res;
-                    multi.srem(set1, key);
-                }
-                if (status !== undefined) {
-                    updated.status = status;
-                    set2 = '$:' + box + '&' + updated.status;
-                    multi.sadd(set2, key);
-                }
-                multi.hmset(box + '&' + key, updated);
-                multi.expire(box + '&' + key, exp_date());
-                multi.exec(callback);
-                return;
-            });
-            return;
-        };
-
-        db.auth(conn.auth.split(':')[1]);
-
-        db.on('connect', function () {
-         // This function needs documentation.
-            if (cluster.isMaster) {
-                console.log('API: Redis storage is ready.');
-            }
-            return;
-        });
-
-        db.on('end', function () {
-         // This function needs documentation.
-            console.log('(Redis client closed)');
-            return;
-        });
-
-        db.on('error', function (message) {
-         // This function needs documentation.
-            console.error('Error:', message);
-            return;
-        });
-
-        process.on('exit', function () {
-         // This function needs documentation.
-            db.quit();
-            console.log('(Redis client released)');
-            return;
-        });
-
-        return {
-            collect_garbage: collect_garbage,
-            get_box_key: get_box_key,
-            get_box_status: get_box_status,
-            post_box_key: post_box_key
-        };
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/defs-sqlite.js

-//- JavaScript source code
-
-//- defs-sqlite.js ~~
-//
-//  NOTE: SQL is _not_ a particular strength of mine, and I appreciate input!
-//
-//                                                      ~~ (c) SRW, 25 Sep 2012
-//                                                  ~~ last updated 25 Apr 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 2, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Declarations
-
-    var cluster, sqlite;
-
- // Definitions
-
-    cluster = require('cluster');
-
-    sqlite = require('sqlite3');
-
- // Out-of-scope definitions
-
-    module.exports = function (options) {
-     // This function needs documentation.
-
-        var collect_garbage, db, exp_date, get_box_key, get_box_status,
-            post_box_key;
-
-        collect_garbage = function () {
-         // This function needs documentation.
-            var lines, values;
-            lines = 'DELETE FROM avars WHERE (exp_date < $now)';
-            values = {
-                $now: Math.ceil(Date.now() / 1000)
-            };
-            db.run(lines, values, function (err) {
-             // This function needs documentation.
-                if (err !== null) {
-                    console.error('Error:', err);
-                    return;
-                }
-                console.log('Finished collecting garbage.');
-                return;
-            });
-            return;
-        };
-
-        db = new sqlite.cached.Database(options.sqlite, function (err) {
-         // This function needs documentation.
-            if (err !== null) {
-                throw err;
-            }
-            if (cluster.isWorker) {
-                return;
-            }
-            var lines;
-            lines = [
-                'CREATE TABLE IF NOT EXISTS avars (',
-                '   body TEXT NOT NULL,',
-                '   box_key TEXT NOT NULL,',
-                '   box_status TEXT,',
-                '   exp_date INTEGER NOT NULL,',
-                '   key TEXT,',         //- this doesn't need to be "NOT NULL"
-                '   PRIMARY KEY (box_key)',
-                ')'
-            ];
-            db.run(lines.join('\n'), function (err) {
-             // This function needs documentation.
-                if (err !== null) {
-                    throw err;
-                }
-                console.log('API: SQLite storage is ready.');
-                return;
-            });
-            return;
-        });
-
-        exp_date = function () {
-         // This function needs documentation.
-            return Math.ceil((Date.now() / 1000) + options.avar_ttl);
-        };
-
-        get_box_key = function (params, callback) {
-         // This function needs documentation.
-            var box_key, sql;
-            box_key = params[0] + '&' + params[1];
-            sql = 'SELECT body FROM avars WHERE box_key = $box_key';
-            db.get(sql, {$box_key: box_key}, function (err, row) {
-             // This function needs documentation.
-                if (err !== null) {
-                    if (err.errno === 5) {
-                        process.nextTick(function () {
-                         // This function needs documentation.
-                            return get_box_key(params, callback);
-                        });
-                        return;
-                    }
-                    return callback(err, row);
-                }
-                return callback(null, (row === undefined) ? row : row.body);
-            });
-            return;
-        };
-
-        get_box_status = function (params, callback) {
-         // This function needs documentation.
-            var box_status, sql;
-            box_status = params[0] + '&' + params[1];
-            sql = 'SELECT key FROM avars WHERE box_status = $box_status';
-            db.all(sql, {$box_status: box_status}, function (err, rows) {
-             // This function needs documentation.
-                if (err !== null) {
-                    if (err.errno === 5) {
-                        process.nextTick(function () {
-                         // This function needs documentation.
-                            return get_box_status(params, callback);
-                        });
-                        return;
-                    }
-                    return callback(err, rows);
-                }
-                if (rows === undefined) {
-                    return callback(null, rows);
-                }
-                return callback(null, rows.map(function (row) {
-                 // This function needs documentation.
-                    return row.key;
-                }));
-            });
-            return;
-        };
-
-        post_box_key = function (params, callback) {
-         // This function needs documentation.
-            var lines, values;
-            if (params.length === 4) {
-                lines = [
-                    'INSERT OR REPLACE INTO avars ' +
-                            '(body, box_key, box_status, exp_date, key)',
-                    '   VALUES ($body, ' +
-                            '   $box_key,' +
-                            '   $box_status,' +
-                            '   $exp_date,' +
-                            '   $key)'
-                ];
-                values = {
-                    $body:          params[3],
-                    $box_key:       params[0] + '&' + params[1],
-                    $box_status:    params[0] + '&' + params[2],
-                    $exp_date:      exp_date(),
-                    $key:           params[1]
-                };
-            } else {
-                lines = [
-                    'INSERT OR REPLACE INTO avars ' +
-                            '(body, box_key, exp_date)',
-                    '   VALUES ($body, $box_key, $exp_date)'
-                ];
-                values = {
-                    $body:          params[2],
-                    $box_key:       params[0] + '&' + params[1],
-                    $exp_date:      exp_date()
-                };
-            }
-            db.run(lines.join('\n'), values, function (err) {
-             // This function needs documentation.
-                if (err !== null) {
-                    if (err.errno === 5) {
-                        process.nextTick(function () {
-                         // This function needs documentation.
-                            return post_box_key(params, callback);
-                        });
-                        return;
-                    }
-                    return callback(err);
-                }
-                return callback(null);
-            });
-            return;
-        };
-
-        return {
-            collect_garbage: collect_garbage,
-            get_box_key: get_box_key,
-            get_box_status: get_box_status,
-            post_box_key: post_box_key
-        };
-    };
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/katamari.js

-//- JavaScript source code
-
-//- katamari.js ~~
-//
-//  This is adapted from a previously unpublished NPM module I wrote.
-//
-//                                                      ~~ (c) SRW, 11 Dec 2012
-//                                                  ~~ last updated 01 Apr 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 2, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Declarations
-
-    var Q, avar, fs, ignore_patterns, mime_types, path, roll_up, unroll;
-
- // Definitions
-
-    Q = require('quanah');
-
-    avar = Q.avar;
-
-    fs = require('fs');
-
-    ignore_patterns = [
-        /^[.]/
-    ];
-
-    mime_types = {
-        '':             'text/plain',
-        '.appcache':    'text/cache-manifest',
-        '.css':         'text/css',
-        '.html':        'text/html; charset=utf-8',
-        '.ico':         'image/x-icon',
-        '.jpg':         'image/jpeg',
-        '.js':          'text/javascript',
-        '.json':        'application/json',
-        '.manifest':    'text/cache-manifest',
-        '.png':         'image/png',
-        '.txt':         'text/plain',
-        '.webapp':      'application/x-web-app-manifest+json',
-        '.xml':         'application/xml'
-    };
-
-    path = require('path');
-
-    roll_up = function (public_html, json_file) {
-     // This function needs documentation.
-        var dirpath, y;
-        dirpath = path.normalize(public_html);
-        y = avar({val: {}});
-        y.Q(function (evt) {
-         // This function checks to see that the input argument is actually a
-         // directory.
-            fs.lstat(dirpath, function (err, stats) {
-             // This function needs documentation.
-                if (err !== null) {
-                    return evt.fail(err);
-                }
-                if (stats.isDirectory() === false) {
-                    return evt.fail('"' + dirpath + '" is not a directory.');
-                }
-                return evt.exit();
-            });
-            return;
-        }).Q(function (evt) {
-         // This function reads all files located in the top level of `dirpath`
-         // into memory as the properties of an object.
-            fs.readdir(dirpath, function (err, files) {
-             // This function needs documentation.
-                if (err !== null) {
-                    return evt.fail(err);
-                }
-                var count, remaining;
-                count = function () {
-                 // This function needs documentation.
-                    remaining -= 1;
-                    if (remaining === 0) {
-                        return evt.exit();
-                    }
-                    return;
-                };
-                remaining = files.length;
-                files.forEach(function (name) {
-                 // This function needs documentation.
-                    var flag, filepath, i, n;
-                    flag = (name === json_file);
-                    n = ignore_patterns.length;
-                    for (i = 0; (flag === false) && (i < n); i += 1) {
-                        flag = ignore_patterns[i].test(name);
-                    }
-                    if (flag === true) {
-                        return count();
-                    }
-                    filepath = path.join(dirpath, name);
-                    fs.lstat(filepath, function (err, stats) {
-                     // This function needs documentation.
-                        if (err !== null) {
-                            return evt.fail(err);
-                        }
-                     /*
-                        if (stats.isDirectory()) {
-                         // Recurse ...
-                            roll_up(filepath).Q(function (evt) {
-                             // This function isn't working correctly yet ...
-                                var key, temp, x;
-                                x = this.val;
-                                for (key in x) {
-                                    if (x.hasOwnProperty(key)) {
-                                        console.log(filepath, '-->', key);
-                                        temp = path.resolve(filepath, key);
-                                        y.val[temp] = x[key];
-                                    }
-                                }
-                                count();
-                                return evt.exit();
-                            }).on('error', function (message) {
-                             // This function needs documentation.
-                                return evt.fail(message);
-                            });
-                            return;
-                        }
-                     */
-                        if (stats.isFile() === false) {
-                            return count();
-                        }
-                        fs.readFile(filepath, function (err, file) {
-                         // This function needs documentation.
-                            if (err !== null) {
-                                return evt.fail(err);
-                            }
-                            var temp = {
-                                buffer:     file,
-                                last_modified: (new Date()).toGMTString(),
-                                mime_type:  mime_types[path.extname(name)]
-                            };
-                            if (temp.mime_type === undefined) {
-                                temp.mime_type = 'application/octet-stream';
-                            }
-                            y.val['/' + name] = temp;
-                            return count();
-                        });
-                        return;
-                    });
-                    return;
-                });
-                return;
-            });
-            return;
-        }).Q(function (evt) {
-         // This function writes `y.val` as JSON to `json_file` if the second
-         // input argument was a string.
-            if (typeof json_file !== 'string') {
-                console.log('Not a string.');
-                return evt.exit();
-            }
-            var filepath, key, obj;
-            filepath = path.normalize(json_file);
-            obj = y.val;
-            for (key in obj) {
-             // This function needs documentation.
-                if (obj.hasOwnProperty(key)) {
-                    try {
-                        obj[key].base64 = obj[key].buffer.toString('base64');
-                        delete obj[key].buffer;
-                    } catch (err) {
-                        console.error(err, key);
-                    }
-                }
-            }
-            fs.writeFile(filepath, JSON.stringify(obj), function (err) {
-             // This function needs documentation.
-                if (err !== null) {
-                    return evt.fail(err);
-                }
-                console.log('Saved to "' + filepath + '".');
-                return evt.exit();
-            });
-            return;
-        }).on('error', function (message) {
-         // This is a default error handler that can be overwritten.
-            console.error('Error:', message);
-            return;
-        });
-        return y;
-    };
-
-    unroll = function (filename) {
-     // This function needs documentation.
-        var key, x, y;
-        x = require(filename);
-        y = {};
-        for (key in x) {
-            if (x.hasOwnProperty(key)) {
-                y[key] = {
-                    buffer: new Buffer(x[key].base64, 'base64'),
-                    last_modified: x[key].last_modified,
-                    last_mod_date: new Date(x[key].last_modified),
-                    mime_type:  x[key].mime_type
-                };
-            }
-        }
-        return y;
-    };
-
- // Out-of-scope definitions
-
-    exports.roll_up = roll_up;
-
-    exports.unroll = unroll;
-
- // That's all, folks!
-
-    return;
-
-}());
-
-//- vim:set syntax=javascript:

File src/npm-package/lib/main.js

-//- JavaScript source code
-
-//- main.js ~~
-//                                                      ~~ (c) SRW, 16 Jul 2012
-//                                                  ~~ last updated 01 Apr 2013
-
-(function () {
-    'use strict';
-
- // Pragmas
-
-    /*jshint maxparams: 1, quotmark: single, strict: true */
-
-    /*jslint indent: 4, maxlen: 80, node: true */
-
- // Out-of-scope definitions
-
-    exports.launch_client = require('./client').launch;
-