UNPKG

@kamilmielnik/trie

Version:

Trie data structure implementation in TypeScript. Highly performant. No dependencies. Built for a Scrabble Solver.

17 lines (16 loc) 559 B
import { traverse } from './traverse.js'; /** * Finds all {@link Descendant | descendants} of given {@link Node} and returns them as an array. * * @param node - {@link Node} to look for {@link Descendant | descendants} in. * @param options - See {@link TraverseOptions}. * @returns An array of {@link Descendant | descendants}. */ export const toArray = (node, options) => { const descendants = []; const callback = (parameters) => { descendants.push(parameters); }; traverse(node, callback, options); return descendants; };