import { markovChoice } from "https://esm.town/v/jdan/markovChoice";
export function traversePairwise(chain) {
let node = "START";
let result = [];
while (node !== "END") {
node = markovChoice(chain[node]);
result.push(node);
}
return result.slice(0, -1).map((word, idx) => {
if (idx === 0) {
return word;
}
return word[word.length - 1];
});
}