rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
28 lines (25 loc) • 445 B
text/typescript
/**
* @public
* returns items in A not in B.
*
* @remarks
* See {@link arraySetDifference}.
*/
export function arraySetDifference<TItem>
(
a: ArrayLike<TItem>,
b: ReadonlySet<TItem>,
)
: Set<TItem>
{
const result = new Set<TItem>();
for (let i = 0, iEnd = a.length; i < iEnd; ++i)
{
const item = a[i];
if (!b.has(item))
{
result.add(item);
}
}
return result;
}