Closed ptbrowne closed 9 years ago
I tried with esprima and escodegen and I managed to do what I wanted. Now I guess I have to manage to do it and leaving the other lines undisturbed. I think I am going to try with recast (https://github.com/benjamn/recast).
https://github.com/ptbrowne/ast/blob/master/tasks/reordering-define.js
Hi,
I am using
requirejs
for my project and I would like to know ifgrasp
would be suitable to do the reordering of the arguments according to a specified order.Background:
requirejs
'sdefine
works like this:I want to reorder the arguments according to a function of my choosing, giving priorities: jQuery, underscore etc.. first, then my Backbone views, then my Backbone models and then all the other modules. My views and models are respectfully in
views/
andmodels/
so I can match the path of the module to know its priority.I guess the priority giving function would look something like:
So the input would be
and the output
It seems that grasp cannot handle complex cases like this where the reordering is dynamic. Or can it ?
If Grasp cannot do it, what tool would you recommend ?
Thanks !