<commit_before>if (typeof global != 'undefined') require('./load.test').load(global);
if (node) junjo_test();

function junjo_test() {
  if (!node) return;
  var mongo      = require('mongodb'),
      DB         = mongo.Db,
      Connection = mongo.Connection,
      Server     = mongo.Server;

  var N = 0; console.time(N);
  function showTime() { console.timeEnd(N); console.time(++N); }

  var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';
  var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT'] : Connection.DEFAULT_PORT;
  var client = new DB('node-mongo-examples', new Server(host, port, {}), {});
  console.log("connecting to " + host);

  var j = new Junjo({
    nodeCallback : true,
    timeout      : 3,
    catcher      : function(e, jfn) {
      console.error(jfn.label());
      return j.defaultCatcher(e, jfn);
    }
  });

  j.getKPF = function(jfn) {
    var resultKP = j.results(jfn.label(), 1);
    return function() {
      var args = arguments;
      var next_jfn = j(function() {
        showTime();
        var obj   = resultKP.get();
        var fname = Array.prototype.shift.call(args);
        Array.prototype.push.call(args, this.callback);
        obj[fname].apply(obj, args);
      }).after(jfn.label());
      return j.getKPF(next_jfn);
    };
  };


  var open = function() { return j.getKPF(j(client.open).bind(client, j.callback)) };


  /****** START *********/
  var conn = open();
  conn('dropDatabase');

  var coll = conn('collection', 'test');
  coll('remove', {});

  for (var i=0; i<3; i++) coll('insert', {a : i});

  coll('count');

  j(function(err, count) {
    showTime();
    console.log("There are " + count + " records in the test collection. Here they are:");
  }).after();

  coll('find');

  j(function(err, cursor) {
    showTime();
    cursor.each(function(err, item) {
      if(item != null) {
        showTime();
        console.log(item);
        console.log("created at " + new Date(item._id.generationTime) + "\n")
      }
    });
  }).after();

  j.on('end', function() {
    client.close();
  });

  j.run();
}<commit_msg>modify mongo.junjo<commit_after>if (typeof global != 'undefined') require('./load.test').load(global);
if (node) junjo_test();

function junjo_test() {
  if (!node) return;
  var mongo      = require('mongodb'),
      DB         = mongo.Db,
      Connection = mongo.Connection,
      Server     = mongo.Server;

  var N = 0; console.time(N);
  function showTime() { console.timeEnd(N); console.time(++N); }

  var host = 'localhost';
  var port = Connection.DEFAULT_PORT;
  var client = new DB('node-mongo-examples', new Server(host, port, {}), {});
  console.log("connecting to " + host);

  var $j = new Junjo({
    nodeCallback : true,
    timeout      : 3,
    catcher      : function(e, jfn) {
      console.error(jfn.label());
      return j.defaultCatcher(e, jfn);
    }
  });

  $j.getResult = function(jfn) {
    var result = $j.results(jfn.label(), 1);
    return function() {
      var args = arguments;
      var next_jfn = $j(function() {
        showTime();
        var obj   = result.get();
        var fname = Array.prototype.shift.call(args);
        Array.prototype.push.call(args, this.callback);
        obj[fname].apply(obj, args);
      }).after(jfn.label());
      return $j.getResult(next_jfn);
    };
  };

  var $result = function(fn) { return $j(fn).after() };
  var $open = function() { return $j.getResult($j(client.open).bind(client, $j.callback)) };

  /****** START *********/
  var $conn = $open();
  $conn('dropDatabase');

  var $coll = $conn('collection', 'test');
  $coll('remove', {});

  for (var i=0; i<3; i++) $coll('insert', {a : i});

  $coll('count');

  $result(function(err, count) {
    showTime();
    console.log("There are " + count + " records in the test collection. Here they are:");
  });

  $coll('find');

  $result(function(err, cursor) {
    showTime();
    cursor.each(function(err, item) {
      if(item != null) {
        showTime();
        console.log(item);
        console.log("created at " + new Date(item._id.generationTime) + "\n")
      }
    });
  });

  $j.on('end', function() {
    client.close();
  });

  $j.run();
}
{'fraction_non_alphanumeric': 0.1916783543712015, 'fraction_numerical': 0.0023375409069658717, 'mean_word_length': 2.848021582733813, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4184822', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1441, 'n_words': 308}