All files board.js

100% Statements 17/17
100% Branches 6/6
100% Functions 8/8
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20              2x 2x 2x   3x 2x   2x 2x   2x 2x  
import { some, } from 'fenugreek-collections';
import { Graph, } from 'graph-curry';
import { Components, Grid, } from 'game_grid';
import { id, } from './player';
import { copy, } from './node';
import { byExcess, byPlayer, exceeds, } from './filter';
 
const { graph, nodes, } = Graph;
const { genNodes: gen, } = Grid;
const { omniComps, } = Components;
 
export const genNodes = (c = 7, r = 6) => gen(c, r).map(copy);
export const board = (c = 7, r = 6) => graph(...genNodes(c, r));
 
export const playerNodes = b => p => byPlayer(nodes(b))(id(p));
export const playerGraph = b => p => graph(...playerNodes(b)(p));
 
export const hasWinComp = (g, n = 3) => some(omniComps(g))(exceeds(n));
export const winComps = (g, n = 3) => byExcess(n)(omniComps(g));