Set operations in setOps.ts
take two arrays and return the result of the operation as an array. Supported operations are union
, intersection
, difference
, complement
, and equals
. difference
is the symmetric difference and complement
is the relative complement. The set operations are fast, even for large arrays.
This code is provided as a gist for ease of use; simply add it to your project as if it was one of your own files and import what you need from it.
There are different ways to apply these operations in TypeScript. A set of static convenience functions is supplied for simple cases along with an ISetOps
interface and a SetOps
class.