<commit_before>
var lmdb = require('..');
var env = new lmdb.Env();
env.open({
    // Path to the environment
    path: "./testdata",
    // Maximum number of databases
    maxDbs: 10
});

// Ensure that the database is empty
var dbi = env.openDbi({
   name: "mydb10",
   create: true
});
dbi.drop();
dbi = env.openDbi({
   name: "mydb10",
   create: true
});

// Write test values

var txn0 = env.beginTxn();
txn0.putString(dbi, Buffer.from("a","utf8"), "Helló1");
txn0.putString(dbi, Buffer.from("b","utf8"), "Hello2");
txn0.putNumber(dbi, Buffer.from("c","utf8"), 43);
/* key 'd' is omitted intentionally */
txn0.putBinary(dbi, "e", Buffer.from("öüóőúéáű"));
txn0.putBoolean(dbi, "f", false);
txn0.putString(dbi, "g", "Hello6");
txn0.commit();
console.log("wrote initial values");

var printFunc = function(key, data) {
    console.log("----->  key:", key.toString(), " : ", JSON.stringify(key));
    console.log("-----> data:", data.toString(), " : ", JSON.stringify(data));
}

// Begin transaction
var txn = env.beginTxn();

// Create cursor
var cursor = new lmdb.Cursor(txn, dbi, true);

console.log("first (expected a)");
cursor.goToFirst();
cursor.getCurrentString(printFunc);

console.log("next (expected b)");
cursor.goToNext();
cursor.getCurrentString(printFunc);

console.log("next (expected c)");
cursor.goToNext();
cursor.getCurrentNumber(printFunc);


console.log("next (expected e)");
cursor.goToNext();
cursor.getCurrentBinary(printFunc);


console.log("prev (expected c)");
cursor.goToPrev();
cursor.getCurrentNumber(printFunc);


console.log("last (expected g)");
cursor.goToLast();
cursor.getCurrentString(printFunc);<commit_msg>fix #112 typo in example 10<commit_after>
var lmdb = require('..');
var env = new lmdb.Env();
env.open({
    // Path to the environment
    path: "./testdata",
    // Maximum number of databases
    maxDbs: 10
});

// Ensure that the database is empty
var dbi = env.openDbi({
   name: "mydb10",
   create: true
});
dbi.drop();
dbi = env.openDbi({
   name: "mydb10",
   create: true
});

// Write test values

var txn0 = env.beginTxn();
txn0.putString(dbi, Buffer.from("a","utf8"), "Helló1");
txn0.putString(dbi, Buffer.from("b","utf8"), "Hello2");
txn0.putNumber(dbi, Buffer.from("c","utf8"), 43);
/* key 'd' is omitted intentionally */
txn0.putBinary(dbi, "e", Buffer.from("öüóőúéáű"));
txn0.putBoolean(dbi, "f", false);
txn0.putString(dbi, "g", "Hello6");
txn0.commit();
console.log("wrote initial values");

var printFunc = function(key, data) {
    console.log("----->  key:", key.toString(), " : ", JSON.stringify(key));
    console.log("-----> data:", data.toString(), " : ", JSON.stringify(data));
}

// Begin transaction
var txn = env.beginTxn();

// Create cursor
var cursor = new lmdb.Cursor(txn, dbi, { keyIsBuffer: true });

console.log("first (expected a)");
cursor.goToFirst();
cursor.getCurrentString(printFunc);

console.log("next (expected b)");
cursor.goToNext();
cursor.getCurrentString(printFunc);

console.log("next (expected c)");
cursor.goToNext();
cursor.getCurrentNumber(printFunc);


console.log("next (expected e)");
cursor.goToNext();
cursor.getCurrentBinary(printFunc);


console.log("prev (expected c)");
cursor.goToPrev();
cursor.getCurrentNumber(printFunc);


console.log("last (expected g)");
cursor.goToLast();
cursor.getCurrentString(printFunc);
{'fraction_non_alphanumeric': 0.20006007810153198, 'fraction_numerical': 0.01471913487533794, 'mean_word_length': 4.873015873015873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1049102', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1186, 'n_words': 263}