function track_collections_helper() {

  /*
   * Our tracking object.
   */
  let collections = {};

  /*
   * Update the timestamp of a collection.
   */
  function update_collection(coll, ts) {
    _("Updating collection " + coll + " to " + ts);
    let timestamp = ts || new_timestamp();
    collections[coll] = timestamp;
  }

  /*
   * Invoke a handler, updating the collection's modified timestamp unless
   * it's a GET request.
   */
  function with_updated_collection(coll, f) {
    return function(request, response) {
      f.call(this, request, response);

      // Update the collection timestamp to the appropriate modified time.
      // This is either a value set by the handler, or the current time.
      if (request.method != "GET") {
        update_collection(coll, response.newModified)
      }
    };
  }

  /*
   * Return the info/collections object.
   */
  function info_collections(request, response) {
    let body = "Error.";
    switch(request.method) {
      case "GET":
        body = JSON.stringify(collections);
        break;
      default:
        throw "Non-GET on info_collections.";
    }

    response.setHeader("Content-Type", "application/json");
    response.setHeader("X-Weave-Timestamp",
                       "" + new_timestamp(),
                       false);
    response.setStatusLine(request.httpVersion, 200, "OK");
    response.bodyOutputStream.write(body, body.length);
  }

  return {"collections": collections,
          "handler": info_collections,
          "with_updated_collection": with_updated_collection,
          "update_collection": update_collection};
}
/*
 * Track collection modified times. Return closures.
 */
Track collection modified times. Return closures.
Track collection modified times . Return closures .
function track_collections_helper() {
  let collections = {};
  function update_collection(coll, ts) {
    _("Updating collection " + coll + " to " + ts);
    let timestamp = ts || new_timestamp();
    collections[coll] = timestamp;
  }
  function with_updated_collection(coll, f) {
    return function(request, response) {
      f.call(this, request, response);
      if (request.method != "GET") {
        update_collection(coll, response.newModified)
      }
    };
  }
  function info_collections(request, response) {
    let body = "Error.";
    switch(request.method) {
      case "GET":
        body = JSON.stringify(collections);
        break;
      default:
        throw "Non-GET on info_collections.";
    }
    response.setHeader("Content-Type", "application/json");
    response.setHeader("X-Weave-Timestamp",
                       "" + new_timestamp(),
                       false);
    response.setStatusLine(request.httpVersion, 200, "OK");
    response.bodyOutputStream.write(body, body.length);
  }
  return {"collections": collections,
          "handler": info_collections,
          "with_updated_collection": with_updated_collection,
          "update_collection": update_collection};
}
function track_collections_helper ( ) { let collections = { } ; function update_collection ( coll , ts ) { _ ( "Updating collection " + coll + " to " + ts ) ; let timestamp = ts || new_timestamp ( ) ; collections [ coll ] = timestamp ; } function with_updated_collection ( coll , f ) { return function ( request , response ) { f . call ( this , request , response ) ; if ( request . method != "GET" ) { update_collection ( coll , response . newModified ) } } ; } function info_collections ( request , response ) { let body = "Error." ; switch ( request . method ) { case "GET" : body = JSON . stringify ( collections ) ; break ; default : throw "Non-GET on info_collections." ; } response . setHeader ( "Content-Type" , "application/json" ) ; response . setHeader ( "X-Weave-Timestamp" , "" + new_timestamp ( ) , false ) ; response . setStatusLine ( request . httpVersion , 200 , "OK" ) ; response . bodyOutputStream . write ( body , body . length ) ; } return { "collections" : collections , "handler" : info_collections , "with_updated_collection" : with_updated_collection , "update_collection" : update_collection } ; }
Track collection modified times.
Track collection modified times .
/*
   * Our tracking object.
   */ /*
   * Update the timestamp of a collection.
   */ /*
   * Invoke a handler, updating the collection's modified timestamp unless
   * it's a GET request.
   */ // Update the collection timestamp to the appropriate modified time. // This is either a value set by the handler, or the current time. /*
   * Return the info/collections object.
   */