ejdb.js
function parseQueryArgs(args) {
    var cname, qobj, orarr, hints, cb;
    var i = 0;
    cname = args[i++];
    if (typeof cname !== "string") {
        throw new Error("Collection name 'cname' argument must be specified");
    }
    var next = args[i++];
    if (typeof next === "function") {
        cb = next;
    } else {
        qobj = next;
    }
    next = args[i++];
    if (next !== undefined) {
        if (Array.isArray(next)) {
            orarr = next;
            next = args[i++];
        } else if (typeof next === "object") {
            hints = next;
            orarr = null;
            next = args[i++];
        }
        if (!hints && typeof next === "object") {
            hints = next;
            next = args[i++];
        }
        if (typeof next === "function") {
            cb = next;
        }
    }
    return [cname, (qobj || {}), (orarr || []), (hints || {}), (cb || null)];
}
function parseQueryArgs(args) {
    var cname, qobj, orarr, hints, cb;
    var i = 0;
    cname = args[i++];
    if (typeof cname !== "string") {
        throw new Error("Collection name 'cname' argument must be specified");
    }
    var next = args[i++];
    if (typeof next === "function") {
        cb = next;
    } else {
        qobj = next;
    }
    next = args[i++];
    if (next !== undefined) {
        if (Array.isArray(next)) {
            orarr = next;
            next = args[i++];
        } else if (typeof next === "object") {
            hints = next;
            orarr = null;
            next = args[i++];
        }
        if (!hints && typeof next === "object") {
            hints = next;
            next = args[i++];
        }
        if (typeof next === "function") {
            cb = next;
        }
    }
    return [cname, (qobj || {}), (orarr || []), (hints || {}), (cb || null)];
}
/*
- (cname, [cb])
- (cname, qobj, [cb])
- (cname, qobj, hints, [cb])
- (cname, qobj, qobjarr, [cb])
- (cname, qobj, qobjarr, hints, [cb])