+/**
+ * Computes the union of one or more arrays
+ * @param {...any[]} arrays One or more arrays to union
+ * @returns {any[]} The union of the input arrays
+ */
+function union(...arrays) {
+
+ // TODO(stephenwade): Replace this with arrays.flat() when we drop support for Node v10
+ return [...new Set([].concat(...arrays))];
+}
+
+/**
+ * Computes the intersection of one or more arrays
+ * @param {...any[]} arrays One or more arrays to intersect
+ * @returns {any[]} The intersection of the input arrays
+ */
+function intersection(...arrays) {
+ if (arrays.length === 0) {
+ return [];
+ }
+
+ let result = [...new Set(arrays[0])];
+
+ for (const array of arrays.slice(1)) {
+ result = result.filter(x => array.includes(x));
+ }
+ return result;
+}
+