remove the pipeline operator

This commit is contained in:
Yanick Champoux 2019-10-21 11:40:08 -04:00
parent 1147f7c344
commit 6e8b3316a0
4 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,4 @@
module.exports = { module.exports = {
"plugins": [["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }]],
presets: [ presets: [
[ [
'@babel/preset-env', '@babel/preset-env',

View File

@ -4,16 +4,14 @@
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"lodash": "^4.17.15",
"redux": "^4.0.4"
},
"devDependencies": {
"@babel/core": "^7.6.4", "@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3", "@babel/preset-env": "^7.6.3",
"babel-jest": "^24.9.0", "babel-jest": "^24.9.0",
"jest": "^24.9.0", "jest": "^24.9.0",
"lodash": "^4.17.15",
"memoize-getters": "^1.1.0",
"redux": "^4.0.4",
"updeep": "^1.2.0" "updeep": "^1.2.0"
},
"devDependencies": {
"@babel/plugin-proposal-pipeline-operator": "^7.5.0"
} }
} }

View File

@ -62,12 +62,16 @@ function buildMutations({mutations = {}, subduxes = {}}) {
Object.entries(subduxes) Object.entries(subduxes)
); );
globby = globby |> fp.fromPairs |> fp.mapValues( globby =
fp.flow([
fp.fromPairs,
fp.mapValues(
({reducer}) => (_,action={}) => state => ({reducer}) => (_,action={}) => state =>
reducer(state,action) ); reducer(state,action) ),
])(globby);
const globbyMutation = (payload,action) => u( const globbyMutation = (payload,action) => u(
globby |> fp.mapValues( mut => mut(payload,action) ) fp.mapValues( mut => mut(payload,action) )(globby)
); );
actions.forEach( action => { actions.forEach( action => {
@ -86,7 +90,7 @@ function buildMutations({mutations = {}, subduxes = {}}) {
mergedMutations[type].push(mutation); mergedMutations[type].push(mutation);
}); });
return mergedMutations |> fp.mapValues( composeMutations ); return fp.mapValues( composeMutations )(mergedMutations);
} }

View File

@ -35,7 +35,7 @@ test( 'with subduxes', () => {
bar: updux({ bar: updux({
mutations: { mutations: {
foo: () => tracer('d'), foo: () => tracer('d'),
'*': (dummy,a) => { console.log( "got a ", dummy, a ); return tracer('e') }, '*': (dummy,a) => tracer('e'),
}, },
}), }),
}, },