<commit_before>var lists = exports;

lists.latest = function(head, req){
  var row = getRow();

  if(!row){
    throw ['error', 'not_found', 'no results'];
  }

  var doc = row.doc;

  var util = require('pkg-util');

  start({ "headers": { "Content-Type": "application/json" } });
  send(JSON.stringify(util.clean(doc, req), null, 2));

};


lists.versions = function(head, req){
  log("*****DDEBUG DEBUG *******");
  var row;
  var packages = [];
  while(row = getRow()){
    log(row.value);
    packages.push({
      '@type': 'Package',
      name: row.value.name,
      version: row.value.version,
      description: row.value.description,
      private: row.value.private,
      url: row.value.name + '/' + row.value.version,
    });
  }

  if(!packages.length){
    start({
      code: 404,
      headers: {"Content-Type": "application/json"}
    });
    return send(JSON.stringify({error: "no results"}));
  } else {
    start({"headers": {"Content-Type": "application/json"}});
    send(JSON.stringify({
      '@id': req.query.name,
      package: packages
    }, null, 2));
  }
};


lists.search = function(head, req){
  var row;
  var cnt = 0;
  start({"headers": {"Content-Type": "application/x-ldjson"}});
  while(row = getRow()){
    send(JSON.stringify(row) + '\n');
    cnt++;
  }

  if(!cnt){
    throw ['error', 'not_found', 'no results'];
  }
};<commit_msg>search<commit_after>var lists = exports;

lists.latest = function(head, req){
  var row = getRow();

  if(!row){
    throw ['error', 'not_found', 'no results'];
  }

  var doc = row.doc;

  var util = require('pkg-util');

  start({ "headers": { "Content-Type": "application/json" } });
  send(JSON.stringify(util.clean(doc, req), null, 2));

};


lists.versions = function(head, req){
  log("*****DDEBUG DEBUG *******");
  var row;
  var packages = [];
  while(row = getRow()){
    log(row.value);
    packages.push({
      '@type': 'Package',
      name: row.value.name,
      version: row.value.version,
      description: row.value.description,
      private: row.value.private,
      url: row.value.name + '/' + row.value.version,
    });
  }

  if(!packages.length){
    start({
      code: 404,
      headers: {"Content-Type": "application/json"}
    });
    return send(JSON.stringify({error: "no results"}));
  } else {
    start({"headers": {"Content-Type": "application/json"}});
    send(JSON.stringify({
      '@id': req.query.name,
      package: packages
    }, null, 2));
  }
};


lists.search = function(head, req){
  var row;
  var cnt = 0;
  start({"headers": {"Content-Type": "application/x-ldjson"}});
  while(row = getRow()){
    if (row.value.private !== true) {
      send(JSON.stringify(row) + '\n');
    }
    cnt++;
  }

  if(!cnt){
    throw ['error', 'not_found', 'no results'];
  }
};
{'fraction_non_alphanumeric': 0.21046970240229473, 'fraction_numerical': 0.004302617425600574, 'mean_word_length': 3.0259740259740258, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '621000', 'n_tokens_mistral': 979, 'n_tokens_neox': 952, 'n_words': 201}