index.js
function _flattenProofBranches(proofBranchArray) {
  let flatProofAnchors = []

  _forEach(proofBranchArray, proofBranch => {
    let anchors = proofBranch.anchors
    _forEach(anchors, anchor => {
      let flatAnchor = {}
      flatAnchor.branch = proofBranch.label || undefined
      flatAnchor.uri = anchor.uris[0]
      flatAnchor.type = anchor.type
      flatAnchor.anchor_id = anchor.anchor_id
      flatAnchor.expected_value = anchor.expected_value
      flatProofAnchors.push(flatAnchor)
    })
    if (proofBranch.branches) {
      flatProofAnchors = flatProofAnchors.concat(
        _flattenProofBranches(proofBranch.branches)
      )
    }
  })
  return flatProofAnchors
}
function _flattenProofBranches(proofBranchArray) {
  let flatProofAnchors = []

  _forEach(proofBranchArray, proofBranch => {
    let anchors = proofBranch.anchors
    _forEach(anchors, anchor => {
      let flatAnchor = {}
      flatAnchor.branch = proofBranch.label || undefined
      flatAnchor.uri = anchor.uris[0]
      flatAnchor.type = anchor.type
      flatAnchor.anchor_id = anchor.anchor_id
      flatAnchor.expected_value = anchor.expected_value
      flatProofAnchors.push(flatAnchor)
    })
    if (proofBranch.branches) {
      flatProofAnchors = flatProofAnchors.concat(
        _flattenProofBranches(proofBranch.branches)
      )
    }
  })
  return flatProofAnchors
}
function _flattenProofBranches ( proofBranchArray ) { let flatProofAnchors = [ ] _forEach ( proofBranchArray , proofBranch => { let anchors = proofBranch . anchors _forEach ( anchors , anchor => { let flatAnchor = { } flatAnchor . branch = proofBranch . label || undefined flatAnchor . uri = anchor . uris [ 0 ] flatAnchor . type = anchor . type flatAnchor . anchor_id = anchor . anchor_id flatAnchor . expected_value = anchor . expected_value flatProofAnchors . push ( flatAnchor ) } ) if ( proofBranch . branches ) { flatProofAnchors = flatProofAnchors . concat ( _flattenProofBranches ( proofBranch . branches ) ) } } ) return flatProofAnchors }
Flatten an Array of proof branches where each proof anchor in
each branch is represented as an Object with all relevant data for that anchor.

@param {Array} proofBranchArray - An Array of branches for a given level in a proof
@returns {Array} An Array of flattened proof anchor objects for each branch
Flatten an Array of proof branches where each proof anchor in each branch is represented as an Object with all relevant data for that anchor .