esquery icon indicating copy to clipboard operation
esquery copied to clipboard

Feature Request: Add a method for converting a selector object to a string

Open StyleShit opened this issue 1 year ago • 1 comments

Currently, the parsing is a one-way ticket, you can take a string and convert it to a selector object. I propose that we'll have a way to go the other way around - taking a selector and converting it to a string.

Roughly something like this:

const filter = 'MethodDefinition[value.typeParameters]';
const selector = esquery.parse(filter);
const unparsed = esquery.unparse(selector);

filter === unparsed; // true

(not sure about the name though)

I'm willing to send a PR for this if this is something that you think can be done properly by someone who's unfamiliar with the codebase (yet 😄)

StyleShit avatar Jan 25 '24 06:01 StyleShit