'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.mergeDeepOnlyMaps = exports.compact = exports.keyBy = undefined;

var _immutable = require('immutable');

var keyBy = exports.keyBy = function keyBy(immutableList, keyAttr) {
  return immutableList.reduce(function (keyedMap, i) {
    return keyedMap.set(i.get(keyAttr), i);
  }, (0, _immutable.Map)());
};

// Remove any undefined values
var compact = exports.compact = function compact(immutableList) {
  return immutableList.filter(function (i) {
    return !!i;
  });
};

// Deep merge Maps, but not Lists or other Collections
var mergeDeepOnlyMaps = exports.mergeDeepOnlyMaps = function mergeDeepOnlyMaps(oldVal, newVal, key) {
  if (_immutable.Map.isMap(oldVal) && _immutable.Map.isMap(newVal)) {
    return oldVal.mergeWith(mergeDeepOnlyMaps, newVal);
  }
  return newVal;
};