UNPKG

raid-addons

Version:

Add-ons functions for use with Raid

23 lines (19 loc) 437 B
const squash = key => update => (state, event) => { if (event.type !== key) { return state } return update(state, event.payload) } const compress = updates => { if (typeof updates === 'string') { return squash(updates) } return (state, event, signal) => { let update = updates[event.type] if (update) { return update(state, event.payload, signal) } return state } } export default compress