index.js
function _flattenProofs(parsedProofs) {
  if (!_isArray(parsedProofs))
    throw new Error('parsedProofs arg must be an Array')
  if (_isEmpty(parsedProofs))
    throw new Error('parsedProofs arg must be a non-empty Array')

  let flatProofAnchors = []

  _forEach(parsedProofs, parsedProof => {
    let proofAnchors = _flattenProofBranches(parsedProof.branches)
    _forEach(proofAnchors, proofAnchor => {
      let flatProofAnchor = {}
      flatProofAnchor.hash = parsedProof.hash
      flatProofAnchor.hash_id_node = parsedProof.hash_id_node
      flatProofAnchor.hash_id_core = parsedProof.hash_id_core
      flatProofAnchor.hash_submitted_node_at =
        parsedProof.hash_submitted_node_at
      flatProofAnchor.hash_submitted_core_at =
        parsedProof.hash_submitted_core_at
      flatProofAnchor.branch = proofAnchor.branch
      flatProofAnchor.uri = proofAnchor.uri
      flatProofAnchor.type = proofAnchor.type
      flatProofAnchor.anchor_id = proofAnchor.anchor_id
      flatProofAnchor.expected_value = proofAnchor.expected_value
      flatProofAnchors.push(flatProofAnchor)
    })
  })

  return flatProofAnchors
}
function _flattenProofs(parsedProofs) {
  if (!_isArray(parsedProofs))
    throw new Error('parsedProofs arg must be an Array')
  if (_isEmpty(parsedProofs))
    throw new Error('parsedProofs arg must be a non-empty Array')

  let flatProofAnchors = []

  _forEach(parsedProofs, parsedProof => {
    let proofAnchors = _flattenProofBranches(parsedProof.branches)
    _forEach(proofAnchors, proofAnchor => {
      let flatProofAnchor = {}
      flatProofAnchor.hash = parsedProof.hash
      flatProofAnchor.hash_id_node = parsedProof.hash_id_node
      flatProofAnchor.hash_id_core = parsedProof.hash_id_core
      flatProofAnchor.hash_submitted_node_at =
        parsedProof.hash_submitted_node_at
      flatProofAnchor.hash_submitted_core_at =
        parsedProof.hash_submitted_core_at
      flatProofAnchor.branch = proofAnchor.branch
      flatProofAnchor.uri = proofAnchor.uri
      flatProofAnchor.type = proofAnchor.type
      flatProofAnchor.anchor_id = proofAnchor.anchor_id
      flatProofAnchor.expected_value = proofAnchor.expected_value
      flatProofAnchors.push(flatProofAnchor)
    })
  })

  return flatProofAnchors
}
function _flattenProofs ( parsedProofs ) { if ( ! _isArray ( parsedProofs ) ) throw new Error ( 'parsedProofs arg must be an Array' ) if ( _isEmpty ( parsedProofs ) ) throw new Error ( 'parsedProofs arg must be a non-empty Array' ) let flatProofAnchors = [ ] _forEach ( parsedProofs , parsedProof => { let proofAnchors = _flattenProofBranches ( parsedProof . branches ) _forEach ( proofAnchors , proofAnchor => { let flatProofAnchor = { } flatProofAnchor . hash = parsedProof . hash flatProofAnchor . hash_id_node = parsedProof . hash_id_node flatProofAnchor . hash_id_core = parsedProof . hash_id_core flatProofAnchor . hash_submitted_node_at = parsedProof . hash_submitted_node_at flatProofAnchor . hash_submitted_core_at = parsedProof . hash_submitted_core_at flatProofAnchor . branch = proofAnchor . branch flatProofAnchor . uri = proofAnchor . uri flatProofAnchor . type = proofAnchor . type flatProofAnchor . anchor_id = proofAnchor . anchor_id flatProofAnchor . expected_value = proofAnchor . expected_value flatProofAnchors . push ( flatProofAnchor ) } ) } ) return flatProofAnchors }
Flatten an Array of parsed proofs where each proof anchor is
represented as an Object with all relevant proof data.

@param {Array} parsedProofs - An Array of previously parsed proofs
@returns {Array} An Array of flattened proof objects
Flatten an Array of parsed proofs where each proof anchor is represented as an Object with all relevant proof data .