UNPKG

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.

24 lines 652 B
/** * @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, b, aSet = new Set(a), bSet = new Set(b)) { 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; } //# sourceMappingURL=array-symmetric-difference.js.map