There’s more to programming than just writing code. While unlikely, it is possible to write imperfect code the first time through, or have requirements change over time. In these cases, you have to refactor the code you’ve already written to fix mistakes and change functionality.
You can go about refactoring your code in several ways; a small change can be done manually, but a larger change requires a tool to automate the task. Many programmers use regular expressions to modify their code - but are they the best choice? Programs such as sed that use regular expressions view your code as simply a blob of text - it’s 2014, we can do better than that!
Grasp is a command line utility that allows you to search and replace your JavaScript code, with one important distinctive feature: it searches the structure behind your code (the abstract syntax tree), rather than simply the text you’ve written. That means Grasp is smart! It knows the difference between an if statement and an identifier, and it knows what parts make up those nodes (eg. an if statement has a test, a consequent, and optionally an alternative - the else). It combines this with an easy to understand syntax for searching and replacing, making it an incredibly powerful tool for refactoring your JavaScript code.