js-trees

    1.0.2 • Public • Published

    MaintainabilityTest CoverageBuild Status

    js Trees

    Install

    npm install js-trees
    

    Using

    import { mkNode, hasChildren, map, filter, reduce, findNodes, } from 'js-trees'
    

    Documentation

    Table of Contents

    mkNode

    Make a node

    Parameters

    • name
    • meta
    • children

    Examples

    mkNode('test', { color: 'blue' }, []); // { name: 'test', meta : { color: 'blue'}, [] }

    Returns {children: Array, meta, name: any}

    hasChildren

    Check if Node has a Children

    Parameters

    • node

    Examples

    hasChildren(mkNode('myNode')); // false;
    hasChildren(mkNode('myNode2', {}, [mkNode('myNode3')])); // true

    map

    Map Tree

    Parameters

    • f
    • node

    Returns (any | {children: any})

    filter

    Filter Tree

    Parameters

    • f
    • node

    Returns ({children: any} | null | any)

    reduce

    Reduce Tree

    Parameters

    • f
    • tree
    • acc

    Returns any

    findNodes

    Find all nodes that fet comparator function

    Parameters

    • comparator
    • tree

    Returns any

    Install

    npm i js-trees

    DownloadsWeekly Downloads

    3

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    65.3 kB

    Total Files

    26

    Last publish

    Collaborators

    • vikzh