01mf02 / jaq

A jq clone focussed on correctness, speed, and simplicity
MIT License
2.7k stars 67 forks source link

Implement indices, index and rindex. #158

Closed kklingenberg closed 6 months ago

kklingenberg commented 8 months ago

This PR implements indices and copies jq's derivative implementations of index and rindex according to the spec here. Note that jq has TODO's related to performance on said implementations, so perhaps you'd want to close this PR and wait for a performant version of these filters.

~Also, the behaviour of jq's indices varies slightly when dealing with strings. I reported/asked about it here: https://github.com/jqlang/jq/issues/3030~ (my mistake; jq solved the issue in 1.7)

Closes #154

01mf02 commented 6 months ago

Thanks a lot, this is some great work! Just for future reference, in tests, it is preferable to use yields! instead of gives, because it allows for much more compact tests with names.