UNPKG

1.11 kBJavaScriptView Raw
1var _concat =
2/*#__PURE__*/
3require("./internal/_concat");
4
5var _curry3 =
6/*#__PURE__*/
7require("./internal/_curry3");
8
9var uniqWith =
10/*#__PURE__*/
11require("./uniqWith");
12/**
13 * Combines two lists into a set (i.e. no duplicates) composed of the elements
14 * of each list. Duplication is determined according to the value returned by
15 * applying the supplied predicate to two list elements.
16 *
17 * @func
18 * @memberOf R
19 * @since v0.1.0
20 * @category Relation
21 * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*]
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 first and second lists concatenated, with
26 * duplicates removed.
27 * @see R.union
28 * @example
29 *
30 * const l1 = [{a: 1}, {a: 2}];
31 * const l2 = [{a: 1}, {a: 4}];
32 * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}]
33 */
34
35
36var unionWith =
37/*#__PURE__*/
38_curry3(function unionWith(pred, list1, list2) {
39 return uniqWith(pred, _concat(list1, list2));
40});
41
42module.exports = unionWith;
\No newline at end of file