Comments (7)
As I see in your example - adding checkCircular:true helps
But it still looks strange for me why this 'self' property visited if childrenPath option specified,
So I will need to check it.
dump code here to not loose it if you will update your example:
var data = [
{
"id": "dh8ge0",
"name": "Long it takes",
"type": "distance",
"self": this,
"value": 2
},
{
"id": "z765tghj",
"name": "Capability 01",
"type": "checkbox",
"state": "active",
"self": "COMPONENT",
"changed": {
"_isScalar": false,
"observers": [],
"closed": false,
"isStopped": false,
"hasError": false,
"thrownError": null,
"__isAsync": false
}
},
{
"id": "fh390hdas",
"name": "Wildy",
"self": "COMPONENT",
"type": "wildcard"
}
]
console.clear()
console.log(data)
const newData = filterDeep(data, node => node.id !== 'z765tghj', {
checkCircular: true,
childrenPath: ['children'],
onFalse:{skipChildren:true}}
);
console.log(newData);
from deepdash.
Just for ur information I got it working by getting rid of the circular dependency which should not be there so thanks for giving me this hint.
This is my final solution:
const newList: ZoneItem[] =
filterDeep(
this.zones[index].items,
(value: ZoneItem): boolean => {
return value.id !== itemId
},
{
childrenPath: ['children'],
onFalse: { skipChildren: true },
}
) || []
from deepdash.
Hi, the only way I know to have infinite loop is to have circular references in your data - in this case, you need to enable checkCircular
option.
If it's not the case then you found a bug, please share how to reproduce it.
Here is an example similar to what you need:
https://codepen.io/yurigor/pen/qBbbXxY?editors=0010
You can fork this pen, put your data and check if it's working for you.
But please share how did you got infinite loop.
from deepdash.
Here is a reproducible example: https://stackblitz.com/edit/angular-ivy-b8uhnv?file=src%2Fapp%2Fhello.component.ts
I found out that there is a circular references inside self. Can I exclude this key explicitly?
from deepdash.
So if it's a circular ref then no bug here just enable circular check.
To exclude check keepCircular
or replaceCircularBy
filterDeep options
from deepdash.
Ok, found, we need to checkCircular in filterDeep in case of childrenPath is specified and circular reference is not one of some children because of condensing.
Bu default filterDeep result is deeply condensed, and condenseDeep
method does not support 'childrenPath' option, so it will go over all the properties.
So it's not a bug, but kind of inefficiency I will improve this in a separate task.
from deepdash.
Yeah, looks good. If you can avoid circular refs - better to do it, because checking for circular references in filterDeep impacts performance.
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.