Skip to content

Cross reference array gives an empty array #37

@kh0ma

Description

@kh0ma
var performantArrayToTree = require("performant-array-to-tree")

console.log(performantArrayToTree.arrayToTree([
    { num: "4", ref: "31", custom: "abc" },
    { num: "31", ref: "4", custom: "12" },
  ],
  { id: "num", parentId: "ref", childrenField: "nodes", throwIfOrphans: true }
));

// result = []

version: 1.9.1

Actually, I don't have a strong opinion on the expected result from this situation. But it seems strange that the lib silently cut an array. Probably it should be an error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions