mardi 19 juillet 2016

How to get a arrow functions's body as string?

How to get code as string between {} of arrow function ?

var myFn=(arg1,..,argN)=>{
         /**
          *Want to parse
          * ONLY which is between { and }
          * of arrow function 
         */ 

 };

If it is easy to parse body of simple function : myFn.toString().match(/function[^{]+\{([\s\S]*)\}$/)[1]; is enough . However, Arrow function does not contains function keyword in its definition .





Aucun commentaire:

Enregistrer un commentaire