1 | var _includesWith =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_includesWith.js");
|
---|
4 |
|
---|
5 | var _curry3 =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./internal/_curry3.js");
|
---|
8 |
|
---|
9 | var _filter =
|
---|
10 | /*#__PURE__*/
|
---|
11 | require("./internal/_filter.js");
|
---|
12 | /**
|
---|
13 | * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list
|
---|
14 | * `xs'` comprising each of the elements of `xs` which is equal to one or more
|
---|
15 | * elements of `ys` according to `pred`.
|
---|
16 | *
|
---|
17 | * `pred` must be a binary function expecting an element from each list.
|
---|
18 | *
|
---|
19 | * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should
|
---|
20 | * not be significant, but since `xs'` is ordered the implementation guarantees
|
---|
21 | * that its values are in the same order as they appear in `xs`. Duplicates are
|
---|
22 | * not removed, so `xs'` may contain duplicates if `xs` contains duplicates.
|
---|
23 | *
|
---|
24 | * @func
|
---|
25 | * @memberOf R
|
---|
26 | * @since v0.24.0
|
---|
27 | * @category Relation
|
---|
28 | * @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a]
|
---|
29 | * @param {Function} pred
|
---|
30 | * @param {Array} xs
|
---|
31 | * @param {Array} ys
|
---|
32 | * @return {Array}
|
---|
33 | * @see R.intersection
|
---|
34 | * @example
|
---|
35 | *
|
---|
36 | * R.innerJoin(
|
---|
37 | * (record, id) => record.id === id,
|
---|
38 | * [{id: 824, name: 'Richie Furay'},
|
---|
39 | * {id: 956, name: 'Dewey Martin'},
|
---|
40 | * {id: 313, name: 'Bruce Palmer'},
|
---|
41 | * {id: 456, name: 'Stephen Stills'},
|
---|
42 | * {id: 177, name: 'Neil Young'}],
|
---|
43 | * [177, 456, 999]
|
---|
44 | * );
|
---|
45 | * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]
|
---|
46 | */
|
---|
47 |
|
---|
48 |
|
---|
49 | var innerJoin =
|
---|
50 | /*#__PURE__*/
|
---|
51 | _curry3(function innerJoin(pred, xs, ys) {
|
---|
52 | return _filter(function (x) {
|
---|
53 | return _includesWith(pred, x, ys);
|
---|
54 | }, xs);
|
---|
55 | });
|
---|
56 |
|
---|
57 | module.exports = innerJoin; |
---|