Skip to content

Commit

Permalink
fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
BenzLeung committed Aug 2, 2019
1 parent ba02008 commit f791056
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions BenzAMRRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,10 +977,13 @@
}
return ret
};
var sourceRegex = /^function\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
var sourceRegex = /^function\s\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;

function parseJSFunc(jsfunc) {
var parsed = jsfunc.toString().match(sourceRegex).slice(1);
// Match the body and the return value of a javascript function source
var parsed = jsfunc.toString().match(sourceRegex);
if (!parsed) { return {}; }
parsed = parsed.slice(1);
return {arguments: parsed[0], body: parsed[1], returnValue: parsed[2]}
}

Expand Down
2 changes: 1 addition & 1 deletion BenzAMRRecorder.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion BenzAMRRecorder.min.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/amrnb.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,13 @@ var AMR = (function () {
}
return ret
};
var sourceRegex = /^function\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
var sourceRegex = /^function\s\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;

function parseJSFunc(jsfunc) {
var parsed = jsfunc.toString().match(sourceRegex).slice(1);
// Match the body and the return value of a javascript function source
var parsed = jsfunc.toString().match(sourceRegex);
if (!parsed) { return {}; }
parsed = parsed.slice(1);
return {arguments: parsed[0], body: parsed[1], returnValue: parsed[2]}
}

Expand Down

0 comments on commit f791056

Please sign in to comment.