Giter Site home page Giter Site logo

Comments (5)

philipstanislaus avatar philipstanislaus commented on May 18, 2024

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.

hexadeciman avatar hexadeciman commented on May 18, 2024
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.

philipstanislaus avatar philipstanislaus commented on May 18, 2024

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.

hexadeciman avatar hexadeciman commented on May 18, 2024

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.

philipstanislaus avatar philipstanislaus commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.