Comments (8)
Ok, I will review it tonight.
Thank you for contribution!
from deepdash.
Hi!
I'll think about 1. - sounds good
2. is already implemented, take a look at childrenPath option
3. I'll take a look, thank you for idea. Hope transpiler will generate clean enough code for spread.
from deepdash.
Thanks for the quick response!
About suggestion 2, the childrenPath specifies what paths will be sent to the user's callbacks, but the iteration process scans all paths, while it can just scan by the paths the user specified (as far as I've seen, if I'm wrong please tell me how to use it properly to reduce scan time)
from deepdash.
If childrenPath is specified - deepdash doesn't visit other paths.
If you see it's not so in some cases - let me know, it's a bug.
At getIterate.js look at :97 (children only case) and :105 (full scan case)
from deepdash.
the thing is, filterDeep uses condenseDeep (if the condense flag wasn't set to false) , which uses eachDeep.
(filterDeep ==> condenseDeep ==> eachDeep)
when condenseDeep calls eachDeep, it doesn't supply the entire options object that the user specified in the filterDeep call, but only part of it :
var eachDeepOptions = { checkCircular: options.checkCircular, };
this causes a full scan.
moreover, I've replaced the concat with spread, which did result in a big performance improvement. as can be seen here:
I forked the repository to submit a pull request, but unfortunately, as you said, the transpiler turned it back to concat. Are there configurations that can be made? I've never used this transpiler before.
from deepdash.
Maybe it's a good idea to extend options to let user collapse only holes caused by filtration, and keep other empty slots untouched.
It's a pretty complicated way - I will need to remember paths rejected by a filtration process,
check each level in the path if it's the beginning or middle of some array and, instead of total deep condensing, surgically collapse specific holes, considering each array could have other holes originally or left by another rejected path.
In case some array has multiple holes left by several rejected paths - it will be a pain to recalculate
shifted indexes on each collapsed hole, to keep rest of remembered rejected paths correct.
As a dirty alternative - I can remember not a paths rejected by a filter, but only arrays affected by such rejection. And after filtering process is done - just condense all these arrays.
In this case, some originally existing holes will be collapsed too, but some - will not. So this case is good only for an initially condensed object.
Yeah, I think it will be good enough to give the user a choice:
- don't condense result at all (so user will be able to use condenseDeep explicitly if he needs)
- 'dirty' condense only affected arrays and gain some performance - in case of initially condensed data this option will work perfectly.
About spread / concat - there is a separate deepdash-es module - it's not transpiled.
Please don't hurry with a PR for now - there are upcoming changes in the lib build process I want to finalize first.
from deepdash.
Actually, after I've seen the performance results of using spread instead of concat, maybe adding the other 2 options that we have discussed are overhead, because the improvement is quite big by itself.
I do think the change in deepdash-es is important and it's really quick with no side effects. I made the PR there , under es/private/getIterate.js. (hope that's what you meant).
it's really important for my usage.
This is the PR #34 .
Thanks for the quick response and discussion!
from deepdash.
Merged and published as v4.2.14
Please test and put a star if everything still works 😉
from deepdash.
Related Issues (20)
- omitDeep changes input on empty array HOT 1
- omitDeep doesn't omit objects HOT 7
- ERR_PACKAGE_PATH_NOT_EXPORTED HOT 3
- how to remove values from json if they exist
- Feature Request Parent path
- filterDeep not working on deeply nested object HOT 2
- Working with promises HOT 2
- Frustrating that things like `pickDeep` and `filterDeep` can only return a nested structure HOT 3
- deepdash-es not working with jest-resolve HOT 9
- deepFilter keep parents
- ESM: IIterateeContext typescript interface not exposed
- findPathDeep doesn't return first Value path
- findDeep or findDeepValue - Return object that contains the key & value
- eachDeep with childrenPath == wrong parent, parent path etc
- Bug in documentation _.findDeep*
- findDeep return types problem HOT 3
- Add contributing docs HOT 1
- findDeep is not a function HOT 1
- explicit return values, why and how does this work HOT 1
- mapValuesDeep mutates the original object if `leavesOnly: false` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepdash.