Here is a mock of what I have tried with each outcome... I've read over the documentation and it seems like at least some of these things should work. Not sure what I'm doing wrong.
function getMatch(
value: string
fooSet: Immutable.Set<string[]>
): boolean {
// Convert the Immutable Set to a regular JavaScript array so i can use includes
const setArray = fooSet.toArray();
return setArray.includes([value]); //TypeError: fooSet.toArray is not a function
// Use the some method to check if value exists in set
let valueList = [value]
return fooSet.some((key) => key === valueList); // fooSet.some is not a function
return fooSet.has([value]); //has is only for numbers can't be used on strings
return fooSet.some((key) => key.is(value))//Property 'is' does not exist on type 'string[]'
let found = fooSet.get([value])
return found ? true : false //fooSet.get is not a function
}
UPDATE SOLUTION: changed to Set<List> which was a great improvement @Bergi. The other half was i needed to compare immutable to immutable, my value was a 3 string key so this was the fix:
function getMatch(
values: { key1: string: key2: string; key3: string }
fooSet: Immutable.Set<List<string>>
): boolean {
const { key1, key2, key3 } = values
const valueList = Immutable.List<string>([key1, key2, key3])
return containsValue = fooSet.some((list) => list.equals(valueList));
}
I can also just look for one value in the list...
const checkKey1 = (list: Immutable.List<string>) => list.includes(key1);
const hasKey1 = set.some(checkKey1);