Skip to content

Commit

Permalink
Fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
markuplab committed Nov 9, 2015
1 parent edf2d1f commit 034ac20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"no-new-wrappers": 2,
"no-octal": 1,
"no-octal-escape": 2,
"no-param-reassign": 1,
"no-param-reassign": 0,
"no-process-env": 0,
"no-proto": 2,
"no-redeclare": 2,
Expand Down Expand Up @@ -318,4 +318,4 @@
"no-bitwise": 0,
"no-plusplus": 0
}
}
}
46 changes: 20 additions & 26 deletions src/appstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = {
// Start recursive run tree branches
runBranch(0, { tree, args, signal, promise, start, state });
});
}
};
}
};

Expand Down Expand Up @@ -92,9 +92,11 @@ function runBranch (index, options) {
return;
}

return Array.isArray(currentBranch) ?
runAsyncBranch(index, currentBranch, options) :
if (Array.isArray(currentBranch)) {
runAsyncBranch(index, currentBranch, options);
} else {
runSyncBranch(index, currentBranch, options);
}
}

/**
Expand Down Expand Up @@ -188,26 +190,25 @@ function runSyncBranch (index, currentBranch, options) {
action.outputPath = result.path;
var output = action.outputs[result.path];

var result = runBranch(0, {
var runResult = runBranch(0, {
args, signal, state, start, promise,
tree: {
actions: tree.actions,
branches: output
}
});

if (result && result.then) {
return result.then(function () {
if (runResult && runResult.then) {
return result.then(() => {
return runBranch(index + 1, options);
});
} else {
return runBranch(index + 1, options);
}
} else {

return runBranch(index + 1, options);
}
return runBranch(index + 1, options);
} catch (e) {
console.log(e.stack);
// do nothing...
}
}

Expand All @@ -233,11 +234,11 @@ function addOutputs (action, next) {
next.success = next.bind(null, 'success');
next.error = next.bind(null, 'error');
} else if (Array.isArray(action.outputs)) {
action.outputs.forEach(function (key) {
action.outputs.forEach(key => {
next[key] = next.bind(null, key);
});
} else {
Object.keys(action.outputs).forEach(function (key) {
Object.keys(action.outputs).forEach(key => {
next[key] = next.bind(null, key);
});
}
Expand Down Expand Up @@ -267,7 +268,7 @@ function createNextFunction (action, resolver) {
} else {
next._result = result;
}
}
};
}

/**
Expand Down Expand Up @@ -348,8 +349,7 @@ function getStateMutatorsAndAccessors (state, action, isAsync) {
methods = methods.concat(accessors);
}

var stateMethods = Object.create(null);
methods.reduce((stateMethods, methodName) => {
return methods.reduce((stateMethods, methodName) => {
var method = state[methodName].bind(state);

stateMethods[methodName] = (...args) => {
Expand All @@ -359,7 +359,7 @@ function getStateMutatorsAndAccessors (state, action, isAsync) {
if (Array.isArray(firstArg)) {
path = args.shift();
} else if (typeof firstArg === 'string') {
path = [args.shift()]
path = [args.shift()];
}

if (args.length === 0) {
Expand All @@ -376,9 +376,7 @@ function getStateMutatorsAndAccessors (state, action, isAsync) {
};

return stateMethods;
}, stateMethods);

return stateMethods;
}, Object.create(null));
}

/**
Expand Down Expand Up @@ -429,7 +427,7 @@ function transformAsyncBranch (action, parentAction, path, actions, isSync) {
path.pop();
return result;
})
.filter(action => !!action);
.filter(branch => !!branch);
}

/**
Expand All @@ -447,10 +445,6 @@ function transformAsyncBranch (action, parentAction, path, actions, isSync) {
* }|undefined}
*/
function transformSyncBranch (action, parentAction, path, actions, isSync) {
if (typeof action !== 'function') {
return;
}

var branch = {
name: getFunctionName(action),
args: {},
Expand Down Expand Up @@ -538,8 +532,8 @@ function getFunctionName (fn) {
*/
function merge (target, source) {
source = source || {};
return Object.keys(source).reduce(function (target, key) {
target[key] = source[key];
return Object.keys(source).reduce((targetKey, key) => {
targetKey[key] = source[key];
return target;
}, target);
}

0 comments on commit 034ac20

Please sign in to comment.