/** * @public * Returns those items in A not in B, and those items in B not in A. * * @remarks * See {@link arraySymmetricDifference}. */ export function arraySymmetricDifference ( a: readonly TItem[], b: readonly TItem[], aSet: ReadonlySet = new Set(a), bSet: ReadonlySet = new Set(b), ) : Set { const result = new Set(); for (let i = 0, iEnd = a.length; i < iEnd; ++i) { const item = a[i]; if (!bSet.has(item)) { result.add(item); } } for (let i = 0, iEnd = b.length; i < iEnd; ++i) { const item = b[i]; if (!aSet.has(item)) { result.add(item); } } return result; }