···8888};
89899090/**
9191+ * returns elements present in the first array but not in the second, based on a selector
9292+ * @param a the source array
9393+ * @param b the array to compare against
9494+ * @param selector function to derive comparison keys
9595+ * @returns an array of elements in a not present in b based on the selector
9696+ */
9797+/*#__NO_SIDE_EFFECTS__*/
9898+export const differenceBy = <T, K>(a: T[], b: T[], selector: (value: T) => K): T[] => {
9999+ const bSet = new Set(b.map(selector));
100100+ const aSet = new Set<K>();
101101+102102+ return a.filter((value) => {
103103+ const key = selector(value);
104104+105105+ if (!bSet.has(key) && !aSet.has(key)) {
106106+ aSet.add(key);
107107+ return true;
108108+ }
109109+110110+ return false;
111111+ });
112112+};
113113+114114+/**
91115 * returns elements common to both arrays
92116 * @param a the first array
93117 * @param b the second array