nepsilon / search-query-parser

A simple parser for advanced search query syntax
https://www.npmjs.org/package/search-query-parser
MIT License
252 stars 40 forks source link

feat: add stringify function #31

Closed jaulz closed 3 years ago

jaulz commented 5 years ago

This PR will add a stringify function which can convert a parsed search query object to a string. I added a part to every test where the parsed search query is stringified and parsed again. If the object equals the previous parsed object (except for the offsets) we can consider it as successful.

nepsilon commented 5 years ago

Thanks, Jaul. Can you as well update the readme? Showing usage examples and updating unit tests count.

jaulz commented 5 years ago

@nepsilon here you go. Number of unit tests stays the same since every existing test is a test for stringify at the same time.

jaulz commented 5 years ago

@nepsilon anything else you need? 😊

nepsilon commented 5 years ago

I should be able to test and merge later next week. Thanks for your contrib!

jaulz commented 5 years ago

@nepsilon great! Let me know if you need anything from my side.

sqwk commented 4 years ago

Does this keep the order of the original string? Just reading through the changed README.md, it seems like adding a new keyword reshuffles the original searchQuery, moving text to the front of the string and inserting the new keyword somewhere in the middle instead of the end?

jmcudk commented 4 years ago

Any reason that this still hasn't been merged?

twodayslate commented 4 years ago

I'd rather not have to pass in the options to get a usable string

sam-jg commented 3 years ago

Been a while, but any chance this will be merged or should I just fork it?

nepsilon commented 3 years ago

@sam-jg Thanks for the reminder. I merged this (along with some other MR). Tests are all green. I also bumped dev dependencies and re-generated the lock file. A new version has been published (v1.6.0).

sam-jg commented 3 years ago

Amazing thanks!