Comments (5)
Good find, I agree, there should be an error on circular structures.
from performant-array-to-tree.
Would you have time to create a PR for this?
from performant-array-to-tree.
Temporary in my project I did it the following way:
- call arrayToTree with a given array
- count entries in Tree
- compare the length of an array vs "length" of Tree
Here we can count on Tree length w/o needs to recalculate it. So will validate it at the end.
Do we care about backward compatibility?
Should it be a config throwIfCircular: true
similar to throwIfOrphans: true
?
from performant-array-to-tree.
Sorry for the delay in resolving this.
I just checked out the current code, and realized that this is actually a special case of throwIfOrphans
, since any items with a circular parent/child relationship would just be a group of orphans that will not be part of the tree.
from performant-array-to-tree.
Released in https://www.npmjs.com/package/performant-array-to-tree/v/1.10.0
from performant-array-to-tree.
Related Issues (20)
- Add support for parentId = undefined or Integer? HOT 2
- Add support for parentId as empty string ("") HOT 3
- throwIfOrphans: true and input array elements order HOT 2
- Add multiple parent ids HOT 5
- Enable nested id and parentId properties HOT 3
- Add `rootParentId` option to fit the case when all rows contain a valid parentId string HOT 4
- Add support for custom "children" value if a node doesn't have children? HOT 1
- Would you like to try my “@zhengxs/js.tree”,the same idea HOT 1
- { id: ".key" } does not work HOT 1
- Prototype is Losted HOT 5
- null/undefined exception with nested id and parentId properties HOT 2
- ParentID 0 returns empty array HOT 1
- Return child nodes in tree structure? HOT 1
- Is there a way to omit children key if there is no child nodes? HOT 2
- Parent ID Issue HOT 1
- [Feature Request] Pass type for data property with Generics HOT 3
- feature request: support pick item props HOT 1
- Add option to include parent in the result
- Fix coveralls reporting by migrating to IstanbulJS 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 performant-array-to-tree.