Edit: For clarification, I'm looking for a JavaScript or TypeScript refactoring transpiler. I want to do the rename at build time, not at runtime.
I would like to use a particular library, but its API does not fit with the naming style of my own codebase (sound familiar?) so I want to override the API calls with identical calls that use the coding conventions of my own code.
But this introduces a lot of runtime overhead, with over a hundred methods introduced into prototypes to change the signature of the objects.
Object.defineProperty(Room.prototype, 'getController', {get: function () {return this.controller}});
Instead, if I could introduce a compilation step that executed refactoring rules on the API calls, my code could us my preferred API but the result code could use the published API. I have not been able to find a JavaScript refactoring tool that has a DSL for executing repetitive refactoring requests, something like:
rename(Room.prototype.controller, 'getController')
Searching for 'automatic refactoring' brings up dozens of pie-in-the-sky projects for making code better with no human input. That's not what I want; I just want to introduce manually-entered, scripted refactoring into my build pipeline to shield the working code from the differing naming conventions of external APIs.
Aucun commentaire:
Enregistrer un commentaire