Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Range Operations Documentation needs updating #6

Open
shomali11 opened this issue Mar 28, 2021 · 4 comments
Open

Range Operations Documentation needs updating #6

shomali11 opened this issue Mar 28, 2021 · 4 comments
Labels

Comments

@shomali11
Copy link

Every section has the same text and example:
https://github.com/aprilmintacpineda/jql/blob/master/packages/jql-matcher/docs/operations/range.md

@aprilmintacpineda
Copy link
Owner

Aha! haha rookie copy-paste mistake :D

@shomali11
Copy link
Author

No worries! I figured you missed it haha!

I really like your library. Would you consider exposing an API that tests whether a JSON Object matches the Query? It would return a Boolean.

Currently I am wrapping your API with a method that passes the object in an array into your method and checking whether the length of the resulting array is not 0.

I figured it would be more memory efficient if an “isMatch(query, object) boolean” api was available

@aprilmintacpineda
Copy link
Owner

hmmm, can you give an example use case? I don't quite understand...

@shomali11
Copy link
Author

Imagine a case where you get a stream of JSON objects, one by one, and you are scanning each of them to see if they match a specific query. If it’s a match, you process it, if not you ignore it.

so to do this using your library, I created this function

function isMatch(query, object) {
return jql(query, [object]).length !== 0
}

...

Then somewhere in my app,

for (const object of someIterableOrGenerator()) {
if (isMatch(query, object)) {
// Do something with object
}
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants