@kamilmielnik/trie
Version:
Trie data structure implementation in TypeScript. Highly performant. No dependencies. Built for a Scrabble Solver.
13 lines (12 loc) • 341 B
JavaScript
import { add } from './add.js';
/**
* Creates a new {@link Node} based on array of words.
*
* @param words - array of words to put in the {@link Node}.
* @returns New {@link Node} containing all given words.
*/
export const fromArray = (words) => {
const node = {};
words.forEach((word) => add(node, word));
return node;
};