packages/js-go-channels/src/index.js
function _createConsumerMessage(consumer, message, {chanId}) {
  const {
    iterator: consumerIterator,
    type: requestType,
    payload
  } = consumer
  if (requestType === cSelectRequest) {
    const {selectedChanIds} = payload
    const i = selectedChanIds.indexOf(chanId)
    const response = new Array(selectedChanIds.length)
    response[i] = message
    return [consumerIterator, response]
  } else if (requestType === cTakeRequest) {
    return [consumerIterator, message]
  }
  throw new Error(`Unknown request type ${requestType}`)
}
function _createConsumerMessage(consumer, message, {chanId}) {
  const {
    iterator: consumerIterator,
    type: requestType,
    payload
  } = consumer
  if (requestType === cSelectRequest) {
    const {selectedChanIds} = payload
    const i = selectedChanIds.indexOf(chanId)
    const response = new Array(selectedChanIds.length)
    response[i] = message
    return [consumerIterator, response]
  } else if (requestType === cTakeRequest) {
    return [consumerIterator, message]
  }
  throw new Error(`Unknown request type ${requestType}`)
}
function _createConsumerMessage ( consumer , message , { chanId } ) { const { iterator : consumerIterator , type : requestType , payload } = consumer if ( requestType === cSelectRequest ) { const { selectedChanIds } = payload const i = selectedChanIds . indexOf ( chanId ) const response = new Array ( selectedChanIds . length ) response [ i ] = message return [ consumerIterator , response ] } else if ( requestType === cTakeRequest ) { return [ consumerIterator , message ] } throw new Error ( ` ${ requestType } ` ) }
Does what it says. Need to take into account the case when the
consumer is a pending select, pending take. `select`s have a
different signature.
@param {Object} consumer - the consumer and message that was queued
@param {Iterator} consumer.iterator
@param {string} consumer.type - the consumer's message type
@param {Object} consumer.payload - the consumer's message payload
@param {Object} message - the message to give to the consumer
@param {Object} extraArgs
@param {string} extraArgs.chanId
@returns {[Iterator, Message]}
Does what it says . Need to take into account the case when the consumer is a pending select pending take . select s have a different signature .