Skip to main content

Home > @jsplumb/util > addWithFunction

addWithFunction() function#

Adds an item to a list if the given hash function determines that the item is not already in the list

Signature:

export declare function addWithFunction<T>(list: Array<T>, item: T, hashFunction: (_a: T) => boolean): void;

Parameters#

ParameterTypeDescription
listArray<T>List to add to
itemTItem to add
hashFunction(_a: T) => booleanFunction to use to check the current items of the list; if this function returns true for any current list item, the insertion does not proceed.

Returns:

void