@kamilmielnik/trie
Version:
Trie data structure implementation in TypeScript. Highly performant. No dependencies. Built for a Scrabble Solver.
19 lines (18 loc) • 678 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasPrefix = void 0;
const find_1 = require("./find");
/**
* Tells you whether there are any words with given prefix in the {@link Node}.
*
* See: https://en.wikipedia.org/wiki/String_operations#Prefixes
*
* @param node - {@link Node} to look for prefix in.
* @param prefix - Prefix to be found.
* @returns true if there are any words with given prefix in the {@link Node}, false otherwise.
*/
const hasPrefix = (node, prefix) => {
const foundNode = (0, find_1.find)(node, prefix);
return foundNode ? Object.keys(foundNode).length > 0 : false;
};
exports.hasPrefix = hasPrefix;