Comparing version 1.0.1 to 1.1.0
@@ -95,3 +95,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
_ref$childBranchList = _ref.childBranchList, | ||
childBranchList = _ref$childBranchList === undefined ? [] : _ref$childBranchList, | ||
childBranchList = _ref$childBranchList === undefined ? {} : _ref$childBranchList, | ||
debug = _ref.debug; | ||
@@ -113,4 +113,4 @@ | ||
var result = void 0; | ||
childBranchList.find(function (childNode) { | ||
return result = childNode.setValue(doFunctionResult); | ||
Object.keys(childBranchList).find(function (branchName) { | ||
return result = childBranchList[branchName].setValue(doFunctionResult); | ||
}); | ||
@@ -273,2 +273,4 @@ return result; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function createAddBranchAction(_ref) { | ||
@@ -278,9 +280,9 @@ var doFunction = _ref.doFunction, | ||
_ref$childBranchList = _ref.childBranchList, | ||
childBranchList = _ref$childBranchList === undefined ? [] : _ref$childBranchList, | ||
childBranchList = _ref$childBranchList === undefined ? {} : _ref$childBranchList, | ||
debug = _ref.debug; | ||
debug("create 'addBranch' method"); | ||
return function (childBranch) { | ||
debug("call 'addBranch' function"); | ||
childBranchList = childBranchList.concat(childBranch); | ||
return function (branchName, childBranch) { | ||
debug("call 'addBranch' function with name", branchName); | ||
childBranchList = Object.assign({}, childBranchList, _defineProperty({}, branchName, childBranch)); | ||
return { | ||
@@ -287,0 +289,0 @@ addBranch: createAddBranchAction({ doFunction: doFunction, conditionFunction: conditionFunction, childBranchList: childBranchList, debug: debug }), |
{ | ||
"name": "horpyna", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "utility to manage async processes", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import createSetValueAction from "./createSetValueAction"; | ||
export default function createAddBranchAction({ doFunction, conditionFunction, childBranchList = [], debug }) { | ||
export default function createAddBranchAction({ doFunction, conditionFunction, childBranchList = {}, debug }) { | ||
debug("create 'addBranch' method"); | ||
return childBranch => { | ||
debug("call 'addBranch' function"); | ||
childBranchList = childBranchList.concat(childBranch); | ||
return (branchName, childBranch) => { | ||
debug("call 'addBranch' function with name", branchName); | ||
childBranchList = Object.assign({}, childBranchList, { [branchName]: childBranch }); | ||
return { | ||
@@ -8,0 +8,0 @@ addBranch: createAddBranchAction({ doFunction, conditionFunction, childBranchList, debug }), |
export default function createSetValueAction({ | ||
doFunction = null, | ||
conditionFunction = () => true, | ||
childBranchList = [], | ||
childBranchList = {}, | ||
debug | ||
@@ -21,4 +21,4 @@ }) { | ||
let result; | ||
childBranchList.find(childNode => (result = childNode.setValue(doFunctionResult))); | ||
Object.keys(childBranchList).find(branchName => (result = childBranchList[branchName].setValue(doFunctionResult))); | ||
return result; | ||
} |
@@ -54,3 +54,3 @@ /* eslint-disable no-unused-vars */ | ||
.do(branchFunctionStub) | ||
.addBranch(Horpyna.when(() => true).do(childBranchFunctionStub)) | ||
.addBranch("subBranchName", Horpyna.when(() => true).do(childBranchFunctionStub)) | ||
.setValue(valueStub); | ||
@@ -57,0 +57,0 @@ expect(result).to.be.equal(childResponseStub); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
397
62433