Grasp: Structural Search and Replace for JavaScript
graspjs.com
graspjs.com
Grasp is by the author of LiveScript[1].
This was submitted by the author of CoffeeScript[2]
PS. If anyone has any questions about grasp please let me know!
The answer is: https://github.com/gkz/grasp/blob/gh-pages/assets/js/command...
But the real source lies here: https://github.com/gkz/grasp/blob/gh-pages/assets/_ls/comman...
$ cat c.js
f(x < y, x == z);
$ grasp bi --replace '{{.r}}+{{.l}}' c.js
f(y+x, z+x);
In jsgrep, the same substitution could be made by: -f(A < B, B == C)
+f(A + B, B + C)
jsgrep: https://github.com/facebook/jsgrepGrasp has two different query types, the default, squery - selector query, CSS style selectors, and equery (-e, --equery) - example query, JS code examples with wildcards.
In the grasp example above, we are using squery. jsgrep is similar to equery. You could do the following search in equery, and it would be more equivalent to the example you posted:
f(__ < __, __ == __)
The only thing missing is the named wildcards for easy replace - that's a good idea and a feature to add to grasp 0.2.0!You can check out the docs on squery (http://graspjs.com/docs/squery/) and equery (http://graspjs.com/docs/equery/)
-foo(A, B, true)
+fooWithOption(A, B)I've asked on GH, but I guess I can repeat the question here: any plans to create a SublimeText plugin for this?
Great job!