All files match.js

100% Statements 53/53
26.32% Branches 5/19
100% Functions 37/37
100% Lines 21/21
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 38 39 40        1x   1x 1x   20x   1x   4x   1x   3x 7x   4x   5x   4x   1x   2x 2x   1x 1x   1x 1x   2x 2x  
import { filtBy, mapTo,some, } from './array';
import { has, } from './has';
import { append, } from './group';
 
export const identity = x => x;
 
const id = identity;
const { assign, } = Object;
 
export const matches = (mFn = id) => a => b => mFn(a) === mFn(b);
 
export const matchBin = (mFn = id) => (a,b) => matches(mFn)(a)(b);
 
export const xMatches = (mFn = id) => a => b => !matches(mFn)(a)(b);
 
export const xMatchBin = (mFn = id) => (a,b) => !matches(mFn)(a)(b);
 
export const mergeMatch = (mFn = id) => b => a => 
  matches(mFn)(a)(b) ? assign({},a,b) : a;
  
export const swapMatch = (mFn = id) => b => a => matches(mFn)(a)(b) ? b : a;
 
export const matchMap = (mFn = id) => coll => mapTo(mFn)(coll);
 
export const hasMatch = (mFn = id) => a => coll => has(matchMap(mFn)(coll))(mFn(a));
 
export const xHasMatch = (mFn = id) => a => coll => !hasMatch(mFn)(a)(coll); 
 
export const addUniq = (mFn = id) => a => coll => 
  some(coll)(matches(mFn)(a)) ? coll : append(coll)(a);
 
export const dropMatch = (mFn = id) => a => coll =>
  filtBy(xMatches(mFn)(a))(coll);
 
export const replaceMatch = (mFn = id) => a => coll =>
  mapTo(swapMatch(mFn)(a))(coll);
 
export const updateMatch = (mFn = id) => a => coll =>
  mapTo(mergeMatch(mFn)(a))(coll);