All files compare.js

100% Statements 21/21
100% Branches 0/0
100% Functions 14/14
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37              2x       4x       2x       2x 2x       5x 5x       2x 2x       1x 1x  
// requires [has](has.html), [spread](spread.html), and [reducers](reducers.html)
import { spread, spreadKV, } from './spread';
import { addBin, addBinMap, } from './reducers';
import { hasK, hasKV, xhasK, xhasKV, } from './has';
 
// **inter** `:: Iterable<a> -> Iterable<a> -> [a]`  
// returns elements shared between two iterables;
export const inter = c0 => c1 => spread(c0).filter(hasK(c1));
 
// **diff** `:: Iterable<a> -> Iterable<a> -> [a]`  
// returns elements of the first iterable absent from the second iterable
export const diff = c0 => c1 => spread(c0).filter(xhasK(c1));
 
// **union** `:: Iterable<a> -> Iterable<a> -> [a]`  
// returns elements of both iterables
export const union = c0 => c1 => spread(c0).concat(diff(c1)(c0));
 
// **mapInter** `:: Map[{k:v}] -> Map[{k:v}] -> Map[{k:v}]`  
// returns elements shared between two maps;
export const mapInter = c0 => c1 =>
  spread(c0).filter(hasKV(c1)).reduce(addBinMap, new Map);
 
// **mapDiff** `:: Map[{k:v}] -> Map[{k:v}] -> Map[{k:v}]`  
// returns elements of the first map absent from the second map
export const mapDiff = c0 => c1 =>
  spread(c0).filter(xhasKV(c1)).reduce(addBinMap, new Map);
 
// **mapUnion** `:: Map[{k:v}] -> Map[{k:v}] -> Map[{k:v}]`  
// returns elements of both maps
export const mapUnion = c0 => c1 =>
  spread(mapDiff(c1)(c0)).reduce(addBinMap, new Map(c0));
 
// **mapUnion** `:: Map[{k:v}] -> Map[{k:v}] -> Map[{k:v}]`  
// returns elements of both maps
export const uniteMap = c0 => c1 =>
  spread(mapDiff(c1)(c0)).reduce(addBinMap, c0);