src/index.js
function getItemValues(item, key) {
  if (typeof key === 'object') {
    key = key.key
  }
  let value
  if (typeof key === 'function') {
    value = key(item)
    // eslint-disable-next-line no-negated-condition
  } else if (key.indexOf('.') !== -1) {
    // handle nested keys
    value = key
      .split('.')
      .reduce(
        (itemObj, nestedKey) => (itemObj ? itemObj[nestedKey] : null),
        item,
      )
  } else {
    value = item[key]
  }
  // concat because `value` can be a string or an array
  // eslint-disable-next-line
  return value != null ? [].concat(value) : null
}
function getItemValues(item, key) {
  if (typeof key === 'object') {
    key = key.key
  }
  let value
  if (typeof key === 'function') {
    value = key(item)
    // eslint-disable-next-line no-negated-condition
  } else if (key.indexOf('.') !== -1) {
    // handle nested keys
    value = key
      .split('.')
      .reduce(
        (itemObj, nestedKey) => (itemObj ? itemObj[nestedKey] : null),
        item,
      )
  } else {
    value = item[key]
  }
  // concat because `value` can be a string or an array
  // eslint-disable-next-line
  return value != null ? [].concat(value) : null
}
function getItemValues ( item , key ) { if ( typeof key === 'object' ) { key = key . key } let value if ( typeof key === 'function' ) { value = key ( item ) // eslint-disable-next-line no-negated-condition } else if ( key . indexOf ( '.' ) !== - 1 ) { // handle nested keys value = key . split ( '.' ) . reduce ( ( itemObj , nestedKey ) => ( itemObj ? itemObj [ nestedKey ] : null ) , item , ) } else { value = item [ key ] } // concat because `value` can be a string or an array // eslint-disable-next-line return value != null ? [ ] . concat ( value ) : null }
Gets value for key in item at arbitrarily nested keypath
@param {Object} item - the item
@param {Object|Function} key - the potentially nested keypath or property callback
@return {Array} - an array containing the value(s) at the nested keypath
Gets value for key in item at arbitrarily nested keypath