react-select-table
Version:
React table component with selectable items
65 lines (64 loc) • 2.1 kB
TypeScript
/**
* @namespace TrieTypes
*/
/**
* A node of a {@link https://en.wikipedia.org/wiki/Trie|trie}
*
* @template Value
* @typedef {object} TrieTypes.Node
* @property {Object<string, TrieTypes.Node<Value>>} children The children of the node
* @property {import('../utils/setUtils').Set<Value>} values The values of the nodes that end at this character
*/
/**
* Returns a new node instance
*
* @template Value
* @returns {TrieTypes.Node<Value>} A new node
*/
export function instance<Value>(): TrieTypes.Node<Value>;
/**
* Adds a new node to the trie
*
* @template Value
* @param {TrieTypes.Node<Value>} node The node under which to place the new one
* @param {Value} value The value of the new node
* @param {string} text The text of the new node
* @returns {void}
*/
export function addNode<Value>(node: TrieTypes.Node<Value>, value: Value, text: string): void;
/**
* Removes a node from the trie
*
* @template Value
* @param {TrieTypes.Node<Value>} node The node under which the node to remove was placed originally
* @param {Value} value The value of the node to remove
* @param {string} text The text of the node to remove
* @returns {boolean} True if the node existed
*/
export function removeNode<Value>(node: TrieTypes.Node<Value>, value: Value, text: string): boolean;
/**
* Returns the values of all nodes whose text begins with the text given
*
* @template Value
* @param {TrieTypes.Node<Value>} node The node from which to begin the search
* @param {string} text The text to find matching values for
* @returns {Value[]} The values of the nodes that match the given text
*/
export function getMatchingValues<Value>(node: TrieTypes.Node<Value>, text: string): Value[];
export namespace TrieTypes {
/**
* A node of a {@link https://en.wikipedia.org/wiki/Trie|trie}
*/
type Node<Value> = {
/**
* The children of the node
*/
children: {
[x: string]: TrieTypes.Node<Value>;
};
/**
* The values of the nodes that end at this character
*/
values: any;
};
}