Giter Club home page Giter Club logo

array-to-tree's People

Contributors

dependabot[bot] avatar taoqf avatar timwis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

array-to-tree's Issues

Unable to generate tree when id or paren_id is too large

Such data cannot generate a tree

var dataOne = [
{
id: 100,
name: 'Portfolio',
parent_id: undefined
},
{
id: 200,
name: 'Web Development',
parent_id: 100
},
{
id: 300,
name: 'Recent Works',
parent_id: 200
},
{
id: 400,
name: 'About Me',
parent_id: undefined
}
];

[Feature request] Add option to skip (deep)cloning

I build trees of objects that shouldn't be cloned, because I want to keep reference. Moreover, cloning messes up my objects that have custom serialization functions.
I will stick to version 3.1.0 until this problem is addressed.

Options parentPropety not working as expected

hi guys, he's the issue I'm facing using parentProperty options.

var data2 =[
{
id: 1,
created_at: '2020-05-09T16:13:04.896Z',
folder_id: 1,
'Filess.name': 'MyFirstLesson'
},
{
id: 2,
created_at: '2020-05-11T16:13:04.896Z',
folder_id: 2,
'Filess.name': 'MyFirstLesson'
},
{
id: 3,
created_at: '2020-05-11T16:13:04.896Z',
folder_id: 3,
'Filess.name': 'MyFirstLesson'
},
{
id: 4,
created_at: '2020-05-09T16:13:04.896Z',
folder_id: 1,
'Filess.name': 'Meeting1'
},
{
id: 5,
created_at: '2020-05-16T16:13:04.896Z',
folder_id: 1,
'Filess.name': 'SetupRoom'
},
{
id: 6,
created_at: '2020-05-17T16:13:04.896Z',
folder_id: 1,
'Filess.name': 'SetupRoom'
},
{
id: 7,
created_at: '2020-05-17T16:13:04.896Z',
folder_id: 1,
'Filess.name': 'SetupRoom'
},
{
id: 8,
created_at: '2020-05-20T15:26:36.656Z',
folder_id: 1,
'Filess.name': 'Annotation 2020-04-08 135240.jpg'
}
]

arrayToTree(data2, {parentProperty: 'folder_id})

returns empty array

[feature request] deep-each-function

arrayToTree(dataTwo, {
  parentProperty: 'parent',
  customID: '_id',
 each:(node)=>{
// here i can �do some things. like choice  the right node to an other list
}
});

this options we can choice some node but no need to deep traverse the whole tree.

Does this work with a nested `parent_id` in each object?

I've been trying to get this to work with a nested parent_id but I can't seem to find the solution.

Say I have:

[
    {
      "id": "1",
      "attributes": {
        "name": "Parent",
        "parent_id": null,
      }
    },
    {
      "id": "2",
      "attributes": {
        "name": "Child One",
        "parent_id": 1,
      }
    },
    {
      "id": "3",
      "attributes": {
        "name": "Child Two",
        "parent_id": 1,
      }
    },
]

Will arrayToTree() work in this situation?

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.