How to use map2tree - 1 common examples

To help you get started, we’ve selected a few map2tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reduxjs / d3-state-visualizer / src / charts / tree / tree.js View on Github external
return function renderChart(nextState = tree || state) {
    data = !tree ? map2tree(nextState, {key: rootKeyName, pushMethod}) : nextState

    if (isEmpty(data) || !data.name) {
      data = { name: 'error', message: 'Please provide a state map or a tree structure'}
    }

    let nodeIndex = 0
    let maxLabelLength = 0

    // nodes are assigned with string ids, which reflect their location
    // within the hierarcy; e.g. "root|branch|subBranch|subBranch[0]|property"
    // top-level elemnt always has id "root"
    visit(data,
        node => {
          maxLabelLength = Math.max(node.name.length, maxLabelLength)
          node.id = node.id || 'root'
        },

map2tree

Utility for mapping maps to trees

MIT
Latest version published 7 months ago

Package Health Score

77 / 100
Full package analysis

Popular map2tree functions