import isEmpty from './isEmpty';
const getTypedValue = function getTypedValue(rawInput, type, options = {}) {
  const {
    getValue,
    lookup
  } = options;
  const input = getValue ? getValue(rawInput) : rawInput;
  if (isEmpty(input)) {
    return input;
  }
  if (type === 'string') {
    return input;
  }
  if (type === 'boolean') {
    return input;
  }
  if (type === 'date') {
    return new Date(input).getTime();
  }
  if (type === 'number') {
    return parseFloat(input);
  }
  if (type === 'lookup') {
    return lookup[input];
  }
  if (type === 'custom') {
    if (!getValue) {
      throw new Error('No "getValue" option provided for custom sort function');
    }
    return input;
  }
  return input;
};
export default getTypedValue;