import isPlainObject from 'lodash/isPlainObject';
import isString from 'lodash/isString';
import LOAD_STATUS from './loadStatus';

function isImageString(image) {
  return isString(image);
}

function isImageObject(image) {
  return isPlainObject(image);
}

var formatImages = function formatImages(images) {
  var previewImages = [];
  (images || []).forEach(function (image) {
    if (isImageString(image)) {
      previewImages.push({
        src: image
      });
    } else if (isImageObject(image)) {
      previewImages.push({
        src: image.src,
        originSrc: image.originSrc,
        loaded: LOAD_STATUS.before
      });
    }
  });
  return previewImages;
};

export default formatImages;