source: node_modules/ramda-adjunct/es/overlaps.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: 929 bytes
RevLine 
[d24f17c]1import { pipe, intersection, isEmpty, curryN } from 'ramda';
2import isNotEmpty from './isNotEmpty';
3
4/**
5 * Returns true if two lists have at least one element common to both lists.
6 *
7 * @func overlaps
8 * @memberOf RA
9 * @category Relation
10 * @since {@link https://char0n.github.io/ramda-adjunct/2.30.0|v2.30.0}
11 * @sig [a] -> [a] -> Boolean
12 * @param {Array} list1 The first list
13 * @param {Array} list2 The second list
14 * @return {boolean} True if two lists have at least one element common to both lists
15 * @example
16 *
17 * RA.overlaps(['-v', '--verbose'], ['node', 'script.js', '-v']); //=> true
18 * RA.overlaps(['-v', '--verbose'], []); //=> false
19 * RA.overlaps([1, 2, 3], [3, 4, 5]); //=> true
20 * RA.overlaps([1, 2, 3], [4, 5]); //=> false
21 */
22
23var overlaps = curryN(2, function (list1, list2) {
24 if (isEmpty(list1)) {
25 return true;
26 }
27 return pipe(intersection, isNotEmpty)(list1, list2);
28});
29export default overlaps;
Note: See TracBrowser for help on using the repository browser.