react-select-table
Version:
React table component with selectable items
82 lines (81 loc) • 2.51 kB
TypeScript
/**
* @namespace SetTypes
*/
/**
* A {@link https://en.wikipedia.org/wiki/Set_(abstract_data_type)|Set}, implemented as an object with true as values
*
* @template Value
* @typedef {Object<Value, boolean>} SetTypes.Set
*/
/**
* Returns a new set instance
*
* @template Value
* @returns {SetTypes.Set<Value>} A new set
*/
export function instance<Value>(): any;
/**
* Removes a value from a set
*
* @template Value
* @param {SetTypes.Set<Value>} set The set that contains the value to remove
* @param {Value} value The value to remove
*/
export function removeItem<Value>(set: any, value: Value): void;
/**
* Adds a value to a set
*
* @template Value
* @param {SetTypes.Set<Value>} set The set to which to add the value
* @param {Value} value The value to add
*/
export function addItem<Value>(set: any, value: Value): void;
/**
* Adds or removes a value from a set
*
* @template Value
* @param {SetTypes.Set<Value>} set The set to/from which to add/remove the value
* @param {Value} value The value to add/remove
* @param {boolean} exists True if the value should be added, false if it should be removed
*/
export function toggleItem<Value>(set: any, value: Value, exists: boolean): void;
/**
* Checks whether a value is contained in a set
*
* @template Value
* @param {SetTypes.Set<Value>} set The set to check whether the value is contained in
* @param {Value} value The value to check
* @returns {boolean} True if the value is contained in the set
*/
export function hasItem<Value>(set: any, value: Value): boolean;
/**
* Returns an array containing all values of a set
*
* @template Value
* @param {SetTypes.Set<Value>} set The set to get the values from
* @returns {string[]} The values of the set
*/
export function getItems<Value>(set: any): string[];
/**
* Checks whether a set is empty
*
* @template Value
* @param {SetTypes.Set<Value>} set The set to check
* @returns {boolean} True if the set contains no values
*/
export function isEmpty<Value>(set: any): boolean;
/**
* Compares the values of two sets
*
* @template Value
* @param {SetTypes.Set<Value>} setA A set
* @param {SetTypes.Set<Value>} setB A different set
* @returns {boolean} True if the two sets contain the same values
*/
export function isEqual<Value>(setA: any, setB: any): boolean;
export namespace SetTypes {
/**
* A {@link https://en.wikipedia.org/wiki/Set_(abstract_data_type)|Set}, implemented as an object with true as values
*/
type Set<Value> = any;
}