trie: add get function

This commit is contained in:
Joeri Exelmans 2025-05-11 09:30:48 +02:00
parent dd35e2b577
commit dadee965e5
2 changed files with 26 additions and 1 deletions

View file

@ -3,7 +3,9 @@ import * as assert from "node:assert";
import { module2Env } from "../lib/environment/env.js";
import { ModuleStd } from "../lib/stdlib.js";
import { pretty } from "../lib/util/pretty.js";
import { emptyTrie, growPrefix, insert, isProperlySorted, suggest } from "../lib/util/trie.js";
import { emptyTrie, get, growPrefix, insert, isProperlySorted, suggest } from "../lib/util/trie.js";
import { push } from "../lib/structures/list.js";
import { getInst } from "../lib/primitives/dynamic.js";
///////////////////
@ -104,4 +106,14 @@ assert.deepEqual(
assert.deepEqual(
suggest(bigTrie)("df")(2),
[]
);
assert.equal(
getInst(get(bigTrie)("list.push")),
push
);
assert.equal(
get(bigTrie)("ooo"),
undefined
);