According to the documentation createKeyStream and createValueStream should use the indices as keys and the indexed values as values. However in reality it uses the keys of the original db on which the index has been created.
const autoLevelIdx = require("level-auto-index");
const level = require("level-mem");
async function printStream(text, stream, print) {
await new Promise((res) => {
stream.on("data", e => text += " | " + print(e));
stream.on("end", res);
});
console.log(text);
}
(async function() {
const db = level();
const byTitle = autoLevelIdx(db, level(), val => val);
await Promise.all([db.put("A", "X"), db.put("B", "Y"), db.put("C", "Z")]);
await printStream("ReadStream", byTitle.createReadStream(), ({key, value}) => `${key}: ${value}`);
await printStream("KeyStream", byTitle.createKeyStream(), (key) => key);
})();
According to the documentation this code should output:
ReadStream | X: X | Y: Y | Z: Z
KeyStream | X | Y | Z
In reality it generates the following output:
ReadStream | A: X | B: Y | C: Z
KeyStream | A | B | C
According to the documentation createKeyStream and createValueStream should use the indices as keys and the indexed values as values. However in reality it uses the keys of the original db on which the index has been created.
According to the documentation this code should output:
In reality it generates the following output: