This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create and return a new array with the separator interposed between elements. | |
* | |
* intersperse :: a -> [a] -> [a] | |
* | |
* Providing the separator as the first argument allows this method to be easily | |
* curried and composed with other functions; follows the "data last" approach. | |
* | |
* @param {*} separator | |
* @param {*} array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const APP = "r3"; | |
export const createActionType = app => duck => type => `${app}/${duck}/${type}`; | |
export const createDuckType = createActionType(APP); | |
/** | |
* Constructs a new action with a required type and optional additional action properties supplied as | |
* optional argument(s*); *see `...rest` param below. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2020-09-28T14:06:24.326Z","extensionVersion":"v3.4.3"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example on codepen https://codepen.io/jagretz/pen/aGeMoJ | |
// If you would like a production version, use complete, tested, performant, and | |
// well-supported version https://github.com/facebook/emitter | |
/** | |
* Subscribe to and control when events are emitted to subscribers. | |
*/ | |
class EventEmitter { | |
constructor() { | |
// k,v store of events to subscribers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Supply multiple reducer functions, as arguments, and return a new reducer function that pipes the | |
* state and action through each reducer in sequence. | |
* @param {...functions} reducers like (arg1, arg2, ...), as a serires of arguments. | |
* @return {function} a new reducer function that pipes the state and action through each reducer in sequence. | |
* Each successive reducer will receive the updated returned by the previous reducer. | |
*/ | |
export default function reduceReducers(...reducers) { | |
return (currentState = {}, action = {}) => | |
reducers.reduce((updatedState, red) => red(updatedState, action), currentState); |