Skip to content

Commit

Permalink
Extract function StringifyFn from Extract Args
Browse files Browse the repository at this point in the history
Original JavaScript commit angular/angular.js@42e622b
  • Loading branch information
mkshiblu committed Jun 27, 2022
1 parent 3aa01bc commit e6c793b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/extract/Injector.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,32 @@
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
var $injectorMinErr = minErr('$injector');
function stringifyFn(fn) {
return Function.prototype.toString.call(fn);
}
function extractArgs(fn) {
var fnText = Function.prototype.toString.call(fn).replace(STRIP_COMMENTS, ''),
var fnText = stringifyFn(fn).replace(STRIP_COMMENTS, ''),
args = fnText.match(ARROW_ARG) || fnText.match(FN_ARGS);
return args;
}
*/


*/
public class Injector {
String ARROW_ARG = "/^([^(]+?)=>/";
String FN_ARGS = "/^[^(]*\\(\\s*([^)]*)\\)/m";
String STRIP_COMMENTS = "/((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg";



StringVar stringifyFn(Object fn) {
return Function.prototype.toString.call(fn);
}

StringVar extractArgs(Object fn) {

StringVar fnText = Function.prototype.toString.call(fn).replace(STRIP_COMMENTS, ""),
StringVar fnText = stringifyFn(fn).replace(STRIP_COMMENTS, ""),
args = fnText.match(ARROW_ARG).match(FN_ARGS);

return args;
}
}

0 comments on commit e6c793b

Please sign in to comment.