Skip to content

Commit

Permalink
Merge 21510d5 into 2002eba
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagonal committed Dec 27, 2017
2 parents 2002eba + 21510d5 commit 7641b20
Show file tree
Hide file tree
Showing 7 changed files with 4,047 additions and 192 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: node_js
node_js:
- "6"
- "5"
- "4"
- "9"
- "8"
12 changes: 3 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const get = (str, obj, fallback) => {
};
const str2fn = (obj, str, fallback) => get(str, obj, fallback);

const execute = (callString, obj, context, executeDone) => {
const execute = async(callString, obj, context) => {
const getExpression = (param) => {
if (param.type === 'MemberExpression') {
return `${getExpression(param.object)}.${param.property.name}`;
Expand All @@ -37,12 +37,7 @@ const execute = (callString, obj, context, executeDone) => {
};
const split = callString.split('(');
const funcName = split[0];
let func;
try {
func = str2fn(obj, funcName);
} catch (e) {
return executeDone(e);
}
const func = str2fn(obj, funcName);
// eval params from param string:
const paramString = `[${restOf(split).join('(').slice(0, -1)}]`;
const parsedArgs = jsep(paramString);
Expand All @@ -56,8 +51,7 @@ const execute = (callString, obj, context, executeDone) => {
}
params.push(getExpression(param));
});
params.push(executeDone);
func.apply(this, params);
return func.apply(this, params);
};

str2fn.get = get;
Expand Down
Loading

0 comments on commit 7641b20

Please sign in to comment.