function fromScriptChunk({tape, t}, chunk, index) {
  const n = tape.length - 1
  const i = tape[n].i

  // Handle Buffer
  if (chunk.buf) {
    if (chunk.buf.toString() === '|') {
      tape.push({ i: i+1 })
      return { tape, t: index + 1 }

    } else {
      tape[n].cell = tape[n].cell || []
      tape[n].cell.push({
        b: chunk.buf.toString('base64'),
        h: chunk.buf.toString('hex'),
        s: chunk.buf.toString(),
        i: index - t,
        ii: index
      })
      return { tape, t }
    }
  }

  // Handle opcode
  else {
    tape[n].cell = tape[n].cell || []
    tape[n].cell.push({
      op: chunk.opCodeNum,
      ops: OpCode.str[chunk.opCodeNum],
      i: index - t,
      ii: index
    })

    if (chunk.opCodeNum === OpCode.OP_RETURN) {
      tape.push({ i: i+1 })
      return { tape, t: index + 1 }
    } else {
      return { tape, t }
    }
  }
}
/**
 * Reducer function converts a BSV Script chunk to BOB parameters.
 * @private
 */
Reducer function converts a BSV Script chunk to BOB parameters.
@private
Reducer function converts a BSV Script chunk to BOB parameters . @private
function fromScriptChunk({tape, t}, chunk, index) {
  const n = tape.length - 1
  const i = tape[n].i
  if (chunk.buf) {
    if (chunk.buf.toString() === '|') {
      tape.push({ i: i+1 })
      return { tape, t: index + 1 }
    } else {
      tape[n].cell = tape[n].cell || []
      tape[n].cell.push({
        b: chunk.buf.toString('base64'),
        h: chunk.buf.toString('hex'),
        s: chunk.buf.toString(),
        i: index - t,
        ii: index
      })
      return { tape, t }
    }
  }
  else {
    tape[n].cell = tape[n].cell || []
    tape[n].cell.push({
      op: chunk.opCodeNum,
      ops: OpCode.str[chunk.opCodeNum],
      i: index - t,
      ii: index
    })
    if (chunk.opCodeNum === OpCode.OP_RETURN) {
      tape.push({ i: i+1 })
      return { tape, t: index + 1 }
    } else {
      return { tape, t }
    }
  }
}
function fromScriptChunk ( { tape , t } , chunk , index ) { const n = tape . length - 1 const i = tape [ n ] . i if ( chunk . buf ) { if ( chunk . buf . toString ( ) === '|' ) { tape . push ( { i : i + 1 } ) return { tape , t : index + 1 } } else { tape [ n ] . cell = tape [ n ] . cell || [ ] tape [ n ] . cell . push ( { b : chunk . buf . toString ( 'base64' ) , h : chunk . buf . toString ( 'hex' ) , s : chunk . buf . toString ( ) , i : index - t , ii : index } ) return { tape , t } } } else { tape [ n ] . cell = tape [ n ] . cell || [ ] tape [ n ] . cell . push ( { op : chunk . opCodeNum , ops : OpCode . str [ chunk . opCodeNum ] , i : index - t , ii : index } ) if ( chunk . opCodeNum === OpCode . OP_RETURN ) { tape . push ( { i : i + 1 } ) return { tape , t : index + 1 } } else { return { tape , t } } } }
Reducer function converts a BSV Script chunk to BOB parameters.
Reducer function converts a BSV Script chunk to BOB parameters .
// Handle Buffer // Handle opcode