Closed robross0606 closed 2 years ago
Hello @robross0606 ,
i just stumpled over this issue. A few things. First your issue is pretty rude not to say disrespectful formulated. @YuriGor does a really great job and i am sure you have to admit that, too.
Also since Deepdash uses Lodash, there are a lot of easy ways to circumvent your issue and get the desired result.
// 1. use the `condense`-option `filterDeep` or `pickDeep` so that the initilal structure is preserved.
const deepFilteredResults = _.filterDeep(obj, predicate, { condense: true });
// 2. create the paths out of the result
const paths = _.paths(deepFilteredResults)
// 3. get the result
const values = paths.map((path) => _.get(obj, path)
Hi @robross0606 you can use reduceDeep just use array as accumulator and push only values you need. I wanted to implement something like selectDeep to do such things, but I have no need/free time for this. Feel free to open PR if you'd like.
Thanks @dkdev030 yes you suggest would also work but, if preserving structure is not needed - better to not use filterDeep because it spends resources under the hood to preserve such structure.
@YuriGor yep, reduceDeep
is already precisely what I ended up using. I would have responded sooner, but I purposely took a breather to avoid getting baited by clear trolling from @dkdev030. Thanks for the advice and, yes, the library is clearly useful. 😁
pickDeep
andfilterDeep
can only return a nested structure that matches the original structure. There does not appear to be a way to, for example, pick all the results from a deep structure and return them as a flattened array of values.