src/cachinglayer.js
function (path, maxAge, queueGetRequest) {
    var self = this;
    if (typeof(maxAge) === 'number') {
      return self.getNodes(pathsFromRoot(path))
      .then(function (objs) {
        var node = getLatest(objs[path]);
        if (isOutdated(objs, maxAge)) {
          return queueGetRequest(path);
        } else if (node) {
          return {statusCode: 200, body: node.body || node.itemsMap, contentType: node.contentType};
        } else {
          return {statusCode: 404};
        }
      });
    } else {
      return self.getNodes([path])
      .then(function (objs) {
        var node = getLatest(objs[path]);
        if (node) {
          if (isFolder(path)) {
            for (var i in node.itemsMap) {
              // the hasOwnProperty check here is only because our jshint settings require it:
              if (node.itemsMap.hasOwnProperty(i) && node.itemsMap[i] === false) {
                delete node.itemsMap[i];
              }
            }
          }
          return {statusCode: 200, body: node.body || node.itemsMap, contentType: node.contentType};
        } else {
          return {statusCode: 404};
        }
      });
    }
  }
function (path, maxAge, queueGetRequest) {
    var self = this;
    if (typeof(maxAge) === 'number') {
      return self.getNodes(pathsFromRoot(path))
      .then(function (objs) {
        var node = getLatest(objs[path]);
        if (isOutdated(objs, maxAge)) {
          return queueGetRequest(path);
        } else if (node) {
          return {statusCode: 200, body: node.body || node.itemsMap, contentType: node.contentType};
        } else {
          return {statusCode: 404};
        }
      });
    } else {
      return self.getNodes([path])
      .then(function (objs) {
        var node = getLatest(objs[path]);
        if (node) {
          if (isFolder(path)) {
            for (var i in node.itemsMap) {
              // the hasOwnProperty check here is only because our jshint settings require it:
              if (node.itemsMap.hasOwnProperty(i) && node.itemsMap[i] === false) {
                delete node.itemsMap[i];
              }
            }
          }
          return {statusCode: 200, body: node.body || node.itemsMap, contentType: node.contentType};
        } else {
          return {statusCode: 404};
        }
      });
    }
  }
TODO: improve our code structure so that this function could call sync.queueGetRequest directly instead of needing this hacky third parameter as a callback