function play (state, x, y) { let changes = flow( filter(p => state.board[p.y][p.x] === oppositeColor(state.current_turn)), map(p => findGroupAndFreedoms(state, p.x, p.y)), filter(found => found.freedoms.length === 1), flatMap(found => found.group), uniqWith(isEqual) )(neighboringPoints(x, y, state.size)); let ko = null; if (changes.length === 1) { let isKo = flow( differenceWith(changes, isEqual), every(p => state.board[p.y][p.x] === oppositeColor(state.current_turn)) )(neighboringPoints(x, y, state.size)); if (isKo) { ko = changes[0]; } } changes.unshift({ x, y, color: state.current_turn }); return { changes, ko }; }
take, takeLatest, select, call, } from 'redux-saga/effects'; import keys from 'lodash/fp/keys'; import map from 'lodash/fp/map'; import get from 'lodash/fp/get'; import every from 'lodash/fp/every'; import flow from 'lodash/fp/flow'; import castArray from 'lodash/fp/castArray'; import api from 'store/api'; const isCachedAction = flow( castArray, every(get('meta.fromCache')) ); export function* getRateLimit(actions) { if (isCachedAction(actions)) { const latestRateLimit = yield select(get('cache.rateLimit.latest')); yield put({ payload: latestRateLimit, type: 'API_RATE_LIMIT_SUCCESS', }); return; } try { const rateLimit = yield call(api.get, 'rate_limit'); yield put({