Comments (1)
Hi, looks like you mixing docs for eachDeep and filterDeep.
eachDeep will not care about returned value unless it's exactly boolean false
.
In this case eachDeep will skip current children if any, so it's kind of 'break' in for loop, but local for current depth level.
This is similar to convention of Lodash each method.
filterDeep similar to Lodash or native array filter method expects true or false from predicate to decide keep current value or not.
Because filterDeep case is much more complex, I extended this convention and also accept undefined
as possible return result. If "truthy" reply will be "yes" and "falsey" response will be "no", undefined
means "Don't know yet"
In case of undefined
current value will be preserved in result only in case some children values will also be preserved. If finally in result such value will be childless - it will be cleared out.
filterDeep
deep doesn't care too much about true or false result data type, 0 or null will also work as false. It only cares about undefined
as separate from false
reply, so undefined
is not falsey from filterDeep point of view.
If you are not sure yet you can read about Truthy and Falsy values in JS.
Note: if in some case you function will not return something - it will mean function will still return undefined
implicitly.
I guess this is your point of confusion. So you can of coarse return just result of evaluation of some boolean value, you don't need to return exactly true
or false
, in case of eachDeep just make sure your false result is really boolen, not undefined
or 0
wich in boolean expressions are considered as false, but if you check it with ===
operator - it will be different.
And in case of filterDeep you can return any truthy/falsy values, but be carefull with undefined
because it's a separate reply.
To have better idea how deepdash works with complex nested data - I recomment first to learn how Lodash / JS array forEach
and filter
methods work. They work similar, but Lodash also supports objects, not only arrays, and in Lodash there is return false ==> break convention exists, while native JS forEach doesn't support it.
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
- 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.