@kamilmielnik/trie
Version:
Trie data structure implementation in TypeScript. Highly performant. No dependencies. Built for a Scrabble Solver.
21 lines (20 loc) • 698 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toArray = void 0;
const traverse_1 = require("./traverse");
/**
* 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}.
*/
const toArray = (node, options) => {
const descendants = [];
const callback = (parameters) => {
descendants.push(parameters);
};
(0, traverse_1.traverse)(node, callback, options);
return descendants;
};
exports.toArray = toArray;