Comments (5)
Not sure I follow – can you give an example of how the function call and how inputs/outputs would look?
Thanks!
from performant-array-to-tree.
const tree = arrayToTree([
{ id: '4', parentId: null, custom: 'abc' },
{ id: '1941', parentId: ['4', '418'], custom: 'de' },
{ id: '1', parentId: ['418'], custom: 'ZZZz' },
{ id: '418', parentId: null, custom: 'ü'},
])
result:
[
{ data: { id: '4', parentId: null, custom: 'abc' }, children: [
{ data: { id: '1941', parentId: '4', custom: 'de' }, children: [] },
] },
{ data: { id: '418', parentId: null, custom: 'ü'}, children: [
{ data: { id: '1941', parentId: '418', custom: 'de' }, children: [] },
{ data: { id: '1', parentId: '418', custom: 'ZZZz' }, children: [] },
] },
]
from performant-array-to-tree.
Thanks for the example.
Can you give a bit context which use cases that would cover?
It seems to me like a very special use case that would complicate performant-array-to-tree
quite a bit.
from performant-array-to-tree.
It is a special use case, just thought it would be a nice addition to extend the package usage.
Can you give a bit context which use cases that would cover?
A structure where a child can be nested in multiple parent, you can imagine it applied to a nested menu for instance.
Feel free to close the issue if you don't think it's relevant.
from performant-array-to-tree.
This issue must have slipped through the cracks – sorry for that. I am not sure that this feature will be widely used, and feel the negative performance impact a potential implementation could have does not make adding this a good trade-off.
If more users are looking for that feature, I'm happy to re-open this issue.
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
- 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
- Cross reference array gives an empty array 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
- Consider using spread syntax HOT 4
- 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.