New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get all values from a nested array #13
Comments
Yes, this is doable. I wrote up a prototype and while it works, I wasn't satisfied with the potential for edge cases. For example:
If we use the proposed syntax, it would be something like:
This works fine; however, things start to get weird with the following structure:
One would expect the following to work:
The problem is that instead of plucking One way to correct this is to ensure that anytime we see the special Besides, it's quite compose-able as-is if you consider the following example:
or if you know for sure
If not in an ES5 environment, you can use a shim for |
Wonder if you reconsider fixing this since selectn is used in https://github.com/CacheControl/json-rules-engine We have following use case let obj = {
medications: [
{ type: "A" },
{ type: "B" },
{ type: "C" }
]
}; And we need an event triggered if type is one of "A", "C", but selectn("medications.type", obj) would return |
@mavarazy - Given you are expecting a list (array) back, you might be looking for this instead: https://www.npmjs.com/package/array-mapcat
|
@mavarazy Definitely let me know if that does or doesn't work for you or if we need to figure out some other solution. |
Thanks. I worked around that. |
Hey,
It would be really great if I could get a range of values from a nested array. So assume I have an object which looks like this:
I can get them now by calling:
But it would be handy to use something like:
Is that doable somehow?
Thanks
The text was updated successfully, but these errors were encountered: