src/command-parser.js
function parseFetchValue (key, value) {
  if (!value) {
    return null
  }

  if (!Array.isArray(value)) {
    switch (key) {
      case 'uid':
      case 'rfc822.size':
        return Number(value.value) || 0
      case 'modseq': // do not cast 64 bit uint to a number
        return value.value || '0'
    }
    return value.value
  }

  switch (key) {
    case 'flags':
    case 'x-gm-labels':
      value = [].concat(value).map((flag) => (flag.value || ''))
      break
    case 'envelope':
      value = parseENVELOPE([].concat(value || []))
      break
    case 'bodystructure':
      value = parseBODYSTRUCTURE([].concat(value || []))
      break
    case 'modseq':
      value = (value.shift() || {}).value || '0'
      break
  }

  return value
}
function parseFetchValue (key, value) {
  if (!value) {
    return null
  }

  if (!Array.isArray(value)) {
    switch (key) {
      case 'uid':
      case 'rfc822.size':
        return Number(value.value) || 0
      case 'modseq': // do not cast 64 bit uint to a number
        return value.value || '0'
    }
    return value.value
  }

  switch (key) {
    case 'flags':
    case 'x-gm-labels':
      value = [].concat(value).map((flag) => (flag.value || ''))
      break
    case 'envelope':
      value = parseENVELOPE([].concat(value || []))
      break
    case 'bodystructure':
      value = parseBODYSTRUCTURE([].concat(value || []))
      break
    case 'modseq':
      value = (value.shift() || {}).value || '0'
      break
  }

  return value
}
function parseFetchValue ( key , value ) { if ( ! value ) { return null } if ( ! Array . isArray ( value ) ) { switch ( key ) { case 'uid' : case 'rfc822.size' : return Number ( value . value ) || 0 case 'modseq' : // do not cast 64 bit uint to a number return value . value || '0' } return value . value } switch ( key ) { case 'flags' : case 'x-gm-labels' : value = [ ] . concat ( value ) . map ( ( flag ) => ( flag . value || '' ) ) break case 'envelope' : value = parseENVELOPE ( [ ] . concat ( value || [ ] ) ) break case 'bodystructure' : value = parseBODYSTRUCTURE ( [ ] . concat ( value || [ ] ) ) break case 'modseq' : value = ( value . shift ( ) || { } ) . value || '0' break } return value }
Parses a single value from the FETCH response object

@param {String} key Key name (uppercase)
@param {Mized} value Value for the key
@return {Mixed} Processed value
Parses a single value from the FETCH response object