New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

breaktree

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

breaktree

Package to identify the root parent and shortest child in database system

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

Break the complex tree structures in your db and get the data in simple form to use it in your app

  • Use the below function to get the hierarchy of the any attribute
    var breaktree = require('breaktree');
    breaktree.getHierarchy(test,attribute,attributes)

    The structure for the object must be in this form

    test : Will be an Empty Array in which you will get the hierarchy
    Eg: []

    attribute: Attribute for which you want the hierarchy
    Eg:{id: 5,name: 'child Element',parent: 4 }

    attributes: List of Attributes

    Eg: [{id: 5,name: 'Child 1',parent: 1 },{id: 1,name: 'Top parent',parent: null },{id: 2,name: 'Child 1',parent: 1 },{id: 3,name: 'Child 3',parent: 2 },{id: 4,name: 'Child 4',parent: 3 },{id: 5,name: 'child Element',parent: 4 },{id: 6,name: 'Child 6',parent: 5 } ]

    The result you will get in the test array as

    [{"id":4,"name":"Child 4"},{"id":3,"name":"Child 3"},{"id":2,"name":"Child 1"}]

    The test array will contain the data from low to high parent hierarchy.If you want it the opposite way you can just reverse the array

  • Use the below function to get the top root of any nested element
    var breaktree = require('breaktree');
    breaktree.getRoot(attributes,attribute,root) 

    The structure for the object must be in this form

    attributes: List of Attributes

    Eg: [{id: 5,name: 'Child 1',parent: 1 },{id: 1,name: 'Top parent',parent: null },{id: 2,name: 'Child 1',parent: 1 },{id: 3,name: 'Child 3',parent: 2 },{id: 4,name: 'Child 4',parent: 3 },{id: 5,name: 'child Element',parent: 4 },{id: 6,name: 'Child 6',parent: 5 } ]

    attribute: Attribute for which you want the root
    Eg:{id: 5,name: 'child Element',parent: 4 }

    root : Will be an Empty Array in which you will get the root element
    Eg: []


    The result you will get in the root array as

    [{id: 1,name: 'Top parent',parent: null }]

Keywords

root

FAQs

Package last updated on 18 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts