source: node_modules/ramda/es/unionWith.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d24f17c]1import _concat from "./internal/_concat.js";
2import _curry3 from "./internal/_curry3.js";
3import uniqWith from "./uniqWith.js";
4/**
5 * Combines two lists into a set (i.e. no duplicates) composed of the elements
6 * of each list. Duplication is determined according to the value returned by
7 * applying the supplied predicate to two list elements. If an element exists
8 * in both lists, the first element from the first list will be used.
9 *
10 * @func
11 * @memberOf R
12 * @since v0.1.0
13 * @category Relation
14 * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*]
15 * @param {Function} pred A predicate used to test whether two items are equal.
16 * @param {Array} list1 The first list.
17 * @param {Array} list2 The second list.
18 * @return {Array} The first and second lists concatenated, with
19 * duplicates removed.
20 * @see R.union
21 * @example
22 *
23 * const l1 = [{a: 1}, {a: 2}];
24 * const l2 = [{a: 1}, {a: 4}];
25 * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}]
26 */
27
28var unionWith =
29/*#__PURE__*/
30_curry3(function unionWith(pred, list1, list2) {
31 return uniqWith(pred, _concat(list1, list2));
32});
33
34export default unionWith;
Note: See TracBrowser for help on using the repository browser.