UNPKG

1.31 kBJavaScriptView Raw
1var _curry3 =
2/*#__PURE__*/
3require("./internal/_curry3");
4
5var concat =
6/*#__PURE__*/
7require("./concat");
8
9var differenceWith =
10/*#__PURE__*/
11require("./differenceWith");
12/**
13 * Finds the set (i.e. no duplicates) of all elements contained in the first or
14 * second list, but not both. Duplication is determined according to the value
15 * returned by applying the supplied predicate to two list elements.
16 *
17 * @func
18 * @memberOf R
19 * @since v0.19.0
20 * @category Relation
21 * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
22 * @param {Function} pred A predicate used to test whether two items are equal.
23 * @param {Array} list1 The first list.
24 * @param {Array} list2 The second list.
25 * @return {Array} The elements in `list1` or `list2`, but not both.
26 * @see R.symmetricDifference, R.difference, R.differenceWith
27 * @example
28 *
29 * const eqA = R.eqBy(R.prop('a'));
30 * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
31 * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}];
32 * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}]
33 */
34
35
36var symmetricDifferenceWith =
37/*#__PURE__*/
38_curry3(function symmetricDifferenceWith(pred, list1, list2) {
39 return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1));
40});
41
42module.exports = symmetricDifferenceWith;
\No newline at end of file