UNPKG

@girders-elements/core

Version:

Girders Elements is an architectural framework that assists with building data-driven apps with React or React Native.

22 lines (19 loc) 485 B
'use strict' import { curry } from 'ramda' import { isOfKind } from '../data' import { postWalk } from '../zip' export const editCond = curry((patterns, zipper) => postWalk(el => { patterns.forEach(pattern => { const pred = pattern[0] const updateFn = pattern[1] if ( (typeof pred === 'function' && pred(el)) || (typeof pred !== 'function' && isOfKind(pred, el)) ) { el = updateFn(el) } }) return el }, zipper) )